/** * @file analog_mux.h * @brief Header file for functions of analog initialisation and mux control. * * @copyright Copyright (c) 2025 Semidrive Semiconductor. * All rights reserved. */ #ifndef ANALOG_MUX_H_ #define ANALOG_MUX_H_ #include #include #define SINGLE_CHNL_POSITIVE 1u #define ADC_ACMP_POS_CHNL(ch) ((SINGLE_CHNL_POSITIVE << 3) | (ch)) #define ADC_ACMP_NEG_CHNL(ch) (ch) /* * Specify a scr signal of an analog mux corresponding to its channel. */ struct channel_amux_scr { uint16_t chnl; scr_signal_t scr_sig; }; /* * Specify a group of analog mux scr signals corresponding to a device. */ struct device_amux_scr { uintptr_t base; const struct channel_amux_scr *chnl_amux; uint32_t chnl_amux_cnt; }; /* * Specify a group of analog mux scr signals corresponding to a chip. */ struct chip_amux_scr { uintptr_t scr_base; const struct device_amux_scr *dev_amux; uint32_t dev_amux_cnt; struct chip_amux_scr *next; }; /* * Register a chip with its analog mux table to the chip list. */ void analog_chip_amux_register(struct chip_amux_scr *amux_scr); /* * Disable all analog mux of a chip. */ void analog_chip_amux_init(struct chip_amux_scr *amux_scr); /* * Disable all analog mux of the specified device. */ void analog_dev_amux_init(uintptr_t ana_dev_base); /* * Enable or disable the analog mux which the channel belongs to. */ void analog_dev_chnl_amux_cfg(uintptr_t ana_dev_base, uint16_t chnl, bool enable); /* * Disable all analog mux of ADC/ACMP device. * And register their scr signals to the chip list. */ void analog_init(void); /* * Register all scr signals of a chip to the chip list. */ void analog_mux_register(void); #endif /* ANALOG_MUX_H_ */