MLC interface driver
|
Macros | |
#define | AD_CH1 0x1 |
#define | AD_CH2 0x2 |
#define | AD_CH3 0x4 |
#define | AD_SOCA 0x1 |
#define | AD_SOCB 0x2 |
#define | AD_SOCC 0x4 |
#define | AD_OS0 0x0000 |
#define | AD_OS1 0x0001 |
#define | AD_OS2 0x0002 |
#define | AD_OS3 0x0003 |
#define | AD_OS4 0x0004 |
#define | AD_OS5 0x0005 |
#define | AD_OS6 0x0006 |
#define | AD_RNG_5V 0x0000 |
#define | AD_RNG_10V 0x0001 |
#define | AD_SOC_ALL_DEFAULT 0x0000 |
#define | AD_SOC_CH3_SOCA 0x1000 |
#define | AD_SOC_CH3_SOCB 0x2000 |
#define | AD_SOC_CH3_SOCAB 0x3000 |
#define | AD_SOC_ALL_SOCA 0x4000 |
#define | AD_SOC_ALL_SOCB 0x5000 |
#define | AD_IN0 0 |
#define | AD_IN1 2 |
#define | AD_IN2 4 |
#define | AD_IN3 6 |
#define | AD_IN4 8 |
#define | AD_IN5 10 |
#define | AD_IN6 12 |
#define | AD_IN7 14 |
#define | DMA_ADCH1 AD_CH1 |
#define | DMA_ADCH2 AD_CH2 |
#define | DMA_ADCH3 AD_CH3 |
Functions | |
void | MLC_ADC_reset (void) |
void | MLC_ADC_setup (unsigned int os_1, unsigned int os_2, unsigned int os_3, unsigned int rng_1, unsigned int rng_2, unsigned int rng_3) |
void | MLC_ADC_setup_SOC (uint16_t adsoc) |
void | MLC_ADC_start_conv (void) |
void | MLC_ADC_start_one_conv (uint16_t channel) |
volatile int16_t * | MLC_ADC1_read (void) |
volatile int16_t * | MLC_ADC2_read (void) |
volatile int16_t * | MLC_ADC3_read (void) |
volatile int16_t * | MLC_ADC1_get_res_ptr (void) |
volatile int16_t * | MLC_ADC2_get_res_ptr (void) |
volatile int16_t * | MLC_ADC3_get_res_ptr (void) |
volatile mlc_adc_result * | MLC_ADC1_get_res_strptr (void) |
volatile mlc_adc_result * | MLC_ADC2_get_res_strptr (void) |
volatile mlc_adc_result * | MLC_ADC3_get_res_strptr (void) |
volatile int16_t * | MLC_ADC_read (volatile int16_t *ad_res, uint16_t ad_addr) |
unsigned int | MLC_ADC_wait (void) |
float | MLC_ADC_calc_volt (int16_t value, uint16_t range) |
void | MLC_ADC_enable_isr (interrupt void *handler) |
void | MLC_ADC_disable_isr (void) |
void | MLC_DMA_enable_isr (uint16_t channel, interrupt void *handler) |
void | MLC_DMA_disable_isr (uint16_t channel) |
uint16_t | MLC_DMA_active (void) |
void | MLC_DMA_activate (void) |
void | MLC_DMA_deactivate (void) |
#define AD_CH1 0x1 |
Constant for selecting ADC CH1.
Definition at line 318 of file MLC_drv.h.
Referenced by MLC_ADC_start_one_conv(), and MLC_DMA_enable_isr().
#define AD_CH2 0x2 |
Constant for selecting ADC CH2.
Definition at line 319 of file MLC_drv.h.
Referenced by MLC_ADC_start_one_conv(), and MLC_DMA_enable_isr().
#define AD_CH3 0x4 |
Constant for selecting ADC CH3.
Definition at line 320 of file MLC_drv.h.
Referenced by MLC_ADC_start_one_conv(), and MLC_DMA_enable_isr().
#define AD_OS0 0x0000 |
Constant defining no oversampling for ADC.
Definition at line 330 of file MLC_drv.h.
Referenced by MLC_init().
#define AD_OS1 0x0001 |
#define AD_OS2 0x0002 |
#define AD_OS3 0x0003 |
#define AD_OS4 0x0004 |
#define AD_OS5 0x0005 |
#define AD_OS6 0x0006 |
#define AD_RNG_10V 0x0001 |
#define AD_RNG_5V 0x0000 |
Constant defining +/- 5V input range of ADC.
Definition at line 344 of file MLC_drv.h.
Referenced by MLC_init().
#define AD_SOC_ALL_DEFAULT 0x0000 |
CH3 will start with toggling of ADSOC pin - no HW SOC support
Definition at line 354 of file MLC_drv.h.
Referenced by MLC_init().
#define AD_SOC_ALL_SOCA 0x4000 |
#define AD_SOC_ALL_SOCB 0x5000 |
#define AD_SOC_CH3_SOCA 0x1000 |
#define AD_SOC_CH3_SOCAB 0x3000 |
#define AD_SOC_CH3_SOCB 0x2000 |
#define DMA_ADCH1 AD_CH1 |
Constant defining DMA CH1
Definition at line 374 of file MLC_drv.h.
Referenced by MLC_DMA_disable_isr().
#define DMA_ADCH2 AD_CH2 |
Constant defining DMA CH2
Definition at line 375 of file MLC_drv.h.
Referenced by MLC_DMA_disable_isr().
#define DMA_ADCH3 AD_CH3 |
Constant defining DMA CH3
Definition at line 376 of file MLC_drv.h.
Referenced by MLC_DMA_disable_isr().
volatile int16_t* MLC_ADC1_get_res_ptr | ( | void | ) |
volatile mlc_adc_result* MLC_ADC1_get_res_strptr | ( | void | ) |
Returns pointer to structure where measured values are stored, this function will NOT actually read a new data from AD1 !
volatile int16_t* MLC_ADC1_read | ( | void | ) |
Reads measured values from ADC No.1 this function triggers full read sequence and update values of array of AD results
Definition at line 1379 of file MLC_drv.c.
References MLC_ADC_read(), and READ_AD1.
volatile int16_t* MLC_ADC2_get_res_ptr | ( | void | ) |
volatile mlc_adc_result* MLC_ADC2_get_res_strptr | ( | void | ) |
Returns pointer to structure where measured values are stored, this function will NOT actually read a new data from AD2 !
volatile int16_t* MLC_ADC2_read | ( | void | ) |
Reads measured values from ADC No.2 this function triggers full read sequence and update values of array of AD results
Definition at line 1384 of file MLC_drv.c.
References MLC_ADC_read(), and READ_AD2.
volatile int16_t* MLC_ADC3_get_res_ptr | ( | void | ) |
volatile mlc_adc_result* MLC_ADC3_get_res_strptr | ( | void | ) |
Returns pointer to structure where measured values are stored, this function will NOT actually read a new data from AD3 !
volatile int16_t* MLC_ADC3_read | ( | void | ) |
Reads measured values from ADC No.3 this function triggers full read sequence and update values of array of AD results
Definition at line 1389 of file MLC_drv.c.
References MLC_ADC_read(), and READ_AD3.
float MLC_ADC_calc_volt | ( | int16_t | value, |
uint16_t | range | ||
) |
void MLC_ADC_disable_isr | ( | void | ) |
void MLC_ADC_enable_isr | ( | interrupt void * | handler | ) |
Function for setup of handler function called after conversion of AD ends. The handler has to acknowledge interrupt by command PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
TMS320F28335 - it uses XINT1 - i.e. int1.4. This interrupt should not be used in user code.
handler | pointer to function to call when conversion end. It MUST be defined with flag interrupt. |
Definition at line 1008 of file MLC_drv.c.
Referenced by MLC_ADC_setup().
volatile int16_t* MLC_ADC_read | ( | volatile int16_t * | ad_res, |
uint16_t | ad_addr | ||
) |
This function can be used to save some computing time. Use as MLC_read_AD(AD_res_1,READ_AD1);
ad_res | pointer to array where to store results. The array must have size of 16 words |
ad_addr | address of ADC in memory, use READ_ADx constant. |
Definition at line 1259 of file MLC_drv.c.
References MLC_READ, READ_AD1, READ_AD2, and READ_AD3.
Referenced by MLC_ADC1_read(), MLC_ADC2_read(), and MLC_ADC3_read().
void MLC_ADC_reset | ( | void | ) |
This function encapsulate reset process of ADCs.
Definition at line 1061 of file MLC_drv.c.
References DELAY_US(), MLC_WRITE, WRITE_CLRRES_AD, and WRITE_SETRES_AD.
Referenced by MLC_init().
void MLC_ADC_setup | ( | unsigned int | os_1, |
unsigned int | os_2, | ||
unsigned int | os_3, | ||
unsigned int | rng_1, | ||
unsigned int | rng_2, | ||
unsigned int | rng_3 | ||
) |
Function for setting oversampling and input range of all three ADCs.
os_1,os_2,os_3 | oversampling setup for each channel, use AD_OS0 - AD_OS6. Oversampling will prolong conversion time. I.e. if AD_OS6 is set, then conversion time will be 2^6*4us = 256us ! All ADC shares one BUSY signal, therefore conversion end is detected after slowest conversion finished. |
rng_1,rng_2,rng_3 | set input range, use AD_RNG_5V or AD_RNG_10V |
Definition at line 1191 of file MLC_drv.c.
References DELAY_US(), MLC_ADC_enable_isr(), MLC_WRITE, and WRITE_AD_CONF.
Referenced by MLC_init().
void MLC_ADC_setup_SOC | ( | uint16_t | adsoc | ) |
Function for setting CONVST source pin. Parameter defines which HW pin starts which ADC channel, valid combinations are defined by AD_SOC_* constants.
adsoc | is one of AD_SOC_* constants. |
Definition at line 1422 of file MLC_drv.c.
References MLC_WRITE, and WRITE_AD_CONF.
Referenced by MLC_init().
void MLC_ADC_start_conv | ( | void | ) |
Function for manually start conversion of all three channels. In this case settings setted by calling MLC_ADC_setup_SOC() has no meaning. All three channels will be always started.
Definition at line 1084 of file MLC_drv.c.
References DELAY_US(), mlc_info_t::pcb_hw_ver, and PCB_REV_1.
void MLC_ADC_start_one_conv | ( | uint16_t | channel | ) |
Function for manually start conversion of channel. Which ADC(s) will start measure is defined by MLC_ADC_setup_SOC() function.
channel | is one of AD_CHx constants. |
Definition at line 1122 of file MLC_drv.c.
References AD_CH1, AD_CH2, AD_CH3, DELAY_US(), mlc_info_t::pcb_hw_ver, and PCB_REV_1.
unsigned int MLC_ADC_wait | ( | void | ) |
void MLC_DMA_activate | ( | void | ) |
uint16_t MLC_DMA_active | ( | void | ) |
void MLC_DMA_deactivate | ( | void | ) |
void MLC_DMA_disable_isr | ( | uint16_t | channel | ) |
void MLC_DMA_enable_isr | ( | uint16_t | channel, |
interrupt void * | handler | ||
) |
Enables DMA interrupt and specify user handler. Interrupt handler must acknowledge interrupt at least by command PieCtrlRegs.PIEACK.all = PIEACK_GROUP7;
If DMA transfer is enabled, then it is automatically started after ADC conversion ends.
channel | DMA channel to enable, use one of constant of DMA_ADCHx |
handler | pointer to function to call when data transfer end. It MUST be defined with flag interrupt. |
Definition at line 932 of file MLC_drv.c.
References AD_CH1, AD_CH2, AD_CH3, BASE_ADDRESS, dmaConfigCtrlPacket(), and READ_AD1.