155 #include "platform.h"
222 #if MCU_TYPE == MCU_TYPE_TMS320F2812 || MCU_TYPE == MCU_TYPE_TMS320F28335
224 #define BASE_ADDRESS 0x00004000
227 #if MCU_TYPE == MCU_TYPE_TMS570LS3137
228 #define BASE_ADDRESS 0x60000000u
235 #define WRITE_AD_CONF 0x0000
236 #define WRITE_PWR_OUT 0x0001
237 #define WRITE_SETRES_AD 0x0002
238 #define WRITE_CLRRES_AD 0x0003
239 #define WRITE_DBGLEDS 0x0004
241 // read addresses constants
242 #define READ_VER 0x0000
243 #define READ_AD1 0x0001
244 #define READ_AD2 0x0002
245 #define READ_AD3 0x0003
246 #define READ_HV_INPUT 0x0004
247 #define READ_ARC 0x0005
248 #define READ_UIO 0x0009
249 #define READ_PCB_REV 0x000F
251 // read+write addresses constants
252 #define RW_CS_EXT1 0x0006
253 #define RW_CS_EXT2 0x0007
254 #define RW_CS_EXT3 0x0008
255 #define RW_UIO 0x0009
256 #define RW_UIO_CONF 0x000A
263 #define READ_FPGA_VER 0x0010
271 #define RW_FPGA_LED_REG 0x0011
278 #define WRITE_LCD_DISP 0x0012
280 #define FPGA_RESERVED_13 0x0013
281 #define FPGA_RESERVED_14 0x0014
282 #define FPGA_RESERVED_15 0x0015
283 #define FPGA_RESERVED_16 0x0016
285 #define FPGA_FAULTS_ADDR 0x0017
287 #define FPGA_RESERVED_18 0x0018
288 #define FPGA_RESERVED_19 0x0019
289 #define FPGA_RESERVED_1A 0x001A
290 #define FPGA_RESERVED_1B 0x001B
291 #define FPGA_RESERVED_1C 0x001C
292 #define FPGA_RESERVED_1D 0x001D
293 #define FPGA_RESERVED_1E 0x001E
294 #define FPGA_RESERVED_1F 0x001F
297 #define FPGA_LEDS_SHOW_DATA 0x0000
298 #define FPGA_LEDS_SHOW_PWMA 0x0100
299 #define FPGA_LEDS_SHOW_PWMB 0x0200
300 #define FPGA_LEDS_SHOW_PWMC 0x0300
301 #define FPGA_LEDS_SHOW_PWMD 0x0400
302 #define FPGA_LEDS_SHOW_PWME 0x0500
303 #define FPGA_LEDS_SHOW_PWMF 0x0600
330 #define AD_OS0 0x0000
332 #define AD_OS1 0x0001
334 #define AD_OS2 0x0002
336 #define AD_OS3 0x0003
338 #define AD_OS4 0x0004
340 #define AD_OS5 0x0005
342 #define AD_OS6 0x0006
343 // range select constants
344 #define AD_RNG_5V 0x0000
345 #define AD_RNG_10V 0x0001
347 // Parameters for MLC_setup_AD_SOC() function
354 #define AD_SOC_ALL_DEFAULT 0x0000
355 #define AD_SOC_CH3_SOCA 0x1000
356 #define AD_SOC_CH3_SOCB 0x2000
357 #define AD_SOC_CH3_SOCAB 0x3000
358 #define AD_SOC_ALL_SOCA 0x4000
359 #define AD_SOC_ALL_SOCB 0x5000
361 // This flag turns on use of EOC interrupt
374 #define DMA_ADCH1 AD_CH1
375 #define DMA_ADCH2 AD_CH2
376 #define DMA_ADCH3 AD_CH3
384 #define PCB_REV_1 0x1
385 #define PCB_REV_2 0x2
386 #define PCB_REV_3 0x3
395 // define buttons, they are active at 0, data is inverted
397 #if MCU_TYPE == MCU_TYPE_TMS320F28335
398 #define CHECK_BTN_S5() !GpioDataRegs.GPADAT.bit.GPIO28
399 #define CHECK_BTN_S8() !GpioDataRegs.GPADAT.bit.GPIO29
400 #define CHECK_BTN_S6() !GpioDataRegs.GPADAT.bit.GPIO30
402 #if USE_256kB_RAM == 1
403 #define CHECK_BTN_S7() 0
405 #define CHECK_BTN_S7() !GpioDataRegs.GPADAT.bit.GPIO31
410 #if MCU_TYPE == MCU_TYPE_TMS320F2812
411 #define CHECK_BTN_S5() !GpioDataRegs.GPFDAT.bit.GPIOF8
412 #define CHECK_BTN_S8() !GpioDataRegs.GPFDAT.bit.GPIOF9
413 #define CHECK_BTN_S6() !GpioDataRegs.GPFDAT.bit.GPIOF10
414 #define CHECK_BTN_S7() !GpioDataRegs.GPFDAT.bit.GPIOF11
417 #if MCU_TYPE == MCU_TYPE_TMS570LS3137
418 #define CHECK_BTN_S5() gioGetBit(gioPORTA, 3)
419 #define CHECK_BTN_S8() gioGetBit(gioPORTA, 2)
420 #define CHECK_BTN_S6() gioGetBit(gioPORTA, 4)
421 #define CHECK_BTN_S7() gioGetBit(gioPORTA, 0)
423 void DELAY_US(float us);
480 #define MLC_WRITE(addr, data) *((volatile uint16_t*)BASE_ADDRESS+addr)=(uint16_t)(data)
486 #define MLC_READ(addr) *((volatile uint16_t*)BASE_ADDRESS+addr)
506 #define FPGA_check_faults() MLC_READ(FPGA_FAULTS_ADDR)
511 #define NO_FAULTS 0x3F
533 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);
617 volatile int16_t*
MLC_ADC_read(
volatile int16_t* ad_res, uint16_t ad_addr);
648 #if MCU_TYPE == MCU_TYPE_TMS320F28335 || MCU_TYPE == MCU_TYPE_TMS570LS3137
731 extern uint16_t dac_values[8];
732 extern uint16_t dac_sel_ch[8];
734 void MLC_DAC_reset(void);
739 void MLC_DAC_control(uint16_t cmd);
753 #define dac_reset() MLC_DAC_reset()
754 #define dac_control MLC_DAC_control
755 #define dac_write MLC_DAC_write
756 #define write_dac MLC_DAC_write
757 #define dac_init() MLC_DAC_init()
758 #define dac_sel_channel dac_sel_ch
759 #define dac_variables dac_values
773 #define DEBUG_LEVEL_NONE 0
774 #define DEBUG_LEVEL_ERR 1
775 #define DEBUG_LEVEL_WRN 2
776 #define DEBUG_LEVEL_INFO 3
778 #if DEBUG_LEVEL == DEBUG_LEVEL_INFO
779 #define DBG_ERR_PUTS(str) puts(str)
780 #define DBG_WRN_PUTS(str) puts(str)
781 #define DBG_INFO_PUTS(str) puts(str)
784 #if DEBUG_LEVEL == DEBUG_LEVEL_WRN
785 #define DBG_ERR_PUTS(str) puts(str)
786 #define DBG_WRN_PUTS(str) puts(str)
787 #define DBG_INFO_PUTS(str) ;
790 #if DEBUG_LEVEL == DEBUG_LEVEL_ERR
791 #define DBG_ERR_PUTS(str) puts(str)
792 #define DBG_WRN_PUTS(str) ;
793 #define DBG_INFO_PUTS(str) ;
796 #if DEBUG_LEVEL == DEBUG_LEVEL_NONE
797 #define DBG_ERR_PUTS(str) ;
798 #define DBG_WRN_PUTS(str) ;
799 #define DBG_INFO_PUTS(str) ;
volatile int16_t * MLC_ADC1_read(void)
float MLC_ADC_calc_volt(int16_t value, uint16_t range)
void MLC_SCI_init(uint32_t baudrate)
void MLC_DMA_activate(void)
volatile int16_t * MLC_ADC3_read(void)
void MLC_LCD_write_to(uint16_t pos, char chr)
void MLC_ADC_setup_SOC(uint16_t adsoc)
void MLC_SCI_send_char(char c)
__inline void MLC_write(uint16_t addr, uint16_t data)
void MLC_ADC_start_one_conv(uint16_t channel)
volatile mlc_adc_result * MLC_ADC3_get_res_strptr(void)
volatile int16_t * MLC_ADC1_get_res_ptr(void)
void MLC_LCD_write_str(char *pStr, uint16_t pos)
uint16_t MLC_DMA_active(void)
void MLC_PWR_on(uint16_t pwr)
__inline uint16_t MLC_read(uint16_t addr)
void MLC_SCI_send_str(char *str)
void MLC_DMA_disable_isr(uint16_t channel)
char MLC_SCI_char_avail(void)
volatile int16_t * MLC_ADC2_get_res_ptr(void)
volatile mlc_adc_result * MLC_ADC2_get_res_strptr(void)
void MLC_DBG_clear(uint16_t dbg)
void MLC_PWR_off(uint16_t pwr)
unsigned int MLC_ADC_wait(void)
char MLC_SCI_recv_char(void)
Header configuration file for MLC driver.
Header file which adding support for external module.
volatile int16_t * MLC_ADC3_get_res_ptr(void)
void MLC_DAC_write(uint16_t count)
void MLC_SCI_send_char_wait(char c)
void MLC_LCD_clrscr(void)
void MLC_DMA_deactivate(void)
char MLC_SCI_wait_send(void)
volatile int16_t * MLC_ADC_read(volatile int16_t *ad_res, uint16_t ad_addr)
void MLC_global_disable()
void MLC_ADC_enable_isr(interrupt void *handler)
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_start_conv(void)
void MLC_ADC_disable_isr(void)
void MLC_DMA_enable_isr(uint16_t channel, interrupt void *handler)
void MLC_DBG_set(uint16_t dbg)
volatile int16_t * MLC_ADC2_read(void)
mlc_info_t * pMLC_info_struct
volatile mlc_adc_result * MLC_ADC1_get_res_strptr(void)