From fc635f792d939f56afe3d4eaf0faf19f7bf9ae63 Mon Sep 17 00:00:00 2001 From: sunbeam Date: Thu, 25 Jan 2024 14:22:18 +0800 Subject: [PATCH] =?UTF-8?q?87400=E5=8A=9F=E8=83=BDOK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 87400/.gitignore | 14 + 87400/application.ewd | 1476 +++++++++++++++ 87400/application.ewp | 1444 +++++++++++++++ 87400/application.ewt | 1557 ++++++++++++++++ 87400/application_based_on_bootloader.ewd | 1476 +++++++++++++++ 87400/application_based_on_bootloader.ewp | 1460 +++++++++++++++ 87400/application_based_on_bootloader.ewt | 1575 +++++++++++++++++ 87400/drivers/core/inc/flash_sfrs.h | 84 + 87400/drivers/core/inc/systick_sfrs.h | 99 ++ 87400/drivers/core/inc/verne.h | 64 + 87400/drivers/core/src/cstartup_M.c | 220 +++ 87400/drivers/core/src/low_level_init.c | 75 + 87400/drivers/hal/inc/adc_device.h | 155 ++ 87400/drivers/hal/inc/atomic.h | 21 + 87400/drivers/hal/inc/clock_device.h | 37 + 87400/drivers/hal/inc/ctt_device.h | 74 + 87400/drivers/hal/inc/errno.h | 21 + 87400/drivers/hal/inc/flash_device.h | 34 + 87400/drivers/hal/inc/gTimer_device.h | 61 + 87400/drivers/hal/inc/gpio_device.h | 89 + 87400/drivers/hal/inc/hwProtection.h | 150 ++ 87400/drivers/hal/inc/lin_device.h | 152 ++ 87400/drivers/hal/inc/math_div_device.h | 39 + 87400/drivers/hal/inc/pmu_device.h | 122 ++ 87400/drivers/hal/inc/pwm_aux_device.h | 44 + 87400/drivers/hal/inc/pwm_device.h | 67 + 87400/drivers/hal/inc/spi_device.h | 54 + 87400/drivers/hal/inc/systick_device.h | 49 + 87400/drivers/hal/inc/uart_device.h | 106 ++ 87400/drivers/hal/inc/wdt_device.h | 46 + 87400/drivers/hal/src/adc_device.c | 183 ++ 87400/drivers/hal/src/clock_device.c | 47 + 87400/drivers/hal/src/ctt_device.c | 137 ++ 87400/drivers/hal/src/flash_device.c | 36 + 87400/drivers/hal/src/gTimer_device.c | 101 ++ 87400/drivers/hal/src/gpio_device.c | 151 ++ 87400/drivers/hal/src/hwProtection.c | 153 ++ 87400/drivers/hal/src/lin_device.c | 333 ++++ 87400/drivers/hal/src/math_div_device.c | 3 + 87400/drivers/hal/src/pmu_device.c | 203 +++ 87400/drivers/hal/src/pwm_aux_device.c | 77 + 87400/drivers/hal/src/pwm_device.c | 231 +++ 87400/drivers/hal/src/spi_device.c | 114 ++ 87400/drivers/hal/src/systick_device.c | 52 + 87400/drivers/hal/src/uart_device.c | 111 ++ 87400/drivers/hal/src/wdt_device.c | 77 + 87400/drivers/hdf/meta.h | 66 + 87400/drivers/hdf/sfrs/crc_sfr.h | 94 + 87400/drivers/hdf/sfrs/crga_sfr.h | 247 +++ 87400/drivers/hdf/sfrs/ctt_sfr.h | 271 +++ 87400/drivers/hdf/sfrs/evthold_sfr.h | 75 + 87400/drivers/hdf/sfrs/flash_sfr.h | 162 ++ 87400/drivers/hdf/sfrs/gpio_sfr.h | 106 ++ 87400/drivers/hdf/sfrs/gtimer_sfr.h | 113 ++ 87400/drivers/hdf/sfrs/ioctrla_sfr.h | 238 +++ 87400/drivers/hdf/sfrs/lins_sfr.h | 261 +++ 87400/drivers/hdf/sfrs/mathdiv_sfr.h | 142 ++ 87400/drivers/hdf/sfrs/meta_sfr.h | 31 + 87400/drivers/hdf/sfrs/pmua_sfr.h | 175 ++ 87400/drivers/hdf/sfrs/pwm_aux_sfr.h | 207 +++ 87400/drivers/hdf/sfrs/pwm_sfr.h | 412 +++++ 87400/drivers/hdf/sfrs/sar_ctrl_sfr.h | 246 +++ 87400/drivers/hdf/sfrs/spi_sfr.h | 143 ++ 87400/drivers/hdf/sfrs/sram_sfr.h | 74 + 87400/drivers/hdf/sfrs/syscfg_sfr.h | 149 ++ 87400/drivers/hdf/sfrs/sysctrla_sfr.h | 187 ++ 87400/drivers/hdf/sfrs/trimhv_sfr.h | 250 +++ 87400/drivers/hdf/sfrs/uart0_sfr.h | 243 +++ 87400/drivers/hdf/sfrs/wdta_sfr.h | 140 ++ 87400/drivers/hdf/sfrs/wica_sfr.h | 103 ++ 87400/drivers/hwcfg/inc/hwcfg.h | 143 ++ 87400/drivers/hwcfg/src/hwcfg.c | 277 +++ 87400/generic_cortex.icf | 165 ++ 87400/metaLite.eww | 10 + 87400/metaLite_app.icf | 31 + 87400/metaLite_app_based_on_bootloader.icf | 31 + 87400/settings/application.Release.cspy.bat | 40 + 87400/settings/application.Release.cspy.ps1 | 31 + 87400/settings/application.Release.driver.xcl | 29 + .../settings/application.Release.general.xcl | 13 + 87400/settings/application.crun | 13 + 87400/settings/application.reggroups | 1 + 87400/settings/application_Release.jlink | 39 + ...ation_based_on_bootloader.Release.cspy.bat | 40 + ...ation_based_on_bootloader.Release.cspy.ps1 | 31 + ...ion_based_on_bootloader.Release.driver.xcl | 27 + ...on_based_on_bootloader.Release.general.xcl | 13 + .../application_based_on_bootloader.crun | 13 + ...lication_based_on_bootloader_Release.jlink | 35 + 87400/usr/common/appConfig.h | 54 + 87400/usr/common/applicationTask.c | 236 +++ 87400/usr/common/applicationTask.h | 43 + 87400/usr/common/crc32.c | 57 + 87400/usr/common/crc32.h | 26 + 87400/usr/common/isrfuncs.h | 83 + 87400/usr/common/linSlaveTask.h | 83 + 87400/usr/common/linsNodeCfgIdentify.c | 210 +++ 87400/usr/common/linsNodeCfgIdentify.h | 68 + 87400/usr/common/linsNodeCfgIdentify_J2602.c | 182 ++ 87400/usr/common/linslaveTask.c | 328 ++++ 87400/usr/common/linslaveTask_J2602.c | 467 +++++ 87400/usr/common/linslaveTask_Private.c | 220 +++ 87400/usr/common/measureTask.c | 93 + 87400/usr/common/measureTask.h | 40 + 87400/usr/common/motorControlTask.c | 22 + 87400/usr/common/motorControlTask.h | 37 + 87400/usr/common/pdsTask.c | 162 ++ 87400/usr/common/pdsTask.h | 56 + 87400/usr/common/safetyMonitorTask.c | 126 ++ 87400/usr/common/safetyMonitorTask.h | 33 + 87400/usr/common/systemInit.c | 82 + 87400/usr/common/systemInit.h | 35 + 87400/usr/common/taskManager.c | 115 ++ 87400/usr/common/taskManager.h | 74 + 87400/usr/common/validation.c | 99 ++ 87400/usr/common/validation.h | 8 + 87400/usr/fcode/PINdef.h | 45 + 87400/usr/fcode/hwCtrl.c | 152 ++ 87400/usr/fcode/hwCtrl.h | 16 + 87400/usr/fcode/prjconfig.h | 10 + 87400/usr/library/LinStackTask_metaLite.a | Bin 0 -> 112620 bytes 87400/usr/library/SoftTimerTask_metaLite.a | Bin 0 -> 5890 bytes 87400/usr/library/linStackTask.h | 533 ++++++ 87400/usr/library/softTimerTask.h | 78 + 87400/usr/main.c | 20 + 87400/usr/validation/inc/hdfVerify.h | 21 + 87400/usr/validation/inc/hwCfgVerify.h | 21 + 87400/usr/validation/inc/val_adc.h | 72 + 87400/usr/validation/inc/val_clock.h | 13 + 87400/usr/validation/inc/val_cttimer.h | 12 + 87400/usr/validation/inc/val_delay.h | 12 + 87400/usr/validation/inc/val_flash.h | 12 + 87400/usr/validation/inc/val_gpio.h | 13 + 87400/usr/validation/inc/val_gtimer.h | 12 + 87400/usr/validation/inc/val_lins.h | 11 + 87400/usr/validation/inc/val_m0.h | 12 + 87400/usr/validation/inc/val_mux.h | 72 + 87400/usr/validation/inc/val_pmu.h | 13 + 87400/usr/validation/inc/val_power.h | 12 + 87400/usr/validation/inc/val_pwm.h | 13 + 87400/usr/validation/inc/val_pwmaux.h | 13 + 87400/usr/validation/inc/val_spi.h | 13 + 87400/usr/validation/inc/val_system.h | 13 + 87400/usr/validation/inc/val_tempsensor.h | 13 + 87400/usr/validation/inc/val_uart.h | 11 + 87400/usr/validation/inc/val_wdta.h | 11 + 87400/usr/validation/inc/validation.h | 8 + 87400/usr/validation/src/hdfVerfify.c | 298 ++++ 87400/usr/validation/src/hwCfgVerify.c | 1150 ++++++++++++ 87400/usr/validation/src/val_adc.c | 127 ++ 87400/usr/validation/src/val_clock.c | 143 ++ 87400/usr/validation/src/val_cttimer.c | 17 + 87400/usr/validation/src/val_delay.c | 19 + 87400/usr/validation/src/val_flash.c | 17 + 87400/usr/validation/src/val_gpio.c | 117 ++ 87400/usr/validation/src/val_gtimer.c | 17 + 87400/usr/validation/src/val_lins.c | 27 + 87400/usr/validation/src/val_m0.c | 17 + 87400/usr/validation/src/val_mux.c | 149 ++ 87400/usr/validation/src/val_pmu.c | 66 + 87400/usr/validation/src/val_power.c | 31 + 87400/usr/validation/src/val_pwm.c | 17 + 87400/usr/validation/src/val_pwmaux.c | 80 + 87400/usr/validation/src/val_spi.c | 36 + 87400/usr/validation/src/val_system.c | 55 + 87400/usr/validation/src/val_tempsensor.c | 35 + 87400/usr/validation/src/val_timer.c | 17 + 87400/usr/validation/src/val_uart.c | 29 + 87400/usr/validation/src/val_wdta.c | 25 + 87400/usr/validation/src/validation.c | 84 + 170 files changed, 24860 insertions(+) create mode 100644 87400/.gitignore create mode 100644 87400/application.ewd create mode 100644 87400/application.ewp create mode 100644 87400/application.ewt create mode 100644 87400/application_based_on_bootloader.ewd create mode 100644 87400/application_based_on_bootloader.ewp create mode 100644 87400/application_based_on_bootloader.ewt create mode 100644 87400/drivers/core/inc/flash_sfrs.h create mode 100644 87400/drivers/core/inc/systick_sfrs.h create mode 100644 87400/drivers/core/inc/verne.h create mode 100644 87400/drivers/core/src/cstartup_M.c create mode 100644 87400/drivers/core/src/low_level_init.c create mode 100644 87400/drivers/hal/inc/adc_device.h create mode 100644 87400/drivers/hal/inc/atomic.h create mode 100644 87400/drivers/hal/inc/clock_device.h create mode 100644 87400/drivers/hal/inc/ctt_device.h create mode 100644 87400/drivers/hal/inc/errno.h create mode 100644 87400/drivers/hal/inc/flash_device.h create mode 100644 87400/drivers/hal/inc/gTimer_device.h create mode 100644 87400/drivers/hal/inc/gpio_device.h create mode 100644 87400/drivers/hal/inc/hwProtection.h create mode 100644 87400/drivers/hal/inc/lin_device.h create mode 100644 87400/drivers/hal/inc/math_div_device.h create mode 100644 87400/drivers/hal/inc/pmu_device.h create mode 100644 87400/drivers/hal/inc/pwm_aux_device.h create mode 100644 87400/drivers/hal/inc/pwm_device.h create mode 100644 87400/drivers/hal/inc/spi_device.h create mode 100644 87400/drivers/hal/inc/systick_device.h create mode 100644 87400/drivers/hal/inc/uart_device.h create mode 100644 87400/drivers/hal/inc/wdt_device.h create mode 100644 87400/drivers/hal/src/adc_device.c create mode 100644 87400/drivers/hal/src/clock_device.c create mode 100644 87400/drivers/hal/src/ctt_device.c create mode 100644 87400/drivers/hal/src/flash_device.c create mode 100644 87400/drivers/hal/src/gTimer_device.c create mode 100644 87400/drivers/hal/src/gpio_device.c create mode 100644 87400/drivers/hal/src/hwProtection.c create mode 100644 87400/drivers/hal/src/lin_device.c create mode 100644 87400/drivers/hal/src/math_div_device.c create mode 100644 87400/drivers/hal/src/pmu_device.c create mode 100644 87400/drivers/hal/src/pwm_aux_device.c create mode 100644 87400/drivers/hal/src/pwm_device.c create mode 100644 87400/drivers/hal/src/spi_device.c create mode 100644 87400/drivers/hal/src/systick_device.c create mode 100644 87400/drivers/hal/src/uart_device.c create mode 100644 87400/drivers/hal/src/wdt_device.c create mode 100644 87400/drivers/hdf/meta.h create mode 100644 87400/drivers/hdf/sfrs/crc_sfr.h create mode 100644 87400/drivers/hdf/sfrs/crga_sfr.h create mode 100644 87400/drivers/hdf/sfrs/ctt_sfr.h create mode 100644 87400/drivers/hdf/sfrs/evthold_sfr.h create mode 100644 87400/drivers/hdf/sfrs/flash_sfr.h create mode 100644 87400/drivers/hdf/sfrs/gpio_sfr.h create mode 100644 87400/drivers/hdf/sfrs/gtimer_sfr.h create mode 100644 87400/drivers/hdf/sfrs/ioctrla_sfr.h create mode 100644 87400/drivers/hdf/sfrs/lins_sfr.h create mode 100644 87400/drivers/hdf/sfrs/mathdiv_sfr.h create mode 100644 87400/drivers/hdf/sfrs/meta_sfr.h create mode 100644 87400/drivers/hdf/sfrs/pmua_sfr.h create mode 100644 87400/drivers/hdf/sfrs/pwm_aux_sfr.h create mode 100644 87400/drivers/hdf/sfrs/pwm_sfr.h create mode 100644 87400/drivers/hdf/sfrs/sar_ctrl_sfr.h create mode 100644 87400/drivers/hdf/sfrs/spi_sfr.h create mode 100644 87400/drivers/hdf/sfrs/sram_sfr.h create mode 100644 87400/drivers/hdf/sfrs/syscfg_sfr.h create mode 100644 87400/drivers/hdf/sfrs/sysctrla_sfr.h create mode 100644 87400/drivers/hdf/sfrs/trimhv_sfr.h create mode 100644 87400/drivers/hdf/sfrs/uart0_sfr.h create mode 100644 87400/drivers/hdf/sfrs/wdta_sfr.h create mode 100644 87400/drivers/hdf/sfrs/wica_sfr.h create mode 100644 87400/drivers/hwcfg/inc/hwcfg.h create mode 100644 87400/drivers/hwcfg/src/hwcfg.c create mode 100644 87400/generic_cortex.icf create mode 100644 87400/metaLite.eww create mode 100644 87400/metaLite_app.icf create mode 100644 87400/metaLite_app_based_on_bootloader.icf create mode 100644 87400/settings/application.Release.cspy.bat create mode 100644 87400/settings/application.Release.cspy.ps1 create mode 100644 87400/settings/application.Release.driver.xcl create mode 100644 87400/settings/application.Release.general.xcl create mode 100644 87400/settings/application.crun create mode 100644 87400/settings/application.reggroups create mode 100644 87400/settings/application_Release.jlink create mode 100644 87400/settings/application_based_on_bootloader.Release.cspy.bat create mode 100644 87400/settings/application_based_on_bootloader.Release.cspy.ps1 create mode 100644 87400/settings/application_based_on_bootloader.Release.driver.xcl create mode 100644 87400/settings/application_based_on_bootloader.Release.general.xcl create mode 100644 87400/settings/application_based_on_bootloader.crun create mode 100644 87400/settings/application_based_on_bootloader_Release.jlink create mode 100644 87400/usr/common/appConfig.h create mode 100644 87400/usr/common/applicationTask.c create mode 100644 87400/usr/common/applicationTask.h create mode 100644 87400/usr/common/crc32.c create mode 100644 87400/usr/common/crc32.h create mode 100644 87400/usr/common/isrfuncs.h create mode 100644 87400/usr/common/linSlaveTask.h create mode 100644 87400/usr/common/linsNodeCfgIdentify.c create mode 100644 87400/usr/common/linsNodeCfgIdentify.h create mode 100644 87400/usr/common/linsNodeCfgIdentify_J2602.c create mode 100644 87400/usr/common/linslaveTask.c create mode 100644 87400/usr/common/linslaveTask_J2602.c create mode 100644 87400/usr/common/linslaveTask_Private.c create mode 100644 87400/usr/common/measureTask.c create mode 100644 87400/usr/common/measureTask.h create mode 100644 87400/usr/common/motorControlTask.c create mode 100644 87400/usr/common/motorControlTask.h create mode 100644 87400/usr/common/pdsTask.c create mode 100644 87400/usr/common/pdsTask.h create mode 100644 87400/usr/common/safetyMonitorTask.c create mode 100644 87400/usr/common/safetyMonitorTask.h create mode 100644 87400/usr/common/systemInit.c create mode 100644 87400/usr/common/systemInit.h create mode 100644 87400/usr/common/taskManager.c create mode 100644 87400/usr/common/taskManager.h create mode 100644 87400/usr/common/validation.c create mode 100644 87400/usr/common/validation.h create mode 100644 87400/usr/fcode/PINdef.h create mode 100644 87400/usr/fcode/hwCtrl.c create mode 100644 87400/usr/fcode/hwCtrl.h create mode 100644 87400/usr/fcode/prjconfig.h create mode 100644 87400/usr/library/LinStackTask_metaLite.a create mode 100644 87400/usr/library/SoftTimerTask_metaLite.a create mode 100644 87400/usr/library/linStackTask.h create mode 100644 87400/usr/library/softTimerTask.h create mode 100644 87400/usr/main.c create mode 100644 87400/usr/validation/inc/hdfVerify.h create mode 100644 87400/usr/validation/inc/hwCfgVerify.h create mode 100644 87400/usr/validation/inc/val_adc.h create mode 100644 87400/usr/validation/inc/val_clock.h create mode 100644 87400/usr/validation/inc/val_cttimer.h create mode 100644 87400/usr/validation/inc/val_delay.h create mode 100644 87400/usr/validation/inc/val_flash.h create mode 100644 87400/usr/validation/inc/val_gpio.h create mode 100644 87400/usr/validation/inc/val_gtimer.h create mode 100644 87400/usr/validation/inc/val_lins.h create mode 100644 87400/usr/validation/inc/val_m0.h create mode 100644 87400/usr/validation/inc/val_mux.h create mode 100644 87400/usr/validation/inc/val_pmu.h create mode 100644 87400/usr/validation/inc/val_power.h create mode 100644 87400/usr/validation/inc/val_pwm.h create mode 100644 87400/usr/validation/inc/val_pwmaux.h create mode 100644 87400/usr/validation/inc/val_spi.h create mode 100644 87400/usr/validation/inc/val_system.h create mode 100644 87400/usr/validation/inc/val_tempsensor.h create mode 100644 87400/usr/validation/inc/val_uart.h create mode 100644 87400/usr/validation/inc/val_wdta.h create mode 100644 87400/usr/validation/inc/validation.h create mode 100644 87400/usr/validation/src/hdfVerfify.c create mode 100644 87400/usr/validation/src/hwCfgVerify.c create mode 100644 87400/usr/validation/src/val_adc.c create mode 100644 87400/usr/validation/src/val_clock.c create mode 100644 87400/usr/validation/src/val_cttimer.c create mode 100644 87400/usr/validation/src/val_delay.c create mode 100644 87400/usr/validation/src/val_flash.c create mode 100644 87400/usr/validation/src/val_gpio.c create mode 100644 87400/usr/validation/src/val_gtimer.c create mode 100644 87400/usr/validation/src/val_lins.c create mode 100644 87400/usr/validation/src/val_m0.c create mode 100644 87400/usr/validation/src/val_mux.c create mode 100644 87400/usr/validation/src/val_pmu.c create mode 100644 87400/usr/validation/src/val_power.c create mode 100644 87400/usr/validation/src/val_pwm.c create mode 100644 87400/usr/validation/src/val_pwmaux.c create mode 100644 87400/usr/validation/src/val_spi.c create mode 100644 87400/usr/validation/src/val_system.c create mode 100644 87400/usr/validation/src/val_tempsensor.c create mode 100644 87400/usr/validation/src/val_timer.c create mode 100644 87400/usr/validation/src/val_uart.c create mode 100644 87400/usr/validation/src/val_wdta.c create mode 100644 87400/usr/validation/src/validation.c diff --git a/87400/.gitignore b/87400/.gitignore new file mode 100644 index 0000000..210b1df --- /dev/null +++ b/87400/.gitignore @@ -0,0 +1,14 @@ +/Release/exe +/Release/List +/Release/Obj +/Debug/exe +/Debug/List +/Debug/Obj +/Function_Blocks/Releases/exe +/Function_Blocks/Releases/List +/Function_Blocks/Releases/Obj +*.dep +/settings/*.wsdt +/settings/*.dbgdt +/settings/*.dnx +/.vscode/*.* diff --git a/87400/application.ewd b/87400/application.ewd new file mode 100644 index 0000000..0762390 --- /dev/null +++ b/87400/application.ewd @@ -0,0 +1,1476 @@ + + + 3 + + Release + + ARM + + 0 + + C-SPY + 2 + + 30 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ARMSIM_ID + 2 + + 1 + 1 + 0 + + + + + + + + CADI_ID + 2 + + 0 + 1 + 0 + + + + + + + + + CMSISDAP_ID + 2 + + 4 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GDBSERVER_ID + 2 + + 0 + 1 + 0 + + + + + + + + + + + IJET_ID + 2 + + 8 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JLINK_ID + 2 + + 16 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LMIFTDI_ID + 2 + + 2 + 1 + 0 + + + + + + + + + + NULINK_ID + 2 + + 0 + 1 + 0 + + + + + + + PEMICRO_ID + 2 + + 3 + 1 + 0 + + + + + + + + STLINK_ID + 2 + + 5 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + THIRDPARTY_ID + 2 + + 0 + 1 + 0 + + + + + + + + TIFET_ID + 2 + + 1 + 1 + 0 + + + + + + + + + + + + + + + + + + + XDS100_ID + 2 + + 8 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\FreeRtos\FreeRtosArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\Mbed\MbedArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\Mbed\MbedArmPlugin2.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm8.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm8BE.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin + 0 + + + $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\TargetAccessServer\TargetAccessServer.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin + 0 + + + + diff --git a/87400/application.ewp b/87400/application.ewp new file mode 100644 index 0000000..3d032b6 --- /dev/null +++ b/87400/application.ewp @@ -0,0 +1,1444 @@ + + + 3 + + Release + + ARM + + 0 + + General + 3 + + 31 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 35 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 10 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 0 + + + + + + + + + CUSTOM + 3 + + + + 0 + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 23 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 0 + + + + + + + BILINK + 0 + + + + + applications + + config + + $PROJ_DIR$\usr\common\appConfig.h + + + + fcode + + $PROJ_DIR$\usr\fcode\hwCtrl.c + + + $PROJ_DIR$\usr\fcode\hwCtrl.h + + + $PROJ_DIR$\usr\fcode\PINdef.h + + + $PROJ_DIR$\usr\fcode\prjconfig.h + + + + include + + $PROJ_DIR$\usr\common\applicationTask.h + + + $PROJ_DIR$\usr\common\isrfuncs.h + + + $PROJ_DIR$\usr\leds\ledParamTables.h + + + $PROJ_DIR$\usr\common\linMasterTask.h + + + $PROJ_DIR$\usr\common\linSlaveTask.h + + + $PROJ_DIR$\usr\common\linsNodeCfgIdentify.h + + + $PROJ_DIR$\usr\library\linStackTask.h + + + $PROJ_DIR$\usr\common\measureTask.h + + + $PROJ_DIR$\usr\common\motorControlTask.h + + + $PROJ_DIR$\usr\common\pdsTask.h + + + $PROJ_DIR$\usr\common\safetyMonitorTask.h + + + $PROJ_DIR$\usr\library\softTimerTask.h + + + $PROJ_DIR$\usr\common\systemInit.h + + + $PROJ_DIR$\usr\common\taskManager.h + + + + src + + $PROJ_DIR$\usr\common\applicationTask.c + + + $PROJ_DIR$\usr\common\linslaveTask.c + + + $PROJ_DIR$\usr\common\linslaveTask_J2602.c + + + $PROJ_DIR$\usr\common\linslaveTask_Private.c + + + $PROJ_DIR$\usr\common\linsNodeCfgIdentify.c + + + $PROJ_DIR$\usr\common\linsNodeCfgIdentify_J2602.c + + + $PROJ_DIR$\usr\common\measureTask.c + + + $PROJ_DIR$\usr\common\motorControlTask.c + + + $PROJ_DIR$\usr\common\pdsTask.c + + + $PROJ_DIR$\usr\common\safetyMonitorTask.c + + + + + crc + + include + + $PROJ_DIR$\usr\common\crc32.h + + + + src + + $PROJ_DIR$\usr\common\crc32.c + + + + + drivers + + core + + inc + + $PROJ_DIR$\drivers\core\inc\flash_sfrs.h + + + $PROJ_DIR$\drivers\core\inc\systick_sfrs.h + + + $PROJ_DIR$\drivers\core\inc\verne.h + + + + src + + $PROJ_DIR$\drivers\core\src\cstartup_M.c + + + $PROJ_DIR$\drivers\core\src\low_level_init.c + + + + + hal + + inc + + $PROJ_DIR$\drivers\hal\inc\adc_device.h + + + $PROJ_DIR$\drivers\hal\inc\atomic.h + + + $PROJ_DIR$\drivers\hal\inc\clock_device.h + + + $PROJ_DIR$\drivers\hal\inc\errno.h + + + $PROJ_DIR$\drivers\hal\inc\flash_device.h + + + $PROJ_DIR$\drivers\hal\inc\gpio_device.h + + + $PROJ_DIR$\drivers\hal\inc\hwProtection.h + + + $PROJ_DIR$\drivers\hal\inc\lin_device.h + + + $PROJ_DIR$\drivers\hal\inc\pmu_device.h + + + $PROJ_DIR$\drivers\hal\inc\pwm_aux_device.h + + + $PROJ_DIR$\drivers\hal\inc\pwm_device.h + + + $PROJ_DIR$\drivers\hal\inc\systick_device.h + + + $PROJ_DIR$\drivers\hal\inc\timer_device.h + + + $PROJ_DIR$\drivers\hal\inc\wdt_device.h + + + + src + + $PROJ_DIR$\drivers\hal\src\adc_device.c + + + $PROJ_DIR$\drivers\hal\src\clock_device.c + + + $PROJ_DIR$\drivers\hal\src\ctt_device.c + + + $PROJ_DIR$\drivers\hal\src\flash_device.c + + + $PROJ_DIR$\drivers\hal\src\gpio_device.c + + + $PROJ_DIR$\drivers\hal\src\gTimer_device.c + + + $PROJ_DIR$\drivers\hal\src\hwProtection.c + + + $PROJ_DIR$\drivers\hal\src\lin_device.c + + + $PROJ_DIR$\drivers\hal\src\pmu_device.c + + + $PROJ_DIR$\drivers\hal\src\pwm_aux_device.c + + + $PROJ_DIR$\drivers\hal\src\pwm_device.c + + + $PROJ_DIR$\drivers\hal\src\spi_device.c + + + $PROJ_DIR$\drivers\hal\src\systick_device.c + + + $PROJ_DIR$\drivers\hal\src\uart_device.c + + + $PROJ_DIR$\drivers\hal\src\wdt_device.c + + + + + hdf + + inc + + $PROJ_DIR$\drivers\hdf\sfrs\bte_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\crc_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\crga_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\ctt_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\evthold_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\flash_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\gpio_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\gtimer_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\ioctrla_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\lins_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\mathdiv_sfr.h + + + $PROJ_DIR$\drivers\hdf\meta.h + + + $PROJ_DIR$\drivers\hdf\sfrs\meta_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\pmua_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\pwm_aux_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\pwm_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\sar_ctrl_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\spi_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\sram_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\syscfg_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\sysctrla_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\trimhv_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\uart0_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\wdt1_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\wdta_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\wica_sfr.h + + + + + hwcfg + + inc + + $PROJ_DIR$\drivers\hwcfg\inc\hwcfg.h + + + + src + + $PROJ_DIR$\drivers\hwcfg\src\hwcfg.c + + + + + + library + + $PROJ_DIR$\usr\library\LinStackTask_metaLite.a + + + $PROJ_DIR$\usr\library\SoftTimerTask_metaLite.a + + + + tasks + + $PROJ_DIR$\usr\common\systemInit.c + + + $PROJ_DIR$\usr\common\taskManager.c + + + + validation + + $PROJ_DIR$\usr\common\validation.c + + + $PROJ_DIR$\usr\common\validation.h + + + + $PROJ_DIR$\usr\main.c + + diff --git a/87400/application.ewt b/87400/application.ewt new file mode 100644 index 0000000..870cbe8 --- /dev/null +++ b/87400/application.ewt @@ -0,0 +1,1557 @@ + + + 3 + + Release + + ARM + + 0 + + C-STAT + 261 + + 261 + + 0 + + 1 + 600 + 1 + 4 + 0 + 1 + 100 + + + 1.5.3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RuntimeChecking + 0 + + 2 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + applications + + config + + $PROJ_DIR$\usr\common\appConfig.h + + + + fcode + + $PROJ_DIR$\usr\fcode\hwCtrl.c + + + $PROJ_DIR$\usr\fcode\hwCtrl.h + + + $PROJ_DIR$\usr\fcode\PINdef.h + + + $PROJ_DIR$\usr\fcode\prjconfig.h + + + + include + + $PROJ_DIR$\usr\common\applicationTask.h + + + $PROJ_DIR$\usr\common\isrfuncs.h + + + $PROJ_DIR$\usr\leds\ledParamTables.h + + + $PROJ_DIR$\usr\common\linMasterTask.h + + + $PROJ_DIR$\usr\common\linslaveTask.h + + + $PROJ_DIR$\usr\common\linsNodeCfgIdentify.h + + + $PROJ_DIR$\usr\library\linStackTask.h + + + $PROJ_DIR$\usr\common\measureTask.h + + + $PROJ_DIR$\usr\common\motorControlTask.h + + + $PROJ_DIR$\usr\common\pdsTask.h + + + $PROJ_DIR$\usr\common\safetyMonitorTask.h + + + $PROJ_DIR$\usr\library\SoftTimerTask.h + + + $PROJ_DIR$\usr\common\systemInit.h + + + $PROJ_DIR$\usr\common\taskManager.h + + + + src + + $PROJ_DIR$\usr\common\applicationTask.c + + + $PROJ_DIR$\usr\common\linslaveTask.c + + + $PROJ_DIR$\usr\common\linslaveTask_J2602.c + + + $PROJ_DIR$\usr\common\linslaveTask_Private.c + + + $PROJ_DIR$\usr\common\linsNodeCfgIdentify.c + + + $PROJ_DIR$\usr\common\linsNodeCfgIdentify_J2602.c + + + $PROJ_DIR$\usr\common\measureTask.c + + + $PROJ_DIR$\usr\common\motorControlTask.c + + + $PROJ_DIR$\usr\common\pdsTask.c + + + $PROJ_DIR$\usr\common\safetyMonitorTask.c + + + + + crc + + include + + $PROJ_DIR$\usr\common\crc32.h + + + + src + + $PROJ_DIR$\usr\common\crc32.c + + + + + drivers + + core + + inc + + $PROJ_DIR$\drivers\core\inc\flash_sfrs.h + + + $PROJ_DIR$\drivers\core\inc\systick_sfrs.h + + + $PROJ_DIR$\drivers\core\inc\verne.h + + + + src + + $PROJ_DIR$\drivers\core\src\cstartup_M.c + + + $PROJ_DIR$\drivers\core\src\low_level_init.c + + + + + hal + + inc + + $PROJ_DIR$\drivers\hal\inc\adc_device.h + + + $PROJ_DIR$\drivers\hal\inc\atomic.h + + + $PROJ_DIR$\drivers\hal\inc\clock_device.h + + + $PROJ_DIR$\drivers\hal\inc\errno.h + + + $PROJ_DIR$\drivers\hal\inc\flash_device.h + + + $PROJ_DIR$\drivers\hal\inc\gpio_device.h + + + $PROJ_DIR$\drivers\hal\inc\hwProtection.h + + + $PROJ_DIR$\drivers\hal\inc\lin_device.h + + + $PROJ_DIR$\drivers\hal\inc\pmu_device.h + + + $PROJ_DIR$\drivers\hal\inc\pwm_aux_device.h + + + $PROJ_DIR$\drivers\hal\inc\pwm_device.h + + + $PROJ_DIR$\drivers\hal\inc\systick_device.h + + + $PROJ_DIR$\drivers\hal\inc\timer_device.h + + + $PROJ_DIR$\drivers\hal\inc\wdt_device.h + + + + src + + $PROJ_DIR$\drivers\hal\src\adc_device.c + + + $PROJ_DIR$\drivers\hal\src\clock_device.c + + + $PROJ_DIR$\drivers\hal\src\ctt_device.c + + + $PROJ_DIR$\drivers\hal\src\flash_device.c + + + $PROJ_DIR$\drivers\hal\src\gpio_device.c + + + $PROJ_DIR$\drivers\hal\src\gTimer_device.c + + + $PROJ_DIR$\drivers\hal\src\hwProtection.c + + + $PROJ_DIR$\drivers\hal\src\lin_device.c + + + $PROJ_DIR$\drivers\hal\src\pmu_device.c + + + $PROJ_DIR$\drivers\hal\src\pwm_aux_device.c + + + $PROJ_DIR$\drivers\hal\src\pwm_device.c + + + $PROJ_DIR$\drivers\hal\src\spi_device.c + + + $PROJ_DIR$\drivers\hal\src\systick_device.c + + + $PROJ_DIR$\drivers\hal\src\uart_device.c + + + $PROJ_DIR$\drivers\hal\src\wdt_device.c + + + + + hdf + + inc + + $PROJ_DIR$\drivers\hdf\sfrs\bte_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\crc_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\crga_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\ctt_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\evthold_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\flash_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\gpio_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\gtimer_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\ioctrla_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\lins_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\mathdiv_sfr.h + + + $PROJ_DIR$\drivers\hdf\meta.h + + + $PROJ_DIR$\drivers\hdf\sfrs\meta_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\pmua_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\pwm_aux_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\pwm_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\sar_ctrl_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\spi_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\sram_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\syscfg_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\sysctrla_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\trimhv_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\uart0_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\wdt1_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\wdta_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\wica_sfr.h + + + + + hwcfg + + inc + + $PROJ_DIR$\drivers\hwcfg\inc\hwcfg.h + + + + src + + $PROJ_DIR$\drivers\hwcfg\src\hwcfg.c + + + + + + library + + $PROJ_DIR$\usr\library\LinStackTask_metaLite.a + + + $PROJ_DIR$\usr\library\SoftTimerTask_metaLite.a + + + + tasks + + $PROJ_DIR$\usr\common\systemInit.c + + + $PROJ_DIR$\usr\common\taskManager.c + + + + validation + + $PROJ_DIR$\usr\common\validation.c + + + $PROJ_DIR$\usr\common\validation.h + + + + $PROJ_DIR$\usr\main.c + + diff --git a/87400/application_based_on_bootloader.ewd b/87400/application_based_on_bootloader.ewd new file mode 100644 index 0000000..2c5f628 --- /dev/null +++ b/87400/application_based_on_bootloader.ewd @@ -0,0 +1,1476 @@ + + + 3 + + Release + + ARM + + 0 + + C-SPY + 2 + + 30 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ARMSIM_ID + 2 + + 1 + 1 + 0 + + + + + + + + CADI_ID + 2 + + 0 + 1 + 0 + + + + + + + + + CMSISDAP_ID + 2 + + 4 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GDBSERVER_ID + 2 + + 0 + 1 + 0 + + + + + + + + + + + IJET_ID + 2 + + 8 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JLINK_ID + 2 + + 16 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LMIFTDI_ID + 2 + + 2 + 1 + 0 + + + + + + + + + + NULINK_ID + 2 + + 0 + 1 + 0 + + + + + + + PEMICRO_ID + 2 + + 3 + 1 + 0 + + + + + + + + STLINK_ID + 2 + + 5 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + THIRDPARTY_ID + 2 + + 0 + 1 + 0 + + + + + + + + TIFET_ID + 2 + + 1 + 1 + 0 + + + + + + + + + + + + + + + + + + + XDS100_ID + 2 + + 8 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\FreeRtos\FreeRtosArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\Mbed\MbedArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\Mbed\MbedArmPlugin2.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm8.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm8BE.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin + 0 + + + $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin + 1 + + + $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\TargetAccessServer\TargetAccessServer.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin + 0 + + + + diff --git a/87400/application_based_on_bootloader.ewp b/87400/application_based_on_bootloader.ewp new file mode 100644 index 0000000..bb87b47 --- /dev/null +++ b/87400/application_based_on_bootloader.ewp @@ -0,0 +1,1460 @@ + + + 3 + + Release + + ARM + + 0 + + General + 3 + + 31 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 35 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 10 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 0 + + + + + + + + + CUSTOM + 3 + + + + 0 + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 23 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 0 + + + + + + + BILINK + 0 + + + + + applications + + config + + $PROJ_DIR$\usr\common\appConfig.h + + + + fcode + + $PROJ_DIR$\usr\fcode\hwCtrl.c + + + $PROJ_DIR$\usr\fcode\hwCtrl.h + + + $PROJ_DIR$\usr\fcode\PINdef.h + + + $PROJ_DIR$\usr\fcode\prjconfig.h + + + + includes + + $PROJ_DIR$\usr\common\applicationTask.h + + + $PROJ_DIR$\usr\common\colorCompensationTask.h + + + $PROJ_DIR$\Function_Blocks\ColorMixingTask\colorFormula.h + + + $PROJ_DIR$\usr\library\colorMixingTask.h + + + $PROJ_DIR$\usr\common\linMasterTask.h + + + $PROJ_DIR$\usr\common\linslaveTask.h + + + $PROJ_DIR$\usr\common\linsNodeCfgIdentify.h + + + $PROJ_DIR$\usr\library\linStackTask.h + + + $PROJ_DIR$\usr\common\measureTask.h + + + $PROJ_DIR$\usr\common\pdsTask.h + + + $PROJ_DIR$\usr\common\safetyMonitorTask.h + + + $PROJ_DIR$\usr\library\SoftTimerTask.h + + + $PROJ_DIR$\usr\common\systemInit.h + + + $PROJ_DIR$\usr\common\taskManager.h + + + + src + + $PROJ_DIR$\usr\common\applicationTask.c + + + $PROJ_DIR$\usr\common\linslaveTask.c + + + $PROJ_DIR$\usr\common\linslaveTask_J2602.c + + + $PROJ_DIR$\usr\common\linslaveTask_Private.c + + + $PROJ_DIR$\usr\common\linsNodeCfgIdentify.c + + + $PROJ_DIR$\usr\common\linsNodeCfgIdentify_J2602.c + + + $PROJ_DIR$\usr\common\measureTask.c + + + $PROJ_DIR$\usr\common\motorControlTask.c + + + $PROJ_DIR$\usr\common\pdsTask.c + + + $PROJ_DIR$\usr\common\safetyMonitorTask.c + + + + + crc + + include + + $PROJ_DIR$\usr\common\crc32.h + + + + src + + $PROJ_DIR$\usr\common\crc32.c + + + + + drivers + + core + + inc + + $PROJ_DIR$\drivers\core\inc\flash_sfrs.h + + + $PROJ_DIR$\drivers\core\inc\systick_sfrs.h + + + $PROJ_DIR$\drivers\core\inc\verne.h + + + + src + + $PROJ_DIR$\drivers\core\src\cstartup_M.c + + + $PROJ_DIR$\drivers\core\src\low_level_init.c + + + + + hal + + inc + + $PROJ_DIR$\drivers\hal\inc\adc_device.h + + + $PROJ_DIR$\drivers\hal\inc\atomic.h + + + $PROJ_DIR$\drivers\hal\inc\clock_device.h + + + $PROJ_DIR$\drivers\hal\inc\errno.h + + + $PROJ_DIR$\drivers\hal\inc\flash_device.h + + + $PROJ_DIR$\drivers\hal\inc\gpio_device.h + + + $PROJ_DIR$\drivers\hal\inc\hwProtection.h + + + $PROJ_DIR$\drivers\hal\inc\lin_device.h + + + $PROJ_DIR$\drivers\hal\inc\lin_stack.h + + + $PROJ_DIR$\drivers\hal\inc\pmu_device.h + + + $PROJ_DIR$\drivers\hal\inc\pwm_aux_device.h + + + $PROJ_DIR$\drivers\hal\inc\pwm_device.h + + + $PROJ_DIR$\drivers\hal\inc\systick_device.h + + + $PROJ_DIR$\drivers\hal\inc\timer_device.h + + + $PROJ_DIR$\drivers\hal\inc\wdt_device.h + + + + src + + $PROJ_DIR$\drivers\hal\src\adc_device.c + + + $PROJ_DIR$\drivers\hal\src\clock_device.c + + + $PROJ_DIR$\drivers\hal\src\ctt_device.c + + + $PROJ_DIR$\drivers\hal\src\flash_device.c + + + $PROJ_DIR$\drivers\hal\src\gpio_device.c + + + $PROJ_DIR$\drivers\hal\src\gTimer_device.c + + + $PROJ_DIR$\drivers\hal\src\hwProtection.c + + + $PROJ_DIR$\drivers\hal\src\lin_device.c + + + $PROJ_DIR$\drivers\hal\src\pmu_device.c + + + $PROJ_DIR$\drivers\hal\src\pwm_aux_device.c + + + $PROJ_DIR$\drivers\hal\src\pwm_device.c + + + $PROJ_DIR$\drivers\hal\src\spi_device.c + + + $PROJ_DIR$\drivers\hal\src\systick_device.c + + + $PROJ_DIR$\drivers\hal\src\uart_device.c + + + $PROJ_DIR$\drivers\hal\src\wdt_device.c + + + + + hdf + + inc + + $PROJ_DIR$\drivers\hdf\sfrs\adc_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\bte_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\crc_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\crga_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\ctt_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\evthold_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\flash_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\gpio_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\gtimer_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\ioctrla_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\linm_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\lins_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\mathdiv_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\meta_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\pmua_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\pwm_aux_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\pwm_sfr.h + + + $PROJ_DIR$\drivers\hdf\realplum.h + + + $PROJ_DIR$\drivers\hdf\sfrs\realplum_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\realplumPro_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\sar_ctrl_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\sfrs.tmp + + + $PROJ_DIR$\drivers\hdf\sfrs\spi_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\sram_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\syscfg_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\sysctrla_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\timer0_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\timer1_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\timer2_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\trimhv_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\uart0_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\wdt1_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\wdta_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\wica_sfr.h + + + + + hwcfg + + inc + + $PROJ_DIR$\drivers\hwcfg\inc\hwcfg.h + + + + src + + $PROJ_DIR$\drivers\hwcfg\src\hwcfg.c + + + + + + library + + $PROJ_DIR$\usr\library\LinStackTask_metaLite.a + + + $PROJ_DIR$\usr\library\SoftTimerTask_metaLite.a + + + + tasks + + $PROJ_DIR$\usr\common\systemInit.c + + + $PROJ_DIR$\usr\common\taskManager.c + + + + $PROJ_DIR$\usr\main.c + + diff --git a/87400/application_based_on_bootloader.ewt b/87400/application_based_on_bootloader.ewt new file mode 100644 index 0000000..fb3dacf --- /dev/null +++ b/87400/application_based_on_bootloader.ewt @@ -0,0 +1,1575 @@ + + + 3 + + Release + + ARM + + 0 + + C-STAT + 261 + + 261 + + 0 + + 1 + 600 + 1 + 4 + 0 + 1 + 100 + + + 1.5.3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RuntimeChecking + 0 + + 2 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + applications + + config + + $PROJ_DIR$\usr\common\appConfig.h + + + + fcode + + $PROJ_DIR$\usr\fcode\hwCtrl.c + + + $PROJ_DIR$\usr\fcode\hwCtrl.h + + + $PROJ_DIR$\usr\fcode\PINdef.h + + + $PROJ_DIR$\usr\fcode\prjconfig.h + + + + includes + + $PROJ_DIR$\usr\common\applicationTask.h + + + $PROJ_DIR$\usr\common\colorCompensationTask.h + + + $PROJ_DIR$\Function_Blocks\ColorMixingTask\colorFormula.h + + + $PROJ_DIR$\usr\library\colorMixingTask.h + + + $PROJ_DIR$\usr\common\linMasterTask.h + + + $PROJ_DIR$\usr\common\linslaveTask.h + + + $PROJ_DIR$\usr\common\linsNodeCfgIdentify.h + + + $PROJ_DIR$\usr\library\linStackTask.h + + + $PROJ_DIR$\usr\common\measureTask.h + + + $PROJ_DIR$\usr\common\pdsTask.h + + + $PROJ_DIR$\usr\common\safetyMonitorTask.h + + + $PROJ_DIR$\usr\library\SoftTimerTask.h + + + $PROJ_DIR$\usr\common\systemInit.h + + + $PROJ_DIR$\usr\common\taskManager.h + + + + src + + $PROJ_DIR$\usr\common\applicationTask.c + + + $PROJ_DIR$\usr\common\linslaveTask.c + + + $PROJ_DIR$\usr\common\linslaveTask_J2602.c + + + $PROJ_DIR$\usr\common\linslaveTask_Private.c + + + $PROJ_DIR$\usr\common\linsNodeCfgIdentify.c + + + $PROJ_DIR$\usr\common\linsNodeCfgIdentify_J2602.c + + + $PROJ_DIR$\usr\common\measureTask.c + + + $PROJ_DIR$\usr\common\motorControlTask.c + + + $PROJ_DIR$\usr\common\pdsTask.c + + + $PROJ_DIR$\usr\common\safetyMonitorTask.c + + + + + crc + + include + + $PROJ_DIR$\usr\common\crc32.h + + + + src + + $PROJ_DIR$\usr\common\crc32.c + + + + + drivers + + core + + inc + + $PROJ_DIR$\drivers\core\inc\flash_sfrs.h + + + $PROJ_DIR$\drivers\core\inc\systick_sfrs.h + + + $PROJ_DIR$\drivers\core\inc\verne.h + + + + src + + $PROJ_DIR$\drivers\core\src\cstartup_M.c + + + $PROJ_DIR$\drivers\core\src\low_level_init.c + + + + + hal + + inc + + $PROJ_DIR$\drivers\hal\inc\adc_device.h + + + $PROJ_DIR$\drivers\hal\inc\atomic.h + + + $PROJ_DIR$\drivers\hal\inc\clock_device.h + + + $PROJ_DIR$\drivers\hal\inc\errno.h + + + $PROJ_DIR$\drivers\hal\inc\flash_device.h + + + $PROJ_DIR$\drivers\hal\inc\gpio_device.h + + + $PROJ_DIR$\drivers\hal\inc\hwProtection.h + + + $PROJ_DIR$\drivers\hal\inc\lin_device.h + + + $PROJ_DIR$\drivers\hal\inc\lin_stack.h + + + $PROJ_DIR$\drivers\hal\inc\pmu_device.h + + + $PROJ_DIR$\drivers\hal\inc\pwm_aux_device.h + + + $PROJ_DIR$\drivers\hal\inc\pwm_device.h + + + $PROJ_DIR$\drivers\hal\inc\systick_device.h + + + $PROJ_DIR$\drivers\hal\inc\timer_device.h + + + $PROJ_DIR$\drivers\hal\inc\wdt_device.h + + + + src + + $PROJ_DIR$\drivers\hal\src\adc_device.c + + + $PROJ_DIR$\drivers\hal\src\clock_device.c + + + $PROJ_DIR$\drivers\hal\src\ctt_device.c + + + $PROJ_DIR$\drivers\hal\src\flash_device.c + + + $PROJ_DIR$\drivers\hal\src\gpio_device.c + + + $PROJ_DIR$\drivers\hal\src\gTimer_device.c + + + $PROJ_DIR$\drivers\hal\src\hwProtection.c + + + $PROJ_DIR$\drivers\hal\src\lin_device.c + + + $PROJ_DIR$\drivers\hal\src\pmu_device.c + + + $PROJ_DIR$\drivers\hal\src\pwm_aux_device.c + + + $PROJ_DIR$\drivers\hal\src\pwm_device.c + + + $PROJ_DIR$\drivers\hal\src\spi_device.c + + + $PROJ_DIR$\drivers\hal\src\systick_device.c + + + $PROJ_DIR$\drivers\hal\src\uart_device.c + + + $PROJ_DIR$\drivers\hal\src\wdt_device.c + + + + + hdf + + inc + + $PROJ_DIR$\drivers\hdf\sfrs\adc_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\bte_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\crc_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\crga_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\ctt_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\evthold_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\flash_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\gpio_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\gtimer_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\ioctrla_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\linm_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\lins_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\mathdiv_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\meta_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\pmua_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\pwm_aux_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\pwm_sfr.h + + + $PROJ_DIR$\drivers\hdf\realplum.h + + + $PROJ_DIR$\drivers\hdf\sfrs\realplum_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\realplumPro_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\sar_ctrl_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\sfrs.tmp + + + $PROJ_DIR$\drivers\hdf\sfrs\spi_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\sram_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\syscfg_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\sysctrla_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\timer0_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\timer1_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\timer2_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\trimhv_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\uart0_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\wdt1_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\wdta_sfr.h + + + $PROJ_DIR$\drivers\hdf\sfrs\wica_sfr.h + + + + + hwcfg + + inc + + $PROJ_DIR$\drivers\hwcfg\inc\hwcfg.h + + + + src + + $PROJ_DIR$\drivers\hwcfg\src\hwcfg.c + + + + + + library + + $PROJ_DIR$\usr\library\LinStackTask_metaLite.a + + + $PROJ_DIR$\usr\library\SoftTimerTask_metaLite.a + + + + tasks + + $PROJ_DIR$\usr\common\systemInit.c + + + $PROJ_DIR$\usr\common\taskManager.c + + + + $PROJ_DIR$\usr\main.c + + diff --git a/87400/drivers/core/inc/flash_sfrs.h b/87400/drivers/core/inc/flash_sfrs.h new file mode 100644 index 0000000..a6450e2 --- /dev/null +++ b/87400/drivers/core/inc/flash_sfrs.h @@ -0,0 +1,84 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file flash_sfrs.h + */ + +#ifndef FLASH_SFRS_H__ +#define FLASH_SFRS_H__ + +#include +#include +#include + +#define FLASH_WRITE_1_BYTE 0x01// +#define FLASH_WRITE_2_BYTE 0x01// +#define FLASH_WRITE_4_BYTE_L 0x0F// +#define FLASH_WRITE_4_BYTE_M_ECC 0x1F0// +#define FLASH_WRITE_8_BYTE 0xFF// +#define FLASH_WRITE_9_BYTE 0x1FF// + +#define E_FLASH_ERASE_SECTOR 0// +#define E_FLASH_ERASE_CHIP 1// + +#define E_FLASH_UNLOCK_WRITE 0x55555555U +#define E_FLASH_UNLOCK_ERASE 0x66666666U +#define E_FLASH_ERASE_START 0x99999999U +#define E_FLASH_WRITE_START 0xAAAAAAAAU +#define E_FLASH_UNLOCK_CTRL 0xACDC1972U + +#define NVR_FLASH_WRITE_START 0x502901FFU +#define NVR_FLASH_ERASE_START 0x502901FFU + +#define E_FLASH_CODE_PROTECT 0xF2E11047U +#define E_FLASH_WRITE_PROTECT 0x12100511U + + +/** +* @brief Flash memory erase sector function. +* +* @param address inside the sector to be erased. +*/ +static __INLINE void f_FLASH_EraseSector(__IO uint32_t address) +{ + /* load address */ + FLASH_SFRS->FLADDR.FLASHADDR = (uint32_t)(address>>3U); + FLASH_SFRS->UNLOCK_CTRL_OP = E_FLASH_UNLOCK_CTRL; + FLASH_SFRS->CTRL_OPR.CHIPSEL = E_FLASH_ERASE_SECTOR; + FLASH_SFRS-> UNLOCK_ERASE = E_FLASH_UNLOCK_ERASE; + FLASH_SFRS-> ERASE_START = E_FLASH_ERASE_START; + while(FLASH_SFRS->OPBSY != 0U); + + FLASH_SFRS->UNLOCK_CTRL_OP = 0; +} + +/** +* @brief Flash memory write word function. +* +* @param address and data (byte) to be programmed into flash. +* @param data and data (byte) to be programmed into flash. +*/ +static __INLINE void f_FLASH_Write2WordsWithECC(__IO uint32_t address, uint32_t dataL,uint32_t dataH) +{ + FLASH_SFRS->UNLOCK_CTRL_OP = E_FLASH_UNLOCK_CTRL; + FLASH_SFRS->CTRL_OPR.BYTESEL = FLASH_WRITE_9_BYTE; + + FLASH_SFRS->FLADDR.FLASHADDR = (uint32_t)(address >> 3); + FLASH_SFRS->DATAL = dataL; + FLASH_SFRS->DATAM = dataH; + + FLASH_SFRS->UNLOCK_WRITE = E_FLASH_UNLOCK_WRITE; + FLASH_SFRS->FLADDR.NVR = 0; + FLASH_SFRS->WRITE_START = E_FLASH_WRITE_START; + while(FLASH_SFRS->OPBSY != 0); + + FLASH_SFRS->UNLOCK_CTRL_OP = 0; +} + + +#endif /* __FLASH_SFRS_H__ */ \ No newline at end of file diff --git a/87400/drivers/core/inc/systick_sfrs.h b/87400/drivers/core/inc/systick_sfrs.h new file mode 100644 index 0000000..350f47f --- /dev/null +++ b/87400/drivers/core/inc/systick_sfrs.h @@ -0,0 +1,99 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file systick_sfrs.h + */ + +#ifndef SYSTICK_SFRS_H__ +#define SYSTICK_SFRS_H__ + +#include +#include +/** + * @brief Enable SysTick timer. + */ +static __INLINE void f_SYSTICK_Enable(void) +{ + SysTick->CTRL |= (SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_CLKSOURCE_Msk); +} + +/** + * @brief Disable SysTick timer. + */ +static __INLINE void f_SYSTICK_Disable(void) +{ + SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; +} + +/** + * @brief Check if SysTick timer enable. + * + * @return 0 if disable. + */ +static __INLINE uint8_t f_SYSTICK_IsEnabled(void) +{ + + return (uint8_t)(SysTick->CTRL & SysTick_CTRL_ENABLE_Msk); +} + +/** + * @brief Enable SysTick timer interrupt. + */ +static __INLINE void f_SYSTICK_IntEnable(void) +{ + SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk; +} + +/** + * @brief Disable SysTick timer interrupt. + */ +static __INLINE void f_SYSTICK_IntDisable(void) +{ + SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; +} + +/** + * @brief Set Reload value of SysTick timer. + * + * @param ticks The tick number to be set. + */ +static __INLINE void f_SYSTICK_SetLoad(uint32_t ticks) +{ + SysTick->LOAD = ticks; +} + +/** + * @brief Set counter value of SysTick timer. + * + * @param ticks The tick number to be set. + */ +static __INLINE void f_SYSTICK_SetCount(uint32_t ticks) +{ + SysTick->VAL = ticks; +} + +/** + * @brief Get counter value of SysTick timer. + * + * @return The current counter of Systick timer. + */ +static __INLINE uint32_t f_SYSTICK_GetCount(void) +{ + return SysTick->VAL; +} + +/** + * @brief Get load value of SysTick timer. + * + * @return The load setting of Systick timer. + */ +static __INLINE uint32_t f_SYSTICK_GetLoad(void) +{ + return SysTick->LOAD; +} +#endif /* __SYSTICK_SFRS_H__ */ diff --git a/87400/drivers/core/inc/verne.h b/87400/drivers/core/inc/verne.h new file mode 100644 index 0000000..ef37a58 --- /dev/null +++ b/87400/drivers/core/inc/verne.h @@ -0,0 +1,64 @@ +#ifndef FlashChipVerneBased_H +#define FlashChipVerneBased_H + +/********************************************************************************************************************/ +/* Number of IRQ priority level bits - must be defined before loading core_cm0.h*/ +/********************************************************************************************************************/ + +/* #define __NVIC_PRIO_BITS 2 */ + +/********************************************************************************************************************/ +/*Includes*/ +/********************************************************************************************************************/ +#include "core_cm0.h" +#include + +/* + end of define :obsoleted in future +*/ +/*Definition of the several memory segments defined in Heimdall Slave +Warning: DO NOT CHANGE definitions without careful consideration and +if at all possible contact Aydeekay LLC!*/ + +/*Flash Memory, addresses, sizes and blocks information*/ + + +#define FLASH_INITIAL_ADDRESS 0x0L +#define FLASH_FINAL_ADDRESS 0xBFFFU +#define FLASH_SIZE ( ( FLASH_FINAL_ADDRESS - FLASH_INITIAL_ADDRESS ) + 1 ) +#define FLASH_SECTOR_SIZE 0x200U +#define FLASH_SECTOR_SIZE_POS (9U) +#define NUMBER_FLASH_SECTORS (FLASH_SIZE/FLASH_SECTOR_SIZE) + + +/*SRAM Memory*/ +#define SRAM_INITIAL_ADDRESS 0x20000000U +#define SRAM_FINAL_ADDRESS 0x20003FFFU +#define SRAM_SIZE ( ( SRAM_FINAL_ADDRESS - SRAM_INITIAL_ADDRESS ) + 1 ) + +/************** ARM INTERNAL Registers *****************/ +/*WARNING: DO NOT TOUCH!*/ +/*******************************************************/ + + +/* +- 7K -bootlaoder +- 36K -app +- 4K -user param +- 1K -system param +*/ +#define FLASH_STRAT_ADDRESS_BOOTLOADER (0x0000U) +#define FLASH_START_ADDRESS_APPLICATION (0x1C08U) /* 7K */ +#define FLASH_START_ADDRESS_USER_DATA (0xAC00U) /* 7K + 36K*/ +#define FLASH_START_ADDRESS_SYSTEM_DATA (0xBC00U) /* 7K + 36K + +4K + 0.5K*/ +#define FLASH_START_ADDRESS_SYSTEM_DATA_BACK_UP (0xBE00U) /* 7K + 36K + +4K + 1.0K*/ +#define FLASH_END (0xBFFFU) +#define IMAGE_MAX_SIZE (FLASH_START_ADDRESS_USER_DATA - FLASH_START_ADDRESS_APPLICATION) + +#define ISR_PRIORITY_LOW (3) +#define ISR_PRIORITY_MEDIUM (2) +#define ISR_PRIORITY_HIGH (1) +#define ISR_PRIORITY_SUPER_HIGH (0) + + +#endif diff --git a/87400/drivers/core/src/cstartup_M.c b/87400/drivers/core/src/cstartup_M.c new file mode 100644 index 0000000..de0fbc3 --- /dev/null +++ b/87400/drivers/core/src/cstartup_M.c @@ -0,0 +1,220 @@ +/************************************************** + * + * This file contains an interrupt vector + * KamCho. (Cortex-M written in C) + * The actual interrupt functions must be provided + * by the application developer. + * + * Copyright 2007 IAR Systems. All rights reserved. + * + * $Revision: 3998 $ + * + **************************************************/ + +#pragma language=extended +#pragma segment="CSTACK" + +#include + +typedef void( *intfunc_t )( void ); +/* +__weak void NMI_Handler(void){asm("nop");} +__weak void HardFault_Handler(void){while(1);} +__weak void MemManage_Handler(void){while(1);} +__weak void BusFault_Handler(void){while(1);} +__weak void UsageFault_Handler(void){while(1);} + +__weak void SVC_Handler(void){while(1);} +__weak void DebugMon_Handler(void){while(1);} +__weak void PendSV_Handler(void){while(1);} + +__weak void SysTick_Handler(void){while(1);} + +__weak void IOCTRLA_Handler(void){while(1);} +__weak void OVTEMP_Handler(void){while(1);} +__weak void GPIO_Handler(void){while(1);} + +__weak void PWM_AUX_Handler(void){while(1);} +__weak void GT4_5_Handler(void){while(1);} + +__weak void WUTIMER_Handler(void){while(1);} +__weak void WatchdogA_Handler(void){while(1);} +__weak void ADC_Handler(void){while(1);} +__weak void SPI_Handler(void){while(1);} +__weak void WULINS_Handler(void){while(1);} + +__weak void UART0_Handler(void){while(1);} +__weak void Divider_Handler(void){while(1);} +__weak void LIN_Handler(void){while(1);} +__weak void FlashEcc_Handler(void){while(1);} +__weak void RamEcc_Handler(void){while(1);} + +__weak void GT1_Handler(void){while(1);} +__weak void GT2_Handler(void){while(1);} +__weak void GT3_Handler(void){while(1);} +__weak void CT2_Handler(void){while(1);} +__weak void CT3_Handler(void){while(1);} + +__weak void CT4_Handler(void){while(1);} +__weak void CT5_Handler(void){while(1);} +__weak void CT6_Handler(void){while(1);} +__weak void CR_Handler(void){while(1);} +__weak void PWM_INTOL0_Handler(void){while(1);} + +__weak void PWM_INTOL1_Handler(void){while(1);} +__weak void PWM_INTOL2_Handler(void){while(1);} +__weak void PWM_INTOL3_Handler(void){while(1);} +__weak void BOR_Handler(void){while(1);} +__weak void UV_OV_Handler(void){while(1);} + +__weak void CSA_OCP_Handler(void){while(1);} +__weak void Lullaby_Handler(void){while(1);} + +__weak void error(void){while(1);} + +*/ + +void __iar_program_start( void ); + +typedef struct{ + void * __ptr; + intfunc_t _iar_program_start; + intfunc_t _NMI_Handler; + intfunc_t _HardFault_Handler; + intfunc_t _MemManage_Handler; + intfunc_t _BusFault_Handler; + intfunc_t _UsageFault_Handler; + intfunc_t _rsv0; + intfunc_t _rsv1; + intfunc_t _rsv2; + intfunc_t _rsv3; + intfunc_t _SVC_Handler; + intfunc_t _DebugMon_Handler; + intfunc_t _rsv4; + intfunc_t _PendSV_Handler; + intfunc_t _SysTick_Handler; + + intfunc_t _IOCTRLA_Handler; /* ASIC irq 0 - - IOCTRLA TXD Dominate */ + intfunc_t _OVTEMP_Handler; /* ASIC irq 1 - OVTEMP*/ + intfunc_t _GPIO_Handler; /* ASIC irq 2 - GPIO */ + intfunc_t _PWM_AUX_Handler; /* ASIC irq 3 - PWM_AUX */ + intfunc_t _GT4_5_Handler; /* ASIC irq 4 - GT4_5 */ + + intfunc_t _WUTIMER_Handler; /* ASIC irq 5 - Wake Up TIMER */ + intfunc_t _WatchdogA_Handler; /* ASIC irq 6 - Watchdog Timer*/ + intfunc_t _ADC_Handler; /* ASIC irq 7 - ADC data ready*/ + intfunc_t _SPI_Handler; /* ASIC irq 8 - SPI */ + intfunc_t _WULINS_Handler; /* ASIC irq 9 - WULIN */ + + intfunc_t _UART0_Handler; /* ASIC irq 10 - UART0*/ + intfunc_t _Divider_Handler; /* ASIC irq 11 - DIVIDER */ + intfunc_t _LIN_Handler; /* ASIC irq 12 - Lin */ + intfunc_t _FlashEcc_Handler; /* ASIC irq 13 - FLASH ECC and protect interrupt */ + intfunc_t _RamEcc_Handler; /* ASIC irq 14 - SRAM ECC interrupt */ + + intfunc_t _GT1_Handler; /* ASIC irq 15 - GT1 */ + intfunc_t _GT2_Handler; /* vern irq 16 - GT2*/ + intfunc_t _GT3_Handler; /* vern irq 17 - GT3*/ + intfunc_t _CT2_Handler; /* vern irq 18 - CT2*/ + intfunc_t _CT3_Handler; /* vern irq 19 - CT3*/ + + intfunc_t _CT4_Handler; /* vern irq 20 - CT4*/ + intfunc_t _CT5_Handler; /* vern irq 21 - CT5*/ + intfunc_t _CT6_Handler; /* vern irq 22 - CT6*/ + intfunc_t _CR_Handler; /* vern irq 23 - crirq interrupt*/ + intfunc_t _PWM_INTOL0_Handler; /* vern irq 24 - pwm 0 interrupt*/ + + intfunc_t _PWM_INTOL1_Handler; /* vern irq 25 - pwm 1 interrupt*/ + intfunc_t _PWM_INTOL2_Handler; /* vern irq 26 - pwm 2 interrupt*/ + intfunc_t _PWM_INTOL3_Handler; /* vern irq 27 - pwm 3 interrupt*/ + intfunc_t _BOR_Handler; /* vern irq 28 - BOR*/ + intfunc_t _UV_OV_Handler; /* vern irq 29 - Under Voltage Event*/ + + intfunc_t _CSA_OCP_Handler; /* vern irq 30 - CSA_OCP Event*/ + intfunc_t Lullaby_Handler; /* vern irq 31 - Software interrupt which will mask all the other interrupts*/ +}intvecTable_t; + +/* + The vector table is normally located at address 0. + When debugging in RAM, it can be located in RAM, aligned to at least 2^6. + If you need to define interrupt service routines, + make a copy of this file and include it in your project. + The name "__vector_table" has special meaning for C-SPY: + it is where the SP start value is found, and the NVIC vector + table register (VTOR) is initialized to this address if != 0. +*/ + +#pragma location = ".intvec" +static const intvecTable_t __vector_table = +{ + .__ptr = __sfe( "CSTACK" ), + ._iar_program_start = __iar_program_start, + ._NMI_Handler = NMI_Handler, + ._HardFault_Handler = HardFault_Handler, + ._MemManage_Handler = MemManage_Handler, + ._BusFault_Handler = BusFault_Handler, + ._UsageFault_Handler = UsageFault_Handler, + ._rsv0 = 0U, + ._rsv1 = 0U, + ._rsv2 = 0U, + ._rsv3 = 0U, + ._SVC_Handler = SVC_Handler, + ._DebugMon_Handler = error, + ._rsv4 = 0U, + ._PendSV_Handler = PendSV_Handler, + ._SysTick_Handler = SysTick_Handler, + + ._IOCTRLA_Handler = IOCTRLA_Handler, /* ASIC irq 0 - - IOCTRLA TXD Dominate */ + ._OVTEMP_Handler = OVTEMP_Handler, /* ASIC irq 1 - OVTEMP*/ + ._GPIO_Handler = GPIO_Handler, /* ASIC irq 2 - GPIO */ + ._PWM_AUX_Handler = PWM_AUX_Handler, /* ASIC irq 3 - PWM_AUX */ + ._GT4_5_Handler = GT4_5_Handler, /* ASIC irq 4 - GT4_5*/ + + ._WUTIMER_Handler = WUTIMER_Handler, /* ASIC irq 5 - Wake Up TIMER */ + ._WatchdogA_Handler = WatchdogA_Handler, /* ASIC irq 6 - Watchdog Timer*/ + ._ADC_Handler = ADC_Handler, /* ASIC irq 7 - ADC data ready*/ + ._SPI_Handler = SPI_Handler, /* ASIC irq 8 - SPI */ + ._WULINS_Handler = WULINS_Handler, /* ASIC irq 9 - WULIN */ + + ._UART0_Handler = UART0_Handler, /* ASIC irq 10 - UART0*/ + ._Divider_Handler = Divider_Handler, /* ASIC irq 11 - DIVIDER */ + ._LIN_Handler = LIN_Handler, /* ASIC irq 12 - Lin */ + ._FlashEcc_Handler = FlashEcc_Handler, /* ASIC irq 13 - FLASH ECC and protect interrupt */ + ._RamEcc_Handler = RamEcc_Handler, /* ASIC irq 14 - SRAM ECC interrupt */ + + ._GT1_Handler = GT1_Handler, /* ASIC irq 15 - GT1 */ + ._GT2_Handler = GT2_Handler, /* vern irq 16 - GT2*/ + ._GT3_Handler = GT3_Handler, /* vern irq 17 - GT3*/ + + ._CT2_Handler = CT2_Handler, /* vern irq 18 - CT2*/ + ._CT3_Handler = CT3_Handler, /* vern irq 19 - CT3*/ + + ._CT4_Handler = CT4_Handler, /* vern irq 20 - CT4*/ + ._CT5_Handler = CT5_Handler, /* vern irq 21 - CT5*/ + ._CT6_Handler = CT6_Handler, /* vern irq 22 - CT6*/ + ._CR_Handler = CR_Handler, /* vern irq 23 - crirq interrupt*/ + ._PWM_INTOL0_Handler = PWM_INTOL0_Handler, /* vern irq 24 - pwm intol0 interrupt*/ + + ._PWM_INTOL1_Handler = PWM_INTOL1_Handler, /* vern irq 25 - pwm intol1 interrupt*/ + ._PWM_INTOL2_Handler = PWM_INTOL2_Handler, /* vern irq 26 - pwm intol2 interrupt*/ + ._PWM_INTOL3_Handler = PWM_INTOL3_Handler, /* vern irq 27 - pwm intol3 interrupt*/ + ._BOR_Handler = BOR_Handler, /* vern irq 28 - BOR*/ + ._UV_OV_Handler = UV_OV_Handler, /* vern irq 29 - Under Voltage Event*/ + + ._CSA_OCP_Handler = CSA_OCP_Handler, /* vern irq 30 - CSA_OCP Event*/ + .Lullaby_Handler = Lullaby_Handler, /* vern irq 31 - Software interrupt which will mask all the other interrupts*/ +}; + + +void __cmain( void ); + +__weak void __iar_init_core( void ); +__weak void __iar_init_vfp( void ); + +#pragma required=__vector_table +void __iar_program_start( void ) +{ + __iar_init_core(); + __iar_init_vfp(); + __cmain(); +} diff --git a/87400/drivers/core/src/low_level_init.c b/87400/drivers/core/src/low_level_init.c new file mode 100644 index 0000000..4bf5196 --- /dev/null +++ b/87400/drivers/core/src/low_level_init.c @@ -0,0 +1,75 @@ +/************************************************** + * + * This module contains the function `__low_level_init', a function + * that is called before the `main' function of the program. Normally + * low-level initializations - such as setting the prefered interrupt + * level or setting the watchdog - can be performed here. + * + * Note that this function is called before the data segments are + * initialized, this means that this function cannot rely on the + * values of global or static variables. + * + * When this function returns zero, the startup code will inhibit the + * initialization of the data segments. The result is faster startup, + * the drawback is that neither global nor static data will be + * initialized. + * + * Copyright 1999-2004 IAR Systems. All rights reserved. + * + * $Revision: 2474 $ + * + **************************************************/ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#pragma language=extended + +__interwork int __low_level_init(void); + +__interwork int __low_level_init(void) +{ + /*==================================*/ + /* Initialize hardware. */ + /*==================================*/ + FLASH_SFRS->CTRL_OPR.FRWS = 2; + /* + Indie's Flash Initialization + For the Cortex M0 core (CM0160K8) + 0 Read/Write Wait-State Clock Cycles [2:0] + 0 Write/Erase Clock Divider [5:3] + */ + /* Initial system clock to RC to allow faster boot up */ + CRGA_SFRS->SYSCLKCTRL.HFRCENA = 1U; + while(CRGA_SFRS->SYSCLKCTRL.HFRCSTS == 0U){} + CRGA_SFRS->SYSCLKCTRL.SYSCLKSEL = 1U; + uint16_t rev = SYSCTRLA_SFRS->REV; + uint32_t name = SYSCTRLA_SFRS->NAME; + if (name != 0x4D54414CU || (rev >> 8) != 0x41U){ /* 0x41='A', 0x42='B' */ + /* invalid chip id*/ + for(;;){} + } + + EVTHOLD_SFRS->HOLD = 0U; + TRIMHV_SFRS->RETAIN.RETAIN0 = 0x01U; /* figure out it's application mode */ + /* Stop watchdog on ASIC */ + WDTA_SFRS->STOPR.STOP = 0xC3U; + /*==================================*/ + /* Choose if segment initialization */ + /* should be done or not. */ + /* Return: 0 to omit seg_init */ + /* 1 to run seg_init */ + /*==================================*/ + + return 1; +} + +#pragma language=default + +#ifdef __cplusplus +} +#endif diff --git a/87400/drivers/hal/inc/adc_device.h b/87400/drivers/hal/inc/adc_device.h new file mode 100644 index 0000000..3c86347 --- /dev/null +++ b/87400/drivers/hal/inc/adc_device.h @@ -0,0 +1,155 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file adc_device.h + */ + +#ifndef ADC_DEVICE_H__ +#define ADC_DEVICE_H__ + +#include +#include +#include +#include +#include +#include + +typedef enum { + ADC_REF_VBG = 0U, /* VBG = 1.22V */ + ADC_REF_VBG_2TIMES, /* 2* VBG */ + ADC_REF_VDD_3V3, +}AdcReference_t; + +typedef enum { + ADC_TRIGGER_SEL_GENERAL_TRIGSRC = 0x00U, + ADC_TRIGGER_SEL_PWM_AUX_TRIGSRC, +}AdcTriggerSEL_t; + +typedef enum { + ADC_PWMAUX_CHN0 = 0x00U, + ADC_PWMAUX_CHN1, + ADC_PWMAUX_CHN2, + ADC_PWMAUX_CHN3, + ADC_PWMAUX_CHN4, + ADC_PWMAUX_CHN5, +}AdcPwmAuxChannel_t; + +typedef enum { + ADC_PWMAUX_TRIG_SRC_PWM_RISING = 0x01U, + ADC_PWMAUX_TRIG_SRC_PWM_FALLING = 0x02U, + ADC_PWMAUX_TRIG_SRC_PWM_PERIOD0 = 0x04U, + ADC_PWMAUX_TRIG_SRC_PWM_PERIOD1 = 0x08U, +}AdcPwmAuxTriggerSRC_t; + +typedef enum { + ADC_TRIG_SRC_SOFT_INPUT = 0x00U, + ADC_TRIG_SRC_PWM_CMP0 = 0x08U, + ADC_TRIG_SRC_PWM_CMP1 = 0x09U, + ADC_TRIG_SRC_PWM_PCC3_1 = 0x0AU, + ADC_TRIG_SRC_PWM_CT6OUT = 0x0BU, + ADC_TRIG_SRC_PWM_CT3OUT = 0x0CU, + ADC_TRIG_SRC_GT1ADCTRIG = 0x0DU, + ADC_TRIG_SRC_GT2ADCTRIG = 0x0EU, + ADC_TRIG_SRC_GT3ADCTRIG = 0x0FU +}AdcGeneralTriggerSRC_t; + + +typedef enum { + ADC_AFE_GAIN_22_OF_32 = 0U, + ADC_AFE_GAIN_31_OF_32, +}AdcAfeGain_t; + +typedef enum { + ADC_AFE_INPUT_ALL_EXT = 0U, + ADC_AFE_INPUT_INP_BUFFERED_INN_EXT, + ADC_AFE_INPUT_INP_EXT_INN_BUFFERED, + ADC_AFE_INPUT_INP_BUFFERED_INN_BUFFERED, +}AdcAfeInputMode_t; + +typedef enum { + ADC_CH_SEL_NONE = 0U, + ADC_CH_SEL_REF_REF, + ADC_CH_SEL_REF_GND, + ADC_CH_SEL_GND_REF, + ADC_CH_SEL_TSENSOR_GND, + ADC_CH_SEL_1V5_GND, + ADC_CH_SEL_3V3_GND, /* 1/2 gain */ + ADC_CH_SEL_5V0_GND, /* 1/4 gain */ + ADC_CH_SEL_VBAT_GND, /* 1/14 gain */ + ADC_CH_SEL_CSA_Filter_OUT_GND, + ADC_CH_SEL_CSA_OUT_GND, + ADC_CH_SEL_PA2_GND, + ADC_CH_SEL_PA3_GND, + ADC_CH_SEL_PA4_GND, + ADC_CH_SEL_PA5_GND, + ADC_CH_SEL_PA6_GND, + ADC_CH_SEL_PC3_GND, + ADC_CH_SEL_PC4_GND, + ADC_CH_SEL_PB0_GND, + ADC_CH_SEL_PB1_GND, + ADC_CH_SEL_PB2_GND, + ADC_CH_SEL_PB3_GND, + ADC_CH_SEL_PB4_GND, + ADC_CH_SEL_PB5_GND, + ADC_CH_SEL_PB6_GND, + ADC_CH_SEL_PB7_GND, + ADC_CH_SEL_3V3_EXT_GND, /* 1/2 gain */ +}AdcChannelSelect_t; + + +typedef enum { + ADC_SQ_CH1_2_CH1 = 1U, + ADC_SQ_CH1_2_CH2 = 2U, + ADC_SQ_CH1_2_CH3 = 3U, + ADC_SQ_CH1_2_CH4 = 4U, + ADC_SQ_CH1_2_CH5 = 5U, + ADC_SQ_CH1_2_CH6 = 6U, + ADC_SQ_CH1_2_CH7 = 7U, + ADC_SQ_CH1_2_CH8 = 8U, + ADC_SQ_CH1_2_CH9 = 9U, + ADC_SQ_CH1_2_CH10= 10U +}AdcSequence_t; + + +typedef enum { + ADC_MEASURE_ITEM_NONE = 0U, + ADC_MEASURE_ITEM_VBG, + ADC_MEASURE_ITEM_VBAT, + ADC_MEASURE_ITEM_VDD1V5, + ADC_MEASURE_ITEM_PC3, + ADC_MEASURE_ITEM_VBAT_VTEMP, + ADC_MEASURE_ITEM_LED, +}AdcMeasureItem_t; + +typedef struct{ + AdcMeasureItem_t item; + uint8_t channel; +}ADCMeasureParam_t; + + +typedef struct{ + AdcTriggerSEL_t selection; + union{ + AdcGeneralTriggerSRC_t general; + AdcPwmAuxTriggerSRC_t pwmAux; + }; + AdcPwmAuxChannel_t channel; /* Only for pwm aux */ +}ADCTriggerParam_t; + + +typedef void (*adc_cb_func_t)(ADCMeasureParam_t item, uint16_t *const result); + +void ADC_GeneralInit(void); +void ADC_Init(AdcMeasureItem_t item, uint8_t channel); +void ADC_UnInit(AdcMeasureItem_t item); +void ADC_RegisterIRQ(adc_cb_func_t callback); +void ADC_UnregisterIRQ(void); +void ADC_Start(void); + + +#endif /* __ADC_DEVICE_H__ */ \ No newline at end of file diff --git a/87400/drivers/hal/inc/atomic.h b/87400/drivers/hal/inc/atomic.h new file mode 100644 index 0000000..003c0ce --- /dev/null +++ b/87400/drivers/hal/inc/atomic.h @@ -0,0 +1,21 @@ +#ifndef _ATOMIC_H +#define _ATOMIC_H + +#include + +typedef uint32_t atomic_t; +/****************************************************************************** + Disables global interrupt. Enter atomic section. +******************************************************************************/ +void halStartAtomic(atomic_t volatile *pAtomic); +/****************************************************************************** + Exit atomic section +******************************************************************************/ +void halEndAtomic(atomic_t volatile *pAtomic); +/** \brief Marks the begin of atomic section */ +#define __atomic_enter() __disable_irq(); +/** \brief Marks the end of atomic section */ +#define __atomic_exit() __enable_irq(); + +#endif + diff --git a/87400/drivers/hal/inc/clock_device.h b/87400/drivers/hal/inc/clock_device.h new file mode 100644 index 0000000..7e443ca --- /dev/null +++ b/87400/drivers/hal/inc/clock_device.h @@ -0,0 +1,37 @@ +/** + * @copyright 2016 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file clock_device.h + */ + +#ifndef CLOCK_DEVICE_H__ +#define CLOCK_DEVICE_H__ + +#include +#include +#include + +typedef enum{ + CLOCK_RC_16KHz = 0U, + CLOCK_RC_16MHz +}ClockSource_t; + + +#define CLOCK_LF_RC_16KHz (0U) +#define CLOCK_LF_RC_256KHz (1U) + +#define CLOCK_DIV_1 (0U) +#define CLOCK_DIV_2 (1U) +#define CLOCK_DIV_4 (3U) + +#define CLOCK_DIV_8 (7U) + +void Clock_SystemMainClockInit(uint8_t divider); +uint32_t Clock_GetSystemClock(void); + +#endif /* __CLOCK_DEVICE_H__ */ diff --git a/87400/drivers/hal/inc/ctt_device.h b/87400/drivers/hal/inc/ctt_device.h new file mode 100644 index 0000000..ef3d96b --- /dev/null +++ b/87400/drivers/hal/inc/ctt_device.h @@ -0,0 +1,74 @@ +/** + * @copyright 2017 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file timer_device.h + */ + +#ifndef CTT_DEVICE_H__ +#define CTT_DEVICE_H__ + +#include +#include + +/* Timer 2 have been used by lin stack ,please don't use !!! */ +#define HW_CTT_TIMER_NUM 5U +#define HW_TIMER_RELOAD 49535U +typedef enum{ + CT2 = 0U, + CT3 = 1U, + CT4 = 2U, + CT5 = 3U, + CT6 = 4U, +}HwCTTId_t; + +typedef enum{ + CTT_CLK_DIV_1 = 0U, + CTT_CLK_DIV_2, + CTT_CLK_DIV_4, + CTT_CLK_DIV_8, + CTT_CLK_DIV_16, + CTT_CLK_DIV_32, + CTT_CLK_DIV_64, + CTT_CLK_DIV_128, + CTT_CLK_DIV_256, + CTT_CLK_DIV_512, + CTT_CLK_DIV_1024, + CTT_CLK_DIV_2048, + CTT_CLK_DIV_4096, +}CttTimer_Prescaler_t; + + +typedef enum{ + HW_TIMER_MODE = 0U, + HW_COUNT_MODE, + HW_GATED_TIMER_MODE_WITH_GATE_ACTIVE_LOW, + HW_GATED_TIMER_MODE_WITH_GATE_ACTIVE_HIGH, + HW_RELOAD_MODE, + HW_CAPTURE_MODE, + HW_INCREMENTAL_INTERFACE_MODE_ROTATION_DETECTION, + HW_INCREMENTAL_INTERFACE_MODE_EDGE_DETECTION, +} HwCttTimeMode_t; + +typedef void (*CttTimeoutCallbackFunc_t)(void); + +typedef struct{ + /* Timer parameters */ + uint32_t timeReloadCnt; + uint32_t periodCount; + HwCttTimeMode_t mode; + CttTimeoutCallbackFunc_t handler; +} HwCttTimer_t; + + +void CTT2_Init(HwCttTimeMode_t mode, CttTimer_Prescaler_t prescale, uint16_t timeoutTicks); +void CTT2_Time_Reload(uint16_t count); +void CTT_Disable(HwCTTId_t timerId); +//void Time_1ms_callback(void); +//void Time_SwitchPhase_callback(void); + +#endif /* __CTT_DEVICE_H__ */ \ No newline at end of file diff --git a/87400/drivers/hal/inc/errno.h b/87400/drivers/hal/inc/errno.h new file mode 100644 index 0000000..5b59ca2 --- /dev/null +++ b/87400/drivers/hal/inc/errno.h @@ -0,0 +1,21 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file errno.h + */ + +#ifndef ERRNO_H__ +#define ERRNO_H__ + +#define EPERM 1U /*!< Operation not permitted */ +#define EAGAIN 2U /*!< Try again */ +#define EFAULT 3U /*!< Bad address */ +#define EBUSY 4U /*!< Device or resource busy */ +#define ENODEV 5U /*!< No such device */ +#define ETIMEOUT 6U /*!< Time out */ +#endif \ No newline at end of file diff --git a/87400/drivers/hal/inc/flash_device.h b/87400/drivers/hal/inc/flash_device.h new file mode 100644 index 0000000..2f68061 --- /dev/null +++ b/87400/drivers/hal/inc/flash_device.h @@ -0,0 +1,34 @@ +/** + * @copyright 2017 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file flash_device.h + */ + +#ifndef FLASH_DEVICE_H__ +#define FLASH_DEVICE_H__ + +#include + +/** + * @brief Erase a sector flash memory and wait for completion + * + * @param addr: starting address of the block + * @return none + */ +void Flash_EraseSector(uint32_t sectorAddress); + +/** + * @brief write flash memory and wait for completion + * + * @param addr: starting address of the data + * @return none + */ +void FLASH_Write2WordsWithECC(uint32_t address,uint32_t dataL,uint32_t dataH); + + +#endif /* __FLASH_DEVICE_H__ */ \ No newline at end of file diff --git a/87400/drivers/hal/inc/gTimer_device.h b/87400/drivers/hal/inc/gTimer_device.h new file mode 100644 index 0000000..e32e1e9 --- /dev/null +++ b/87400/drivers/hal/inc/gTimer_device.h @@ -0,0 +1,61 @@ +/** + * @copyright 2017 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file timer_device.h + */ + +#ifndef TIMER_DEVICE_H__ +#define TIMER_DEVICE_H__ + +#include +#include + +/* Timer 2 have been used by lin stack ,please don't use !!! */ +#define HW_GP_TIMER_NUM 3U +typedef enum{ + TIMER1 = 0U, + TIMER2 = 1U, + TIMER3 = 2U, +}HwGpTimerId_t; + +typedef enum{ + GTIMER_CLK_DIV_1 = 0U, + GTIMER_CLK_DIV_2, + GTIMER_CLK_DIV_4, + GTIMER_CLK_DIV_8, + GTIMER_CLK_DIV_16, + GTIMER_CLK_DIV_32, + GTIMER_CLK_DIV_64, + GTIMER_CLK_DIV_256, + GTIMER_CLK_DIV_1024, + GTIMER_CLK_DIV_2048, + GTIMER_CLK_DIV_4096, +}GTimer_Prescaler_t; + + +typedef enum GlobalTimerMode_t{ + HW_TIMER_PERIODIC_MODE = 0U, + HW_TIMER_ONE_SHOT_MODE, +} HwGpTimeMode_t; + +typedef void (*TimeoutCallbackFunc_t)(void); + +typedef struct{ + /* Timer parameters */ + uint32_t timeReloadCnt; + uint32_t periodCount; + HwGpTimeMode_t mode; + TimeoutCallbackFunc_t handler; +} HwGpTimer_t; + + +void TIMER_Init(HwGpTimerId_t timerId, HwGpTimeMode_t mode, GTimer_Prescaler_t prescale, uint16_t timeoutTicks, TimeoutCallbackFunc_t callback); +void TIMER_Disable(HwGpTimerId_t timerId); + + +#endif /* __TIMER_DEVICE_H__ */ \ No newline at end of file diff --git a/87400/drivers/hal/inc/gpio_device.h b/87400/drivers/hal/inc/gpio_device.h new file mode 100644 index 0000000..075e973 --- /dev/null +++ b/87400/drivers/hal/inc/gpio_device.h @@ -0,0 +1,89 @@ +/** + * @copyright 2017 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file gpio_device.h + */ + +#ifndef GPIO_DEVICE_H__ +#define GPIO_DEVICE_H__ + +#include +#include +#include +#include +#include "errno.h" + +/* for IO control*/ +typedef enum{ + GPIO_PORT_0 = 0U, + GPIO_PORT_1, + GPIO_PORT_2, + GPIO_PORT_3, + GPIO_PORT_4, + GPIO_PORT_5, + GPIO_PORT_6, + GPIO_PORT_7, +}GpioPort_t; + +/* for IO init*/ +typedef enum{ + GROUP_GPIOA = 0, + GROUP_GPIOB, + GROUP_GPIOC, +}GpioGroup_t; + + +typedef enum{ + GPIO_DIR_INPUT = 0U, + GPIO_DIR_OUTPUT, +}GpioDir_t; + +/* 01: pull none, 00: pull up, 11: pull down, 10: pull up and down*/ +typedef enum{ + GPIO_PULL_UP = 0U, + GPIO_PULL_NONE = 1U, + GPIO_PULL_UP_DOWN = 2U, + GPIO_PULL_DOWN = 3U, +}GpioPullMode_t; + +typedef enum{ + GPIO_LOW = 0U, + GPIO_HIGH, +}GpioSetState_t; + +typedef enum{ + GPIO_MUX_GPIO = 0U, + GPIO_MUX_PWM, +}GpioMuxMode_t; + + +typedef enum{ + GPIO_PWM_CH1 = 0U, + GPIO_PWM_CH2, + GPIO_PWM_NONE, +}GpioPWMchannel_t; + +/* 00: disable, 01: rising, 10: falling, 11: both */ +typedef enum{ + GPIO_EDGE_NODE = 0U, + GPIO_EDGE_RISING, + GPIO_EDGE_FALLING, + GPIO_EDGE_BOTH, +}GpioISREdge_t; + + +typedef void (*gpio_cb_func_t)(void); + +void PWMAUX_GPIO_Init(GpioGroup_t group,GpioPort_t port); +void GPIO_Init(GpioGroup_t group,GpioPort_t port, GpioDir_t dir,GpioPullMode_t pullMode); +void GPIO_RegisterIRQ(GpioGroup_t group,GpioPort_t port, GpioISREdge_t edge, gpio_cb_func_t callback); +void GPIO_UnRegisterIRQ(GpioGroup_t group,GpioPort_t port); +void GPIO_Set(GpioGroup_t group,GpioPort_t port, GpioSetState_t state); +uint8_t GPIO_Read(GpioGroup_t group,GpioPort_t port); + +#endif /* __GPIO_DEVICE_H__ */ \ No newline at end of file diff --git a/87400/drivers/hal/inc/hwProtection.h b/87400/drivers/hal/inc/hwProtection.h new file mode 100644 index 0000000..1b37fa5 --- /dev/null +++ b/87400/drivers/hal/inc/hwProtection.h @@ -0,0 +1,150 @@ +#ifndef __HW_PROTECTION_H__ +#define __HW_PROTECTION_H__ +#include +#include + + +typedef enum{ + OVT_PROT_93C = 0, + OVT_PROT_98C, + OVT_PROT_104C, + OVT_PROT_109C, + OVT_PROT_115C, + OVT_PROT_121C, + OVT_PROT_127C, + OVT_PROT_133C, + OVT_PROT_139C, + OVT_PROT_146C, + OVT_PROT_153C, + OVT_PROT_160C, + OVT_PROT_168C, + OVT_PROT_176C, + OVT_PROT_185C, + OVT_PROT_195C +}OverTempThres_t; + +typedef enum{ + OVT_ACTION_HW_RESET = 0, + OVT_ACTION_IRQ, + OVT_ACTION_NONE +}OverTempAction_t; + +typedef enum{ + OV_VOLT_14_7V = 0U, + OV_VOLT_15_2V, + OV_VOLT_15_6V, + OV_VOLT_16_4V, + OV_VOLT_16_8V, + OV_VOLT_17_6V, + OV_VOLT_18_3V, + OV_VOLT_19_0V, + OV_VOLT_20_0V, + OV_VOLT_20_7V, +}OverVoltThres_t; + +typedef enum{ + OV_VOLT_HYS_360mV = 0U, + OV_VOLT_HYS_720mV, + OV_VOLT_HYS_1080mV, + OV_VOLT_HYS_1440mV, +}OverVoltHysteresis_t; + + +typedef enum{ + UV_VOLT_4_6V = 0x0, + UV_VOLT_4_7V, + UV_VOLT_5_1V, + UV_VOLT_5_2V, + UV_VOLT_5_061V, + UV_VOLT_5_140V, + UV_VOLT_5_221V, + UV_VOLT_5_305V, + UV_VOLT_5_392V, + UV_VOLT_5_482V, + UV_VOLT_5_574V, + UV_VOLT_5_670V, + UV_VOLT_5_770V, + UV_VOLT_5_872V, + UV_VOLT_5_979V, + UV_VOLT_6_089V, + UV_VOLT_6_204V, + UV_VOLT_6_323V, + UV_VOLT_6_447V, + UV_VOLT_6_575V, + UV_VOLT_6_709V, + UV_VOLT_6_849V, + UV_VOLT_6_994V, + UV_VOLT_7_146V, + UV_VOLT_7_304V, + UV_VOLT_7_470V, + UV_VOLT_7_643V, + UV_VOLT_7_825V, + UV_VOLT_8_015V, + UV_VOLT_8_215V, + UV_VOLT_8_425V, + UV_VOLT_8_646V, + UV_VOLT_8_879V, + UV_VOLT_9_125V, + UV_VOLT_9_385V, + UV_VOLT_9_660V, + UV_VOLT_9_952V, + UV_VOLT_10_26V, + UV_VOLT_10_59V, + UV_VOLT_10_94V, +}UnderVoltThres_t; + +typedef enum{ + UNDER_VOLT_HYS_470mV = 0U, + UNDER_VOLT_HYS_830mV, + UNDER_VOLT_HYS_1220mV, + UNDER_VOLT_HYS_1630mV, +}UnderVoltHysteresis_t; + + +typedef enum{ + VOLT_DEBOUNCE_TIME_0ms = 0U, + VOLT_DEBOUNCE_TIME_1ms = 16U, + VOLT_DEBOUNCE_TIME_2ms = 32U, + VOLT_DEBOUNCE_TIME_3ms = 48U, + VOLT_DEBOUNCE_TIME_4ms = 64U, + VOLT_DEBOUNCE_TIME_5ms = 80U, + VOLT_DEBOUNCE_TIME_6ms = 96U, + VOLT_DEBOUNCE_TIME_7ms = 112U, + VOLT_DEBOUNCE_TIME_8ms = 128U, + VOLT_DEBOUNCE_TIME_9ms = 144U, + VOLT_DEBOUNCE_TIME_10ms = 160U, + VOLT_DEBOUNCE_TIME_11ms = 176U, + VOLT_DEBOUNCE_TIME_12ms = 192U, + VOLT_DEBOUNCE_TIME_13ms = 208U, + VOLT_DEBOUNCE_TIME_14ms = 224U, + VOLT_DEBOUNCE_TIME_15ms = 240U, +}VoltDebouceTime_t; + + + + + +typedef void (*hwProtIsrCallback_t)(void); + + +void HW_PROT_SetOverTmperature(OverTempThres_t threshold, OverTempAction_t action); +void HW_PROT_RegisterOVTemperatureIRQ(hwProtIsrCallback_t callback); +void HW_PROT_UnRegisterOVTemperatureIRQ(void); + +void HW_PROT_SetOverVoltage(OverVoltThres_t threshold,OverVoltHysteresis_t hys, VoltDebouceTime_t triggerTime, VoltDebouceTime_t releaseTime); +void HW_PROT_RegisterOverVoltageIRQ(hwProtIsrCallback_t callback); +void HW_PROT_UnRegisterOverVoltageIRQ(void); + +void HW_PROT_SetUnderVoltage(UnderVoltThres_t threshold,UnderVoltHysteresis_t hys, VoltDebouceTime_t triggerTime, VoltDebouceTime_t releaseTime); +void HW_PROT_RegisterUnderVoltageIRQ(hwProtIsrCallback_t callback); +void HW_PROT_UnRegisterUnderVoltageIRQ(void); + +/* return 0: normal , 1: low, 2:high */ +uint8_t HW_PROT_GetBattVoltState(void); +/* return 0: normal , others : over heat */ +uint8_t HW_PROT_ChipIsOverHeat(void); + + + + +#endif \ No newline at end of file diff --git a/87400/drivers/hal/inc/lin_device.h b/87400/drivers/hal/inc/lin_device.h new file mode 100644 index 0000000..c66dbe0 --- /dev/null +++ b/87400/drivers/hal/inc/lin_device.h @@ -0,0 +1,152 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file lin_device.h + */ + +#ifndef LIN_DEVICE_H__ +#define LIN_DEVICE_H__ + +#include +#include +#include +#include "lins_sfr.h" + +#define E_LIN_STATUS_COMPLETE (1U << 0) +#define E_LIN_STATUS_WAKEUP (1U << 1) +#define E_LIN_STATUS_ERROR (1U << 2) +#define E_LIN_STATUS_INT_REQ (1U << 3) +#define E_LIN_STATUS_DATA_REQ (1U << 4) +#define E_LIN_STATUS_ABORT (1U << 5) +#define E_LIN_STATUS_IDLE_TIMEOUT (1U << 6) +#define E_LIN_STATUS_ACTIVE (1U << 7) + +#define E_LIN_ERROR_BIT (1U << 0) +#define E_LIN_ERROR_CHECKSUM (1U << 1) +#define E_LIN_ERROR_TIMEOUT (1U << 2) +#define E_LIN_ERROR_PARITY (1U << 3) + + +#define E_LIN_TIME_INACTIVE_SEC_4 (0U) +#define E_LIN_TIME_INACTIVE_SEC_6 (1U) +#define E_LIN_TIME_INACTIVE_SEC_8 (2U) +#define E_LIN_TIME_INACTIVE_SEC_10 (3U) +#define E_LIN_TIME_INACTIVE_MAX (3U) /*E_LIN_TIME_INACTIVE_SEC_10*/ + +#define E_LIN_TIME_WAKEUP_REPEAT_MS_180 (0U) +#define E_LIN_TIME_WAKEUP_REPEAT_MS_200 (1U) +#define E_LIN_TIME_WAKEUP_REPEAT_MS_220 (2U) +#define E_LIN_TIME_WAKEUP_REPEAT_MS_240 (3U) +#define E_LIN_TIME_WAKEUP_REPEAT_MAX (3U)/*E_LIN_TIME_WAKEUP_REPEAT_MS_240*/ + + +#define LIN_RX_FILTER_2_3_us (0U)/* LINS_RX_BIAS_BOOST */ +#define LIN_RX_FILTER_1_3_us (1U) +#define LIN_RX_FILTER_1_0_us (2U) +#define LIN_RX_FILTER_0_8_us (3U) + +#define LIN_TX_DRIVE_CURRENT_32_mA (0U)/* pull down capacity */ +#define LIN_TX_DRIVE_CURRENT_48_mA (1U) +#define LIN_TX_DRIVE_CURRENT_66_mA (2U) +#define LIN_TX_DRIVE_CURRENT_88_mA (3U) +#define LIN_TX_DRIVE_CURRENT_101_mA (4U) +#define LIN_TX_DRIVE_CURRENT_118_mA (5U) +#define LIN_TX_DRIVE_CURRENT_135_mA (6U) +#define LIN_TX_DRIVE_CURRENT_151_mA (7U) + +#define LIN_TX_SLEW_RATE_0_6V_PER_US (1U)/* Slew from 40%*Vbat to 60%*Vbat @Vbat=13V,Cbus=1nF */ +#define LIN_TX_SLEW_RATE_1_2V_PER_US (2U) +#define LIN_TX_SLEW_RATE_1_7V_PER_US (3U) +#define LIN_TX_SLEW_RATE_2_3V_PER_US (4U) +#define LIN_TX_SLEW_RATE_2_8V_PER_US (5U) +#define LIN_TX_SLEW_RATE_3_4V_PER_US (6U) +#define LIN_TX_SLEW_RATE_5_1V_PER_US (7U) + + +#define LIN_BUFF_SIZE 8U + +/* Defines for LIN device to handle message direction. */ +typedef enum{ + LIN_MSG_TYPE_RX = 0U, /*received data from sender for slave; */ + LIN_MSG_TYPE_TX, /*data request from sender for slave; */ + LIN_MSG_TYPE_TX_EVENT, /*event trigger data request from sender for slave; */ +}LinMessageType_t; + + +typedef enum{ + E_LIN_BAUDRATE_10417, + E_LIN_BAUDRATE_19200, + E_LIN_BAUDRATE_20000, +}LIN_BaudRate_t; + +#define E_LIN_BAUDRATE_MAX (3U)/*E_LIN_BAUDRATE_20000*/ + + +typedef enum{ + LIN_CHECKSUM_CLASSIC = 0U, /*!< classic checksum does not include ID Byte. */ + LIN_CHECKSUM_ENHANCED /*!< "enhanced" checksum includes ID Byte. */ +}ChecksumType_t; + + +typedef enum{ + AA_SWITCH_OFF = 0U, + AA_SWITCH_ON, +}AutoaddressingSwitchState_t; + +/** +* @brief A structure to represent LIN frame information. +*/ +typedef struct { + uint8_t frameTobeHandled :1; /*!< frame ID waiting to be handled */ + uint8_t reverved :7; + uint8_t frame_id; /*!< frame ID. */ + uint8_t msg_type :2; /*!< Type of message,LinMessageType_t rx,tx or event trigger. */ + uint8_t checksum :1; /*!< Type of checksum (enhanced or classic). */ + uint8_t length :5; /*!< Number of bytes in the data. */ + + uint8_t responseValid :1; + uint8_t frameIsValid :1; + uint8_t eventTriggered :1; /*!< event triggered when the msg_type is LIN_MSG_TYPE_TX_EVENT */ + uint8_t linkedEventTriggerFidTableIndex :5; /*!< event triggered when the msg_type is LIN_MSG_TYPE_TX_EVENT */ + + union{ + uint8_t data[LIN_BUFF_SIZE]; /*!< data buffer. */ + uint16_t data16[LIN_BUFF_SIZE/2]; + uint32_t data32[LIN_BUFF_SIZE/4]; + uint64_t data64; + }; +} LIN_Device_Frame_t; + + + +typedef void (*lin_cb_func_t)(LIN_Device_Frame_t const *frame); +typedef void (*lin_stack_cb_func_t)(void); +typedef void (*lin_wakeup_cb_func_t)(void); + +void LINS_Init(void); +void LINS_SetSlaveModuleToSleep(void); +void LINS_RegisterLINStack_IRQ(lin_stack_cb_func_t callback,lin_wakeup_cb_func_t wakeupCallback); + +#if LIN_STACK_TYPE == LIN_STACK_TYPE_PRIVATE + +typedef void (*ls_DataReqCallback_t)(LIN_Device_Frame_t const *frame); +typedef void (*ls_DataRspCallback_t)(LIN_Device_Frame_t *const frame); +typedef void (*ls_SleepReqCallback_t)(void); + +typedef struct{ + ls_DataReqCallback_t dataReqCallback; /* received data from master */ + ls_DataRspCallback_t dataRspCallback; /* send data to master */ + ls_SleepReqCallback_t sleepReqCallback; +}ls_LinsPrivateFramesCallback_t; + +void LINS_RegisterPrivateServices(LIN_Device_Frame_t *frameTable, uint8_t tableSize, const ls_LinsPrivateFramesCallback_t *pFunCallback); + +#endif + + +#endif /* __LIN_DEVICE_H__ */ diff --git a/87400/drivers/hal/inc/math_div_device.h b/87400/drivers/hal/inc/math_div_device.h new file mode 100644 index 0000000..646b5dd --- /dev/null +++ b/87400/drivers/hal/inc/math_div_device.h @@ -0,0 +1,39 @@ +#ifndef MATH_DIV_DEVICE_H__ +#define MATH_DIV_DEVICE_H__ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#endif \ No newline at end of file diff --git a/87400/drivers/hal/inc/pmu_device.h b/87400/drivers/hal/inc/pmu_device.h new file mode 100644 index 0000000..947a184 --- /dev/null +++ b/87400/drivers/hal/inc/pmu_device.h @@ -0,0 +1,122 @@ +/** + * @copyright 2017 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file pmu_device.h + */ + +#ifndef PMU_DEVICE_H__ +#define PMU_DEVICE_H__ + +#include +#include +#include +#include +#include + +typedef enum{ + POLARITY_NATIVE = 0, + POLARITY_FLIP, +}BattMonitorPolarity_t; + + +typedef enum{ + BOR_1V5_THRS_1298mV = 0, + BOR_1V5_THRS_1328mV, + BOR_1V5_THRS_1358mV, + BOR_1V5_THRS_1393mV, + BOR_1V5_THRS_1423mV, + BOR_1V5_THRS_1463mV, +}Bor1V5Thres_t; + + +typedef enum{ + BOR_3V3_THRS_2163mV = 0, + BOR_3V3_THRS_2228mV, + BOR_3V3_THRS_2292mV, + BOR_3V3_THRS_2363mV, + BOR_3V3_THRS_2433mV, + BOR_3V3_THRS_2513mV, + BOR_3V3_THRS_2598mV, + BOR_3V3_THRS_2688mV, + BOR_3V3_THRS_2783mV, + BOR_3V3_THRS_2883mV, + BOR_3V3_THRS_2998mV, + BOR_3V3_THRS_3118mV, + BOR_3V3_THRS_3248mV, +}Bor3V3Thres_t; + +/** + * @brief The enumeration of brownout mode. + */ +typedef enum { + PMU_BROWNOUT_RESET = 0U, + PMU_BROWNOUT_INTERRUPT, + PMU_BROWNOUT_NONE, +} PMU_BROWNOUT_MODE_t; + +/** + * @brief The enumeration of wake up timer mode. + */ +typedef enum { + WAKEUP_TIMEER_DISABLE = 0U, + WAKEUP_TIMEER_ENABLE, +} PMU_WAKEUP_TIMEER_MODE_t; + +/** + * @brief The enumeration of wake up timer mode. + */ +typedef enum { + WAKEUP_TIMEER_INTERVAL_100us = 0U, + WAKEUP_TIMEER_INTERVAL_200us, + WAKEUP_TIMEER_INTERVAL_400us, + WAKEUP_TIMEER_INTERVAL_800us, + WAKEUP_TIMEER_INTERVAL_16ms, + WAKEUP_TIMEER_INTERVAL_32ms, + WAKEUP_TIMEER_INTERVAL_64ms, + WAKEUP_TIMEER_INTERVAL_128ms, + WAKEUP_TIMEER_INTERVAL_256ms, + WAKEUP_TIMEER_INTERVAL_512ms, + WAKEUP_TIMEER_INTERVAL_1024ms, + WAKEUP_TIMEER_INTERVAL_2048ms, + WAKEUP_TIMEER_INTERVAL_4096ms, + WAKEUP_TIMEER_INTERVAL_8192ms, + WAKEUP_TIMEER_INTERVAL_16384ms, + WAKEUP_TIMEER_INTERVAL_32768ms +} PMU_WAKEUP_TIMEER_Interval_t; + + + + +#define MODUE_SOFT_RESET_ADC (0x001U) +#define MODUE_SOFT_RESET_PWM (0x002U) +#define MODUE_SOFT_RESET_CTT (0x004U) +#define MODUE_SOFT_RESET_GTM (0x008U) +#define MODUE_SOFT_RESET_SPIM (0x010U) +#define MODUE_SOFT_RESET_UART (0x011U) +#define MODUE_SOFT_RESET_MATHDIV (0x012U) +#define MODUE_SOFT_RESET_CRC (0x014U) +#define MODUE_SOFT_RESET_PWM_AUX (0x018U) +#define MODUE_SOFT_RESET_LINS (0x020U) + + + + + + + + + + +void PMU_BORInit(Bor1V5Thres_t lowThreshold, Bor3V3Thres_t highThreshold); +void PMU_WakeTimerInit(PMU_WAKEUP_TIMEER_MODE_t mode, PMU_WAKEUP_TIMEER_Interval_t interval); +void PMU_EnterDeepSleepMode(void); + + + + +#endif /* __PMU_DEVICE_H__ */ diff --git a/87400/drivers/hal/inc/pwm_aux_device.h b/87400/drivers/hal/inc/pwm_aux_device.h new file mode 100644 index 0000000..3cdbb09 --- /dev/null +++ b/87400/drivers/hal/inc/pwm_aux_device.h @@ -0,0 +1,44 @@ +#ifndef PWM_AUX_DEVICE_H__ +#define PWM_AUX_DEVICE_H__ + +#include +#include +#include +#include + +typedef void (*PwmAuxIsrCallback_t)(void); + + +typedef enum{ + PWMAUX_CHANNEL_0 = 0U, + PWMAUX_CHANNEL_1, + PWMAUX_CHANNEL_2, + PWMAUX_CHANNEL_3, + PWMAUX_CHANNEL_4, + PWMAUX_CHANNEL_5, +}PwmAuxChannel_t; + +typedef enum{ + PWMAUX_BASE_0 = 0U, + PWMAUX_BASE_1, +}PWMAUX_ClockSource_t; + + +typedef enum{ + PWMAUX_CLK_DIV_1 = 0U, + PWMAUX_CLK_DIV_2, + PWMAUX_CLK_DIV_4, + PWMAUX_CLK_DIV_8, + PWMAUX_CLK_DIV_16, + PWMAUX_CLK_DIV_64, + PWMAUX_CLK_DIV_256, + PWMAUX_CLK_DIV_1024, +}PWMAUX_Prescaler_t; + +void PWMAUX_Init(PwmAuxChannel_t channel,PWMAUX_ClockSource_t source,PWMAUX_Prescaler_t divider,uint16_t peroid); +void PWMAUX_RegisterReloadIRQ(PWMAUX_ClockSource_t source, PwmAuxIsrCallback_t callback); +void PWMAUX_UnRegisterReloadIRQ(PWMAUX_ClockSource_t source); +void PWMAUX_SetMatchValue(PwmAuxChannel_t channel, uint16_t matchRisingValue, uint16_t matchFaillValue); + + +#endif \ No newline at end of file diff --git a/87400/drivers/hal/inc/pwm_device.h b/87400/drivers/hal/inc/pwm_device.h new file mode 100644 index 0000000..37342e4 --- /dev/null +++ b/87400/drivers/hal/inc/pwm_device.h @@ -0,0 +1,67 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file pwm_device.h + */ + +#ifndef PWM_DEVICE_H__ +#define PWM_DEVICE_H__ + +#include +#include +#include +#include +#include + +typedef enum{ + PWM_CH0_0 = 0U, + PWM_CH0_1 = 1U, + PWM_CH1_0 = 2U, + PWM_CH1_1 = 3U, + PWM_CH2_0 = 4U, + PWM_CH2_1 = 5U, + PWM_CH3_0 = 6U, + PWM_CH3_1 = 7U, +}PWM_CH_t; + +typedef enum{ + PWM_BASE_0 = 0U, + PWM_BASE_1, +}PWM_ClockSource_t; + +typedef enum{ + PWM_CLK_DIV_1 = 0U, + PWM_CLK_DIV_2, + PWM_CLK_DIV_4, + PWM_CLK_DIV_8, + PWM_CLK_DIV_16, + PWM_CLK_DIV_32, + PWM_CLK_DIV_64, + PWM_CLK_DIV_128, + PWM_CLK_DIV_256, + PWM_CLK_DIV_512, + PWM_CLK_DIV_1024, + PWM_CLK_DIV_2048, + PWM_CLK_DIV_4096, + PWM_CLK_DIV_8192, + PWM_CLK_DIV_16384, + PWM_CLK_DIV_32768, +}PWM_Prescaler_t; + +typedef enum{ + PULSE_0 = 0U, + PULSE_1, + PULSE_2, + PULSE_3, +}PWM_Pulse_t; + +void PWM_Init(GpioGroup_t group,GpioPort_t port,PWM_CH_t channel,PWM_ClockSource_t source,PWM_Prescaler_t divider,uint16_t peroid); +void PWM_SetMatchValue(PWM_ClockSource_t source,PWM_Pulse_t pulse,uint16_t matchRisingValue, uint16_t matchFaillValue); +void PWM_Listofotherparameters_Init(void); + +#endif /* __PWM_DEVICE_H__ */ diff --git a/87400/drivers/hal/inc/spi_device.h b/87400/drivers/hal/inc/spi_device.h new file mode 100644 index 0000000..b000e62 --- /dev/null +++ b/87400/drivers/hal/inc/spi_device.h @@ -0,0 +1,54 @@ +#ifndef SPI_DEVICE_H__ +#define SPI_DEVICE_H__ + +#include + + + +typedef enum{ + SPI_CLK_DIV_2 = 0, + SPI_CLK_DIV_4, + SPI_CLK_DIV_8, + SPI_CLK_DIV_32, + SPI_CLK_DIV_64, + SPI_CLK_DIV_16, + SPI_CLK_DIV_128, + SPI_CLK_DIV_256, + SPI_CLK_DIV_512, + SPI_CLK_DIV_1024, + SPI_CLK_DIV_2048, + SPI_CLK_DIV_4096, +}SpiClkDevider_t; + + +int8_t SPI_Init(SpiClkDevider_t devider); +int8_t SPI_SendBuff(uint8_t * const buff, uint16_t length); +int8_t SPI_ReadBuff(uint8_t * const buff, uint16_t length); +uint8_t SPI_ReadWriteOneByte(uint8_t data); + + + + + + + + + + + + + + + + + + + + + + + + + + +#endif \ No newline at end of file diff --git a/87400/drivers/hal/inc/systick_device.h b/87400/drivers/hal/inc/systick_device.h new file mode 100644 index 0000000..5f6459d --- /dev/null +++ b/87400/drivers/hal/inc/systick_device.h @@ -0,0 +1,49 @@ +/** + * @copyright 2016 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file systick_device.h + */ + +#ifndef SYSTICK_DEVICE_H +#define SYSTICK_DEVICE_H + +#include + +typedef void (*sysTick_cb_func_t)(void); + + +void SysTick_Init(uint32_t ticks, sysTick_cb_func_t callback); +uint32_t SysTick_GetCount(void); +uint32_t SysTick_GetLoad(void); + + + + + + + + + + + + + + + + + + + + + + + + + +#endif /* ___SYSTICK_DEVICE_H__ */ + diff --git a/87400/drivers/hal/inc/uart_device.h b/87400/drivers/hal/inc/uart_device.h new file mode 100644 index 0000000..3cc4d75 --- /dev/null +++ b/87400/drivers/hal/inc/uart_device.h @@ -0,0 +1,106 @@ +#ifndef UART_DEVICE_H__ +#define UART_DEVICE_H__ + + +#include + +#define TX_MAX_FIFO_SIZE (8U) +#define RX_MAX_FIFO_SIZE (32U) + +#define TX_BUFF_SIZE_POS (7U) +#define TX_BUFF_SIZE (1U << TX_BUFF_SIZE_POS) + +#define RX_BUFF_SIZE RX_MAX_FIFO_SIZE +#define RX_FIFO_INT_SIZE (RX_MAX_FIFO_SIZE/2) +#define TX_FIFO_INT_SIZE (1U) + +#define BAUDRATE_OSR_16MHZ_HIGH_SPEED (16U) +#define BAUDRATE_OSR_16MHZ (14U) +#define BAUDRATE_OSR_8MHZ (14U) +#define BAUDRATE_OSR_4MHZ (13U) +#define BAUDRATE_OSR_2MHZ (13U) + + + +//typedef enum{ +// BAUDRATE_9600 = 9600U, +// BAUDRATE_19200 = 19200U, +// BAUDRATE_38400 = 38400U, +// BAUDRATE_57600 = 57600U, +// BAUDRATE_115200 = 115200U, +// BAUDRATE_250000 = 250000U, +// BAUDRATE_500000 = 500000U, +// BAUDRATE_1000000 = 1000000U, +//}Baudrate_t; + +typedef enum{ + BITSIZE_7BITS = 2U, + BITSIZE_8BITS = 3U, +}BitSize_t; + +/*!< Parity: 00: NONE, 01: ODD, 11: EVEN */ +typedef enum{ + PARITY_NONE = 0U, + PARITY_ODD = 1U, + PARITY_EVEN = 3U, +}Parity_t; + + +typedef enum{ + STOPS_1BITS = 0U, + STOPS_2BITS, +}StopBits_t; + + +#define RX_DATA_SIZE (128U) +#define VALID_RX_PACKAGE_SIZE (81U) + +typedef void (*uartRx_cb_func_t)(uint8_t* buff, uint8_t length); +typedef void (*uartTx_cb_func_t)(void); + + +int8_t UART_Init(uint32_t baudRate, BitSize_t bitSize, Parity_t parity,StopBits_t stopBits); +void UART_RegisterIRQ(uartRx_cb_func_t rxDowncallback); +void UART_UnRegisterIRQ(void); +int8_t UART_SendBuff(uint8_t *buff, uint16_t length); +uint8_t UART_ReadByte(void); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#endif \ No newline at end of file diff --git a/87400/drivers/hal/inc/wdt_device.h b/87400/drivers/hal/inc/wdt_device.h new file mode 100644 index 0000000..50422bb --- /dev/null +++ b/87400/drivers/hal/inc/wdt_device.h @@ -0,0 +1,46 @@ +/** + * @copyright 2017 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file wdt_device.h + */ + +#ifndef WDT_DEVICE_H__ +#define WDT_DEVICE_H__ + +#include +#include +#include "errno.h" + + +typedef void (*wdt_cb_func_t)(void); + +typedef enum{ + WDTA_INTERVAL_144MS = 0U,/*0x0: 2^11 * 62.5us ~= 128*(1+1/8) ms*/ + WDTA_INTERVAL_288MS, /*0x2: 2^12 * 62.5us ~= 256*(1+1/8) ms*/ + WDTA_INTERVAL_576MS, /*0x3: 2^13 * 62.5us ~= 512*(1+1/8) ms*/ + WDTA_INTERVAL_1152MS, /*0x4: 2^14 * 62.5us ~= 1.0*(1+1/8) s*/ + WDTA_INTERVAL_2304MS, /*0x5: 2^15 * 62.5us ~= 2.0*(1+1/8) s*/ + WDTA_INTERVAL_4608MS, /*0x6: 2^16 * 62.5us ~= 4.0*(1+1/8) s*/ + WDTA_INTERVAL_9216MS, /*0x7: 2^17 * 62.5us ~= 8.0*(1+1/8) s*/ + WDTA_INTERVAL_18432MS, /*0x7: 2^18 * 62.5us ~= 16.0*(1+1/8)s*/ +}WDTAInterval_t; + +typedef enum{ + WDTA_MODE_RESET = 0U, +}WDTAMode_t; + + +void WDTA_Enable(WDTAInterval_t interval); +void WDTA_Disable(void); +void WDTA_Clear(void); + + + + +#endif /* __WDT_DEVICE_H__ */ + diff --git a/87400/drivers/hal/src/adc_device.c b/87400/drivers/hal/src/adc_device.c new file mode 100644 index 0000000..deb1a3f --- /dev/null +++ b/87400/drivers/hal/src/adc_device.c @@ -0,0 +1,183 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file adc_device.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ + +#include +#include +#include +static ADCMeasureParam_t adcMeasParamm = {ADC_MEASURE_ITEM_NONE, 0}; +static adc_cb_func_t adcCallback = NULL; +static uint16_t adcResult[10]; + + +void ADC_Handler(void) +{ + if (adcCallback !=NULL){ + for (uint8_t i = 0U; i < 10U; i++){ + adcResult[i] = (uint16_t)(SAR_CTRL_SFRS->DATA[i].DATA & 0x0FFFU); + } + adcCallback(adcMeasParamm, adcResult); + } + SAR_CTRL_SFRS->SARINT.CLEAR.INT_CONV_DONE_CLR = 1U; + SAR_CTRL_SFRS->SARCTRL.SARENAREQ = 0U; +} + +void ADC_GeneralInit(void) +{ +#if SYS_MAIN_CLOCK_DIV == CLOCK_DIV_1 + SAR_CTRL_SFRS->SARCLKDIV = 4U; +#elif SYS_MAIN_CLOCK_DIV == CLOCK_DIV_2 + SAR_CTRL_SFRS->SARCLKDIV = 2U; +#else + SAR_CTRL_SFRS->SARCLKDIV = 1U; +#endif + + SAR_CTRL_SFRS->SARCFG.TRIGSEL = 0U; + SAR_CTRL_SFRS->AFECTRL.SARAFEEN = 1U; + SAR_CTRL_SFRS->AFECTRL.ADCSELVINVCMEXT = 0U; /* set to 1 if only test PN voltage and enable low voltage mode when SAR_CTRL_SFRS->AFECTRL.SARAFEEN = 0;*/ + SAR_CTRL_SFRS->SARCTRL.SARENAREQ = 1U; /* SAR ADC Enable. Set to enable the SAR analog & digital part */ + SAR_CTRL_SFRS->AFECTRL.SARPREAMPEN = 1U; + SAR_CTRL_SFRS->SARCFG.TRIGDLY = 8U; + + SAR_CTRL_SFRS->ADCCHCTRL1R.SAMPCYCCH1 = 7U; + SAR_CTRL_SFRS->ADCCHCTRL1R.SAMPCYCCH2 = 7U; + SAR_CTRL_SFRS->ADCCHCTRL1R.SAMPCYCCH3 = 7U; + SAR_CTRL_SFRS->ADCCHCTRL1R.SAMPCYCCH4 = 7U; + SAR_CTRL_SFRS->ADCCHCTRL1R.SAMPCYCCH5 = 7U; + SAR_CTRL_SFRS->ADCCHCTRL1R.SAMPCYCCH6 = 7U; + SAR_CTRL_SFRS->ADCCHCTRL1R.SAMPCYCCH7 = 7U; + SAR_CTRL_SFRS->ADCCHCTRL1R.SAMPCYCCH8 = 7U; + SAR_CTRL_SFRS->ADCCHCTRL2R.SAMPCYCCH9 = 7U; + SAR_CTRL_SFRS->ADCCHCTRL2R.SAMPCYCCH10 = 7U; + + for (uint8_t i = 0U; i < 10U; i++){ + /* VREF */ + SAR_CTRL_SFRS->ADCCHCTRL2R.WORD &= ~((uint32_t)0x03UL << (i*2U+8U)); + SAR_CTRL_SFRS->ADCCHCTRL2R.WORD |= ((uint32_t)ADC_REF_VDD_3V3 << (i*2U+8U)); + + /* INPUT_MODE */ + SAR_CTRL_SFRS->ADCCHCTRL0R.WORD &= ~((uint32_t)0x03UL << (i*2U+0U)); + SAR_CTRL_SFRS->ADCCHCTRL0R.WORD |= ((uint32_t)ADC_AFE_INPUT_INP_BUFFERED_INN_EXT << (i*2U+0U)); + + /* INPUT GAIN */ + SAR_CTRL_SFRS->ADCCHCTRL0R.WORD &= ~((uint32_t)0x01UL << (i*1U+20U)); + SAR_CTRL_SFRS->ADCCHCTRL0R.WORD |= ((uint32_t)ADC_AFE_GAIN_31_OF_32 << (i*1U+20U)); + } + +} + + +void ADC_Init(AdcMeasureItem_t item, uint8_t channel) +{ + ADCTriggerParam_t source; + source.selection = ADC_TRIGGER_SEL_GENERAL_TRIGSRC; + source.general = ADC_TRIG_SRC_SOFT_INPUT; + source.channel = ADC_PWMAUX_CHN0; + adcMeasParamm.item = item; + adcMeasParamm.channel = channel; + + switch(item){ + case ADC_MEASURE_ITEM_VBAT_VTEMP:/* 1x */ + SAR_CTRL_SFRS->ADCCHCONF.CH1SEL = ADC_CH_SEL_TSENSOR_GND;// + SAR_CTRL_SFRS->ADCCHCONF.CH2SEL = ADC_CH_SEL_VBAT_GND; + SAR_CTRL_SFRS->ADCCHCONF.CH3SEL = ADC_CH_SEL_PB6_GND; + SAR_CTRL_SFRS->ADCCHCONF.CH4SEL = ADC_CH_SEL_PB7_GND; + SAR_CTRL_SFRS->ADCCHCONF.SEQCNT = ADC_SQ_CH1_2_CH4;//0x3: CH1->CH2->CH3 + source.selection = ADC_TRIGGER_SEL_GENERAL_TRIGSRC; + source.general = ADC_TRIG_SRC_SOFT_INPUT; + + break; + + case ADC_MEASURE_ITEM_VBG: /*1x */ + SAR_CTRL_SFRS->ADCCHCONF.CH1SEL = (uint8_t)ADC_CH_SEL_REF_GND; + SAR_CTRL_SFRS->ADCCHCONF.SEQCNT = (uint8_t)ADC_SQ_CH1_2_CH1; + source.selection = ADC_TRIGGER_SEL_GENERAL_TRIGSRC; + source.general = ADC_TRIG_SRC_SOFT_INPUT; + break; + + case ADC_MEASURE_ITEM_VBAT: /*1/16x */ + SAR_CTRL_SFRS->ADCCHCONF.CH1SEL = (uint8_t)ADC_CH_SEL_VBAT_GND; + SAR_CTRL_SFRS->ADCCHCONF.SEQCNT = (uint8_t)ADC_SQ_CH1_2_CH1; + source.selection = ADC_TRIGGER_SEL_GENERAL_TRIGSRC; + source.general = ADC_TRIG_SRC_SOFT_INPUT; + break; + + case ADC_MEASURE_ITEM_VDD1V5: + SAR_CTRL_SFRS->ADCCHCONF.CH1SEL = (uint8_t)ADC_CH_SEL_1V5_GND; + SAR_CTRL_SFRS->ADCCHCONF.SEQCNT = (uint8_t)ADC_SQ_CH1_2_CH1; + source.selection = ADC_TRIGGER_SEL_GENERAL_TRIGSRC; + source.general = ADC_TRIG_SRC_SOFT_INPUT; + break; + + case ADC_MEASURE_ITEM_PC3: + SAR_CTRL_SFRS->ADCCHCONF.CH1SEL = (uint8_t)((uint8_t)ADC_CH_SEL_PC3_GND + channel); + SAR_CTRL_SFRS->ADCCHCONF.SEQCNT = (uint8_t)ADC_SQ_CH1_2_CH1; + source.selection = ADC_TRIGGER_SEL_GENERAL_TRIGSRC; + source.general = ADC_TRIG_SRC_SOFT_INPUT; + break; + + default: + break; + } + SAR_CTRL_SFRS->SARCFG.TRIGSEL = (uint8_t)source.selection; + if (source.selection == ADC_TRIGGER_SEL_GENERAL_TRIGSRC){ + SAR_CTRL_SFRS->SARCFG.TRIGSRC = (uint8_t)source.general; + }else{ + SAR_CTRL_SFRS->SARCFG.PWMAUXTRIGSEL = (uint8_t)source.pwmAux; + SAR_CTRL_SFRS->SARCFG.PWMAUXCHSEL = (uint8_t)source.channel; + } +} + +void ADC_UnInit(AdcMeasureItem_t item) +{ + + +} + +/** + * @brief Register a callback function to ADC interrupt handler. + * + * @param dev Pointer to the ADC device. + * @param cb The callback function to be registered. + * @return 0 for success or error code upon a failure. + */ +void ADC_RegisterIRQ(adc_cb_func_t callback) +{ + adcCallback = callback; + SAR_CTRL_SFRS->SARINT.CLEAR.INT_CONV_DONE_CLR = 1U; + SAR_CTRL_SFRS->SARINT.ENABLE.INT_CONV_DONE_ENA = 1U; + NVIC_EnableIRQ(ADC_IRQn); + +} + +/** + * @brief Unregister a callback function to ADC interrupt handler. + * + * @param dev Pointer to the ADC device. + * @param cb The callback function to be unregistered. + * @return 0 for success or error code upon a failure. + */ +void ADC_UnregisterIRQ(void) +{ + adcCallback = NULL; + SAR_CTRL_SFRS->SARINT.CLEAR.INT_CONV_DONE_CLR = 1U; + SAR_CTRL_SFRS->SARINT.ENABLE.INT_CONV_DONE_ENA = 0U; + NVIC_DisableIRQ(ADC_IRQn); +} + +void ADC_Start(void) +{ + SAR_CTRL_SFRS->SARINT.CLEAR.INT_CONV_DONE_CLR = 1U; + SAR_CTRL_SFRS->SARCTRL.SARENAREQ = 1U; + SAR_CTRL_SFRS->SARCTRL.CONVERT = 1U; +} diff --git a/87400/drivers/hal/src/clock_device.c b/87400/drivers/hal/src/clock_device.c new file mode 100644 index 0000000..9b6a58f --- /dev/null +++ b/87400/drivers/hal/src/clock_device.c @@ -0,0 +1,47 @@ +/** + * @copyright 2016 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file clock_device.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ + +#include + +#define SYSTEM_CLOCK_SUPER_HIGH_FREQ (48000U)/* KHz */ +#define SYSTEM_CLOCK_HIGH_FREQ (16000U)/* KHz */ +#define SYSTEM_CLOCK_LOW_FREQ (256U) /* KHz */ +static uint32_t systemClock = SYSTEM_CLOCK_HIGH_FREQ; + +void Clock_SystemMainClockInit(uint8_t divider) +{ + CRGA_SFRS->SYSCLKCTRL.HFRCENA = 1U; + while(CRGA_SFRS->SYSCLKCTRL.HFRCSTS == 0U){} + /* Enable trim access write enable */ + SYSCTRLA_SFRS->TRIM_ACCESS_KEY.TRIM_ACCESS_KEY = 0x0EU; + SYSCTRLA_SFRS->HF_OSC_TRIM.TRIM_HF_RC= HWCFG_GetRCHFClockCalibValue(); + + TRIMHV_SFRS->TRIM_LF_RC = HWCFG_GetRCLFClockCalibValue(); + + CRGA_SFRS->SYSCLKCTRL.SYSCLKSEL = (uint8_t)CLOCK_RC_16MHz; + CRGA_SFRS->SYSCLKCTRL.DIVSYSCLK = (uint8_t)divider; + /* frequency spread */ + SYSCTRLA_SFRS->HF_OSC_TRIM.SSCDEEP = 7U; + SYSCTRLA_SFRS->HF_OSC_TRIM.SSCDIV = 15U; + SYSCTRLA_SFRS->HF_OSC_TRIM.SSCENA = 1U; + + systemClock = SYSTEM_CLOCK_HIGH_FREQ; + systemClock = systemClock >> (uint8_t)divider; + +} + +uint32_t Clock_GetSystemClock(void) +{ + return systemClock;/* KHz */ +} diff --git a/87400/drivers/hal/src/ctt_device.c b/87400/drivers/hal/src/ctt_device.c new file mode 100644 index 0000000..d15e159 --- /dev/null +++ b/87400/drivers/hal/src/ctt_device.c @@ -0,0 +1,137 @@ +/* This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file timer_device.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ +#include +#include +#include +#include +#include +#include +#include "errno.h" +#include + +//static CttTimeoutCallbackFunc_t timeoutCallbackFunc[HW_CTT_TIMER_NUM] = {NULL,NULL,NULL,NULL,NULL}; + +void CT2_Handler( void ) +{ + CTT_SFRS->INTCTRLR.CT2IC = 1U; + CTT2_Time_Reload(HW_TIMER_RELOAD); +} + +void CT3_Handler( void ) +{ + CTT_SFRS->INTCTRLR.CT3IC = 1U; +} + +void CT4_Handler( void ) +{ + CTT_SFRS->INTCTRLR.CT4IC = 1U; +} + +void CT5_Handler( void ) +{ + CTT_SFRS->INTCTRLR.CT5IC = 1U; +} + +void CT6_Handler( void ) +{ + CTT_SFRS->INTCTRLR.CT6IC = 1U; +} + +void CTT2_Init(HwCttTimeMode_t mode, CttTimer_Prescaler_t prescale, uint16_t timeoutTicks) +{ + switch(mode) + { + case HW_TIMER_MODE: + CTT_SFRS->CT2CTRLR.CT2DIR = 0U; + CTT_SFRS->CT2CTRLR.CT2RC = 0U; /* CT2R CONTORL */ + CTT_SFRS->CT2CTRLR.CT2M = 0U; /* Timer Mode */ + CTT_SFRS->CT2CTRLR.CT2PRESHI = ((uint8_t)prescale>>3U); + CTT_SFRS->CT2CTRLR.CT2I = ((uint8_t)prescale & 0x07U) ; + CTT_SFRS->CT2CV = timeoutTicks; + CTT_SFRS->INTCTRLR.CT2IE = 1U; + CTT_SFRS->CT2CTRLR.CT2R = 1U; + NVIC_EnableIRQ(CT2_IRQn); + break; + + case HW_COUNT_MODE: + break; + + case HW_GATED_TIMER_MODE_WITH_GATE_ACTIVE_LOW: + break; + + case HW_GATED_TIMER_MODE_WITH_GATE_ACTIVE_HIGH: + break; + + case HW_RELOAD_MODE: + break; + + case HW_CAPTURE_MODE: + CTT_SFRS->CTTINSR.SELCT2IN = 0U; /*select CT2INA input */ + CTT_SFRS->CT2CTRLR.CT2IIMIDIS = 1U; /* Disable incrmental interrupt */ + CTT_SFRS->CT2CTRLR.CT2RC = 1U; /* Timer CT2 is controlled by the run bit CT3R of core timer CT3 */ + CTT_SFRS->CT2CTRLR.CT2M = (uint8_t)HW_CAPTURE_MODE; /* Capture Mode */ + /* CTT_SFRS->CT2CTRLR.CT2PRESHI = (prescale>>3u); */ + CTT_SFRS->CT2CTRLR.CT2I = 3U ; /* Any transition (rising or falling edge) on CT2IN */ + CTT_SFRS->INTCTRLR.CT2IE = 1U; + CTT_SFRS->CT3CTRLR.CT3IIMIDIS = 1U; /* Disable incrmental interrupt */ + CTT_SFRS->CT3CTRLR.CT3UD = 0U; /* counts up */ + CTT_SFRS->CT3CTRLR.CT3M = (uint8_t)HW_TIMER_MODE; /* Timer Mode */ + CTT_SFRS->CT3CTRLR.CT3PRESHI = ((uint8_t)prescale>>3U); + CTT_SFRS->CT3CTRLR.CT3I = ((uint8_t)prescale & 0x07U) ; + CTT_SFRS->CT3CV = 0U; + CTT_SFRS->CT3CTRLR.CT3R = 1U; + NVIC_EnableIRQ(CT2_IRQn); + + break; + + case HW_INCREMENTAL_INTERFACE_MODE_ROTATION_DETECTION: + + break; + + case HW_INCREMENTAL_INTERFACE_MODE_EDGE_DETECTION: + + break; + + default: + break; + } + +} + +void CTT_Disable(HwCTTId_t timerId) +{ + if(timerId == CT2){ + NVIC_DisableIRQ(CT2_IRQn); + } + if(timerId == CT3){ + NVIC_DisableIRQ(CT3_IRQn); + } + if(timerId == CT4){ + NVIC_DisableIRQ(CT4_IRQn); + } + if(timerId == CT5){ + NVIC_DisableIRQ(CT5_IRQn); + } + if(timerId == CT6){ + NVIC_DisableIRQ(CT6_IRQn); + } +} + + +void CTT2_Time_Reload(uint16_t count) +{ + CTT_SFRS->CT2CV = count; +} + + + + + diff --git a/87400/drivers/hal/src/flash_device.c b/87400/drivers/hal/src/flash_device.c new file mode 100644 index 0000000..381065d --- /dev/null +++ b/87400/drivers/hal/src/flash_device.c @@ -0,0 +1,36 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file flash_device.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ + +#include +#include +#include +#include + + +void Flash_EraseSector(uint32_t sectorAddress) +{ + /* Erase sector data */ + f_FLASH_EraseSector(sectorAddress); +} + +void FLASH_Write2WordsWithECC(uint32_t address,uint32_t dataL,uint32_t dataH) +{ + f_FLASH_Write2WordsWithECC(address, dataL,dataH); +} + + + + + + diff --git a/87400/drivers/hal/src/gTimer_device.c b/87400/drivers/hal/src/gTimer_device.c new file mode 100644 index 0000000..14fbef4 --- /dev/null +++ b/87400/drivers/hal/src/gTimer_device.c @@ -0,0 +1,101 @@ +/** + * @copyright 2017 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file timer_device.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ + +#include +#include +#include +#include +#include +#include "errno.h" +#include + +//GTimer4-5Handler be used by linstack lib + +static TimeoutCallbackFunc_t timeoutCallbackFunc[HW_GP_TIMER_NUM] = {NULL,NULL,NULL}; + +void GT1_Handler( void ) +{ + if (timeoutCallbackFunc[(uint8_t)TIMER1] != NULL){ + timeoutCallbackFunc[(uint8_t)TIMER1](); + } + GTIMER_SFRS->TIMER[TIMER1].GTINTCTRLR.GTTFC = 1U; +} + +void GT2_Handler( void ) +{ + if (timeoutCallbackFunc[(uint8_t)TIMER2] != NULL){ + timeoutCallbackFunc[(uint8_t)TIMER2](); + } + GTIMER_SFRS->TIMER[(uint8_t)TIMER2].GTINTCTRLR.GTTFC = 1U; +} + +void GT3_Handler( void ) +{ + if (timeoutCallbackFunc[(uint8_t)TIMER3] != NULL){ + timeoutCallbackFunc[(uint8_t)TIMER3](); + } + GTIMER_SFRS->TIMER[(uint8_t)TIMER3].GTINTCTRLR.GTTFC = 1U; +} + + + +void TIMER_Init(HwGpTimerId_t timerId, HwGpTimeMode_t mode, GTimer_Prescaler_t prescale, uint16_t timeoutTicks, TimeoutCallbackFunc_t callback) +{ + GTIMER_SFRS->TIMER[timerId].GTCTRLR.GTR = 0U; + GTIMER_SFRS->TIMER[timerId].GTCTRLR.GTSSE = (uint8_t)mode; + GTIMER_SFRS->TIMER[timerId].GTCTRLR.GTEXTEN = 0U; + GTIMER_SFRS->TIMER[timerId].GTCTRLR.GTCNTEN = 0U; + GTIMER_SFRS->TIMER[timerId].GTCTRLR.GTCAPEN = 0U; + GTIMER_SFRS->TIMER[timerId].GTCTRLR.GTHRSEL = 0U; + GTIMER_SFRS->TIMER[timerId].GTCTRLR.GTDCEN = 0U; + + GTIMER_SFRS->TIMER[timerId].GTCTRLR.GTPRES = (uint8_t)prescale; + GTIMER_SFRS->TIMER[timerId].GTRCV = 0xFFFFU - timeoutTicks; + GTIMER_SFRS->TIMER[timerId].GTCV = 0xFFFFU - timeoutTicks; + timeoutCallbackFunc[timerId] = callback; + GTIMER_SFRS->TIMER[timerId].GTCTRLR.GTR = 1U; + GTIMER_SFRS->TIMER[timerId].GTINTCTRLR.GTTFC = 1U; + GTIMER_SFRS->TIMER[timerId].GTINTCTRLR.GTTFIE = 1U; + int32_t irq = (int32_t)GT1_IRQn + (int32_t)timerId; + NVIC_EnableIRQ((IRQn_Type)irq); +} + + +void TIMER_Disable(HwGpTimerId_t timerId) +{ + GTIMER_SFRS->TIMER[timerId].GTCTRLR.GTR = 0U; + timeoutCallbackFunc[timerId] = NULL; + int32_t irq = (int32_t)GT1_IRQn + (int32_t)timerId; + NVIC_DisableIRQ((IRQn_Type)irq); +} + + + + + + + + + + + + + + + + + + + + diff --git a/87400/drivers/hal/src/gpio_device.c b/87400/drivers/hal/src/gpio_device.c new file mode 100644 index 0000000..41972e3 --- /dev/null +++ b/87400/drivers/hal/src/gpio_device.c @@ -0,0 +1,151 @@ +/** + * @copyright 2017 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file gpio_device.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ + +#include +#include +#include +#include +#include +#include + + +static gpio_cb_func_t gpioCallback[3][8]= { + {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, + {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, + {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL} +}; + +void GPIO_Handler(void) +{ + for (uint8_t i = (uint8_t)GPIO_PORT_0; i<= (uint8_t)GPIO_PORT_7; i++ ){ + + uint8_t enable_flag = GPIO_SFRS->GPIOA[i].IE; + uint8_t action_flag = GPIO_SFRS->GPIOA[i].ACTDET; + if ((action_flag == 1U) && (enable_flag == 1U)){ + if (gpioCallback[GROUP_GPIOA][i] !=NULL){ + gpioCallback[GROUP_GPIOA][i](); + } + GPIO_SFRS->GPIOA[i].CLR = 1U; + } + + enable_flag = GPIO_SFRS->GPIOB[i].IE; + action_flag = GPIO_SFRS->GPIOB[i].ACTDET; + if ((action_flag == 1U) && (enable_flag == 1U)){ + if (gpioCallback[GROUP_GPIOB][i] !=NULL){ + gpioCallback[GROUP_GPIOB][i](); + } + GPIO_SFRS->GPIOB[i].CLR = 1U; + } + + enable_flag = GPIO_SFRS->GPIOC[i].IE; + action_flag = GPIO_SFRS->GPIOC[i].ACTDET; + if ((action_flag == 1U) && (enable_flag == 1U)){ + if (gpioCallback[GROUP_GPIOC][i] !=NULL){ + gpioCallback[GROUP_GPIOC][i](); + } + GPIO_SFRS->GPIOC[i].CLR = 1U; + } + } +} + + +void PWMAUX_GPIO_Init(GpioGroup_t group,GpioPort_t port) +{ + IOCTRLA_SFRS->PORT_GROUP_MUX[group] &= ~(0x0FUL << (4U*(uint8_t)port)); + IOCTRLA_SFRS->PORT_GROUP_MUX[group] |= (0x07UL << (4U*(uint8_t)port)); + + + IOCTRLA_SFRS->CTRL_MODE[group].PU &= ~(1U << (uint8_t)port); + IOCTRLA_SFRS->CTRL_MODE[group].PD &= ~(1U << (uint8_t)port); + + if (group == GROUP_GPIOA){ + GPIO_SFRS->GPIOA[port].DIR = 1; + }else if(group == GROUP_GPIOB){ + GPIO_SFRS->GPIOB[port].DIR = 1; + }else{ + GPIO_SFRS->GPIOC[port].DIR = 1; + } + +} + +void GPIO_Init(GpioGroup_t group,GpioPort_t port, GpioDir_t dir,GpioPullMode_t pullMode) +{ + IOCTRLA_SFRS->PORT_GROUP_MUX[group] &= ~(0x0FUL << (4U*(uint8_t)port)); + + if (pullMode == GPIO_PULL_NONE){ + IOCTRLA_SFRS->CTRL_MODE[group].PU &= ~(1U << (uint8_t)port); + IOCTRLA_SFRS->CTRL_MODE[group].PD &= ~(1U << (uint8_t)port); + }else if (pullMode == GPIO_PULL_UP){ + IOCTRLA_SFRS->CTRL_MODE[group].PU |= (1U << (uint8_t)port); + IOCTRLA_SFRS->CTRL_MODE[group].PD &= ~(1U << (uint8_t)port); + }else if (pullMode == GPIO_PULL_DOWN){ + IOCTRLA_SFRS->CTRL_MODE[group].PU &= ~(1U << (uint8_t)port); + IOCTRLA_SFRS->CTRL_MODE[group].PD |= (1U << (uint8_t)port); + }else{ + IOCTRLA_SFRS->CTRL_MODE[group].PU |= (1U << (uint8_t)port); + IOCTRLA_SFRS->CTRL_MODE[group].PD |= (1U << (uint8_t)port); + } + + IOCTRLA_SFRS->CTRL_MODE[group].RE |= (1U << (uint8_t)port); + + if (group == GROUP_GPIOA){ + GPIO_SFRS->GPIOA[port].DIR = (uint8_t)dir; + }else if(group == GROUP_GPIOB){ + GPIO_SFRS->GPIOB[port].DIR = (uint8_t)dir; + }else{ + GPIO_SFRS->GPIOC[port].DIR = (uint8_t)dir; + } + +} + + +void GPIO_RegisterIRQ(GpioGroup_t group,GpioPort_t port, GpioISREdge_t edge, gpio_cb_func_t callback) +{ + gpioCallback[(uint8_t)group][(uint8_t)port] = callback; + if (group == GROUP_GPIOA){ + GPIO_SFRS->GPIOA[(uint8_t)port].EDGE = (uint8_t)edge; + GPIO_SFRS->GPIOA[(uint8_t)port].CLR = 1U; + GPIO_SFRS->GPIOA[(uint8_t)port].IE = 1U; + }else if (group == GROUP_GPIOB){ + GPIO_SFRS->GPIOB[(uint8_t)port].EDGE = (uint8_t)edge; + GPIO_SFRS->GPIOB[(uint8_t)port].CLR = 1U; + GPIO_SFRS->GPIOB[(uint8_t)port].IE = 1U; + }else{ + GPIO_SFRS->GPIOC[(uint8_t)port].EDGE = (uint8_t)edge; + GPIO_SFRS->GPIOC[(uint8_t)port].CLR = 1U; + GPIO_SFRS->GPIOC[(uint8_t)port].IE = 1U; + } + NVIC_EnableIRQ(GPIO_IRQn); +} + +void GPIO_UnRegisterIRQ(GpioGroup_t group,GpioPort_t port) +{ + gpioCallback[(uint8_t)group][(uint8_t)port] = NULL; +} + +void GPIO_Set(GpioGroup_t group,GpioPort_t port, GpioSetState_t state) +{ + if (state == GPIO_LOW){ + GPIO_SFRS->GPIO_SET[group].DATACLR = 1U << (uint8_t)port; + }else{ + GPIO_SFRS->GPIO_SET[group].DATASET = 1U << (uint8_t)port; + } + +} + +uint8_t GPIO_Read(GpioGroup_t group,GpioPort_t port) +{ + uint8_t data = GPIO_SFRS->GPIO_SET[group].DATA &(1U << (uint8_t)port); + return (uint8_t)(data != 0U); +} diff --git a/87400/drivers/hal/src/hwProtection.c b/87400/drivers/hal/src/hwProtection.c new file mode 100644 index 0000000..2a43ad3 --- /dev/null +++ b/87400/drivers/hal/src/hwProtection.c @@ -0,0 +1,153 @@ +/** + * @copyright 2017 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file hwProtection.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ + +#include +#include +#include + +static hwProtIsrCallback_t otCallback = NULL; +static hwProtIsrCallback_t uvCallback = NULL; +static hwProtIsrCallback_t ovCallback = NULL; + +/* !!!!UV OV are level interrupt */ +void UV_OV_Handler(void) +{ + if (PMUA_SFRS->PMUIRQ.STATUS.UV_STS !=0U){ + if (uvCallback != NULL){ + uvCallback(); + } + PMUA_SFRS->PMUIRQ.CLEAR.UV_CLR = 1U; + } + + if (PMUA_SFRS->PMUIRQ.STATUS.OV_STS != 0U){ + if (ovCallback != NULL){ + ovCallback(); + } + PMUA_SFRS->PMUIRQ.CLEAR.OV_CLR; + } + NVIC_DisableIRQ(UV_OV_IRQn); +} + +void OVTEMP_Handler(void) +{ + if (otCallback != NULL){ + otCallback(); + } + NVIC_DisableIRQ(OVTEMP_IRQn); + CRGA_SFRS->RESETCTRL.OVTEMPFLAGCLR = 1U; +} + + +void HW_PROT_SetOverTmperature(OverTempThres_t threshold, OverTempAction_t action) +{ + TRIMHV_SFRS->OVTEMPCONFIG.VTEMP_SEL = (uint8_t)threshold; + TRIMHV_SFRS->OVTEMPCONFIG.TEMPSENSE_EN = 1U; /* enable temperature sensor */ + + CRGA_SFRS->OVTEMPACTION.OVTEMP = (uint8_t)action; + CRGA_SFRS->OVTEMPACTION.OVERTEMP_EN = 1U; /* enable ov temperature action */ +} + +void HW_PROT_RegisterOVTemperatureIRQ(hwProtIsrCallback_t callback) +{ + otCallback = callback; + CRGA_SFRS->RESETCTRL.OVTEMPFLAGCLR = 1U; + NVIC_EnableIRQ(OVTEMP_IRQn); +} + +void HW_PROT_UnRegisterOVTemperatureIRQ(void) +{ + NVIC_DisableIRQ(OVTEMP_IRQn); + CRGA_SFRS->RESETCTRL.OVTEMPFLAGCLR = 1U; + otCallback = NULL; +} + +void HW_PROT_SetOverVoltage(OverVoltThres_t threshold,OverVoltHysteresis_t hys, VoltDebouceTime_t triggerTime, VoltDebouceTime_t releaseTime) +{ + TRIMHV_SFRS->VBATTRIM.OVLEVEL = (uint8_t)threshold; + TRIMHV_SFRS->VBATTRIM.OVHYS = (uint8_t)hys; + + PMUA_SFRS->VBATDBNC.OVSTRB0SEL = 1U; /* 16KHz source */ + PMUA_SFRS->VBATDBNC.OVSTRB1SEL = 1U; /* 16KHz source */ + + PMUA_SFRS->VBATDBNCTHRES.OVTHRES1 = (uint8_t)triggerTime;/* value*62.5us when 16Khz*/ + PMUA_SFRS->VBATDBNCTHRES.OVTHRES0 = (uint8_t)releaseTime;/* value*62.5us when 16Khz*/ + + TRIMHV_SFRS->VBATTRIM.BAT_OV_EN = 1U; + +} + +void HW_PROT_RegisterOverVoltageIRQ(hwProtIsrCallback_t callback) +{ + ovCallback = callback; + PMUA_SFRS->PMUIRQ.CLEAR.OV_CLR = 1U; + PMUA_SFRS->PMUIRQ.ENABLE.OV_ENA = 1U; + NVIC_EnableIRQ(UV_OV_IRQn); +} + +void HW_PROT_UnRegisterOverVoltageIRQ(void) +{ + NVIC_DisableIRQ(UV_OV_IRQn); + PMUA_SFRS->PMUIRQ.ENABLE.OV_ENA = 0U; + PMUA_SFRS->PMUIRQ.CLEAR.OV_CLR = 1U; + ovCallback = NULL; +} + + +void HW_PROT_SetUnderVoltage(UnderVoltThres_t threshold,UnderVoltHysteresis_t hys, VoltDebouceTime_t triggerTime, VoltDebouceTime_t releaseTime) +{ + TRIMHV_SFRS->VBATTRIM.UVLEVEL = (uint8_t)threshold; + TRIMHV_SFRS->VBATTRIM.UVHYS = (uint8_t)hys; + + PMUA_SFRS->VBATDBNC.UVSTRB0SEL = 1U; /* 16KHz source */ + PMUA_SFRS->VBATDBNC.UVSTRB1SEL = 1U; /* 16KHz source */ + + PMUA_SFRS->VBATDBNCTHRES.UVTHRES1 = (uint8_t)triggerTime; /* value*62.5us when 16Khz*/ + PMUA_SFRS->VBATDBNCTHRES.UVTHRES0 = (uint8_t)releaseTime; /* value*62.5us when 16Khz*/ + + TRIMHV_SFRS->VBATTRIM.BAT_UV_EN = 1U; + +} + +void HW_PROT_RegisterUnderVoltageIRQ(hwProtIsrCallback_t callback) +{ + uvCallback = callback; + PMUA_SFRS->PMUIRQ.CLEAR.UV_CLR = 1U; + PMUA_SFRS->PMUIRQ.ENABLE.UV_ENA = 1U; + NVIC_EnableIRQ(UV_OV_IRQn); +} + +void HW_PROT_UnRegisterUnderVoltageIRQ(void) +{ + NVIC_DisableIRQ(UV_OV_IRQn); + PMUA_SFRS->PMUIRQ.ENABLE.UV_ENA = 0U; + PMUA_SFRS->PMUIRQ.CLEAR.UV_CLR = 1U; + uvCallback = NULL; +} + + +uint8_t HW_PROT_GetBattVoltState(void) +{ + uint8_t result = PMUA_SFRS->VBATCTRL.BAT_STATE; + return result; +} + +uint8_t HW_PROT_ChipIsOverHeat(void) +{ + uint8_t result = (uint8_t)CRGA_SFRS->RESETCTRL.OVTEMPFLAG; + return result; +} + + + + diff --git a/87400/drivers/hal/src/lin_device.c b/87400/drivers/hal/src/lin_device.c new file mode 100644 index 0000000..80af5bd --- /dev/null +++ b/87400/drivers/hal/src/lin_device.c @@ -0,0 +1,333 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file lin_device.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ + +#include +#include + +#include +#include +#include "gtimer_device.h" +#include "errno.h" +#include +#include +#include + +#if LIN_STACK_TYPE == LIN_STACK_TYPE_PRIVATE + static void LINS_SLAVE_ISR(void); + static lin_wakeup_cb_func_t lin_wakeup_callback = NULL; +#else + static lin_stack_cb_func_t lin_stack_callback = NULL; + static lin_wakeup_cb_func_t lin_wakeup_callback = NULL; +#endif + + +typedef struct { + uint16_t divider; + uint16_t multiplier; + uint8_t prescale; +} lin_speed_setting_t; + +/********************************************************************** + * Local definitions + *********************************************************************/ + +/** + * At 16MHz clock, the clock divider settings for each LIN speed. + */ + +#if SYS_MAIN_CLOCK_DIV != CLOCK_DIV_1 +#error MAIN_CPU_CLOCK MUST BE at 16MHz system colck! +#endif + +#if SYS_MAIN_CLOCK_DIV == CLOCK_DIV_1 /* 16MHz */ + static const lin_speed_setting_t lins_speed_map[] = { + [E_LIN_BAUDRATE_10417] = {.divider = 200U, .multiplier = 0U, .prescale = 1U}, + [E_LIN_BAUDRATE_19200] = {.divider = 200U, .multiplier = 0U, .prescale = 1U}, + [E_LIN_BAUDRATE_20000] = {.divider = 416U, .multiplier = 0U, .prescale = 1U}, + }; +#elif SYS_MAIN_CLOCK_DIV == CLOCK_DIV_2 /* 8MHz */ + static const lin_speed_setting_t lins_speed_map[E_LIN_BAUDRATE_MAX] = { + [E_LIN_BAUDRATE_10417] = {.divider = 200U, .multiplier = 0U, .prescale = 1U}, + [E_LIN_BAUDRATE_19200] = {.divider = 200U, .multiplier = 0U, .prescale = 1U}, + [E_LIN_BAUDRATE_20000] = {.divider = 200U, .multiplier = 0U, .prescale = 1U}, + }; +#elif SYS_MAIN_CLOCK_DIV == CLOCK_DIV_4 /* 4MHz */ + static const lin_speed_setting_t lins_speed_map[E_LIN_BAUDRATE_MAX] = { + [E_LIN_BAUDRATE_10417] = {.divider = 200U, .multiplier = 0U, .prescale = 0U}, + [E_LIN_BAUDRATE_19200] = {.divider = 200U, .multiplier = 0U, .prescale = 0U}, + [E_LIN_BAUDRATE_20000] = {.divider = 200U, .multiplier = 0U, .prescale = 0U}, + }; +#else +#error invalid SYS_MAIN_CLOCK_DIV Settings! +#endif + +void lins_SetTiming(LIN_BaudRate_t BaudRate); + + void lins_SetTiming(LIN_BaudRate_t BaudRate) +{ + LINS_SFRS->BTDIVSYNC = lins_speed_map[BaudRate].divider; + LINS_SFRS->BITTIME.PRESCL = (uint8_t)lins_speed_map[BaudRate].prescale; +} + +void LINS_Init(void) +{ + SYSCTRLA_SFRS->DEBUG_ACCESS_KEY.DEBUG_ACCESS_KEY = 0x05U; + SYSCTRLA_SFRS->TRIM_ACCESS_KEY.TRIM_ACCESS_KEY = 0x0E; + SYSCTRLA_SFRS->PMU_ACCESS_KEY.PMU_ACCESS_KEY = 0x0AU; + TRIMHV_SFRS->LINS.LINS_SLEEP = 0U; /* wake up lins when init if sleep */ + +// IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOA] |= 0x1UL << 12;//ext_lins_rxd0 +// IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOA] |= 0x1UL << 16;//ext_lins_txd0 + + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOC] |= 0x1UL << 8; + + TRIMHV_SFRS->LINS.LINS_PU30K_ENA = 1U; + TRIMHV_SFRS->LINS.LINS_RXENA = 1U; + TRIMHV_SFRS->LINS.LINS_PUOFF_TIMEOUT = 1U; + + /* LINS Pullup Disable in dominant TimeOut condition. Set to disable LINS 30K pullup in case that lin bus is + shorted to ground(Bus idle dominant timeout is detected) for saving power. LINS Pullup will be recovered + automatically if bus idle dominant timeout is released by any bus activity. Only reset by power-on sequence. + */ + IOCTRLA_SFRS->LINTXDMONITOR.LINSTXDMONITORENA = 1U; /* LINS TxD Monitor enable */ + +#if LIN_STACK_TYPE == LIN_STACK_TYPE_SAEJ2602 + LINS_SFRS->BUSTIME.BUSINACTIVE = E_LIN_TIME_INACTIVE_SEC_4; +#else + LINS_SFRS->BUSTIME.BUSINACTIVE = E_LIN_TIME_INACTIVE_SEC_6; +#endif +// LINS_SFRS->BUSTIME.WUPREPEAT = E_LIN_TIME_WAKEUP_REPEAT_MS_200; + + LINS_SFRS->CTRL.WORD = 0; + LINS_SFRS->CTRL.RST_INT_ERR = 0x03U; /* reset error,reset interrupt */ + + TRIMHV_SFRS->LINSTRIM.LINS_RX_BIAS_BOOST = 0U; + TRIMHV_SFRS->LINSTRIM.LINS_TX_BIAS_BOOST = HWCFG_GetLINS_TxBiasBoost();// pull down ability + TRIMHV_SFRS->LINSTRIM.LINS_TX_SLOPE = HWCFG_GetLINS_SlewRate(); + TRIMHV_SFRS->LINSTRIM.LINS_TX_DUTY = HWCFG_GetLINS_TxDuty(); + + + lins_SetTiming(E_LIN_BAUDRATE_20000); /* set the maximum supported baud rate */ + /* Enable wakeup detect and IRQ when LINS is in sleep mode(LINS_REG_CTRL.SLEEP = 1U;) */ +// WICA_SFRS->CTRL.LINS_IRQCLR = 1U; + WICA_SFRS->CTRL.LINS_IRQENA = 1U; + WICA_SFRS->CTRL.LINS_ENA = 1U; + WICA_SFRS->CTRL.LINS_WICA_SEL = 0; + + NVIC_EnableIRQ(WULIN_IRQn); + +} + + +void LINS_RegisterLINStack_IRQ(lin_stack_cb_func_t callback,lin_wakeup_cb_func_t wakeupCallback) +{ +#if LIN_STACK_TYPE != LIN_STACK_TYPE_PRIVATE + lin_stack_callback = callback; + lin_wakeup_callback = wakeupCallback; + NVIC_EnableIRQ(LIN_IRQn); +#endif +} + +void LINS_SetSlaveModuleToSleep(void) +{ + TRIMHV_SFRS->LINS.LINS_SLEEP = 0U; +} + + + + +void LIN_Handler(void) +{ +#if LIN_STACK_TYPE == LIN_STACK_TYPE_PRIVATE + LINS_SLAVE_ISR(); +#else + if (lin_stack_callback != NULL){ + lin_stack_callback(); + } +#endif +} + + + +/* Please make sure here and don't delete these functions!!!! or it would cause severe error*/ + +void IOCTRLA_Handler(void) +{ + +} + + +void WULINS_Handler(void) +{ + if (WICA_SFRS->STATUS.LINS != 0U){ + TRIMHV_SFRS->LINS.LINS_SLEEP = 0U;/* wake up lins occurs when wake up signal detected */ + if (lin_wakeup_callback != NULL){ + lin_wakeup_callback(); + } + WICA_SFRS->CTRL.LINS_IRQCLR = 1U; + } +} + +/* Please make sure here and don't delete these functions!!!! or it would cause severe error*/ +/* wakeup timer wake up interrupt ISR */ +void WUTIMER_Handler(void) +{ + WICA_SFRS->CTRL.TIMER_IRQCLR = 1U; +} + + + +#if LIN_STACK_TYPE == LIN_STACK_TYPE_PRIVATE + + + +static LIN_Device_Frame_t *privateFrameTable = NULL; +static uint8_t privateFrameTableCount = 0U; +static ls_DataReqCallback_t dataReceivedCallback = NULL; +static ls_DataRspCallback_t dataRspCallback = NULL; +static ls_SleepReqCallback_t sleepReqCallback = NULL; + +void LINS_RegisterPrivateServices(LIN_Device_Frame_t *frameTable, uint8_t tableSize, const ls_LinsPrivateFramesCallback_t *pFunCallback) +{ + privateFrameTable = frameTable; + privateFrameTableCount = tableSize; + dataReceivedCallback = pFunCallback->dataReqCallback; + dataRspCallback = pFunCallback->dataRspCallback; + sleepReqCallback = pFunCallback->sleepReqCallback; + NVIC_EnableIRQ(LIN_IRQn); +} + + +static __INLINE int8_t isValidFrame(LIN_Device_Frame_t *frameTable, uint8_t frameTableLength,uint8_t id) +{ + int8_t index = -1; + if (frameTable != NULL && id != 0xFFU){ + for (uint8_t i = 0U; i < frameTableLength; i++){ + if (frameTable[i].frame_id == id && frameTable[i].frameIsValid == TRUE){ + index = (int8_t)i; + break; + } + } + } + return index; +} + +static __INLINE void dataReceivedACK(uint8_t dataLength, ChecksumType_t checksumType) +{ + LINS_SFRS->DL.WORD = (uint32_t)dataLength + ((uint32_t)checksumType << LINS_DL_ENHCHK_POS) + (0U << LINS_DL_DISBITMON_POS); + LINS_SFRS->CTRL.DATAACK_TPYE = DATAACK_TPYE_RECEIVE;/* it's a data receive ack operation */ +} + +static __INLINE void dataResponseACK(uint8_t* payload, uint8_t dataLength,ChecksumType_t checksumType) +{ + LINS_SFRS->DL.WORD = (uint32_t)dataLength + ((uint32_t)checksumType << LINS_DL_ENHCHK_POS) + (0U << LINS_DL_DISBITMON_POS); + for (uint8_t i = 0U; i < dataLength; i++){ + LINS_SFRS->DATABUFF[i].DATA = payload[i]; + } + LINS_SFRS->CTRL.DATAACK_TPYE = DATAACK_TPYE_TRANSMIT;/* it's a data transmit ack operation */ +} + + +static void LINS_SLAVE_ISR(void) +{ + static int8_t index = -1; + static uint8_t command = 0; + uint8_t status = (uint8_t)LINS_SFRS->STATUS.WORD; + + if ((status & E_LIN_STATUS_DATA_REQ) != 0U){ + command = LINS_SFRS->ID; + index = isValidFrame(privateFrameTable, privateFrameTableCount,command); + if (index >= 0){ + if (privateFrameTable[index].msg_type == (uint8_t)LIN_MSG_TYPE_RX){ + dataReceivedACK(privateFrameTable[index].length, (ChecksumType_t)privateFrameTable[index].checksum); + }else{ + if (dataRspCallback != NULL){ + dataRspCallback(&privateFrameTable[index]);// feed data based on FID + } + dataResponseACK(privateFrameTable[index].data, privateFrameTable[index].length,(ChecksumType_t)privateFrameTable[index].checksum); + } + }else{ + LINS_SFRS->CTRL.STOP = 1U; + } + }else if ((status & E_LIN_STATUS_COMPLETE) != 0U){ + if (LINS_SFRS->TX_STATUS.COMPLETETX == 0U){ /*receive finished */ + if (index >= 0){ + for (uint8_t i = 0U; i < LIN_BUFF_SIZE; i++){ + privateFrameTable[index].data[i] = LINS_SFRS->DATABUFF[i].DATA; + } + if (dataReceivedCallback != NULL){ + dataReceivedCallback(&privateFrameTable[index]); + } + } + } + }else if ((status & E_LIN_STATUS_IDLE_TIMEOUT) != 0U){ + if (sleepReqCallback != NULL){ + sleepReqCallback(); + } + }else if ((status & E_LIN_STATUS_ERROR) != 0U){ + /*intent to empty*/ + }else{ + /*intent to empty*/ + } + LINS_SFRS->CTRL.RST_INT_ERR = 0x03U; /*reset error,reset interrupt */ +} + + +#endif + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/87400/drivers/hal/src/math_div_device.c b/87400/drivers/hal/src/math_div_device.c new file mode 100644 index 0000000..29f9a59 --- /dev/null +++ b/87400/drivers/hal/src/math_div_device.c @@ -0,0 +1,3 @@ +#include + + diff --git a/87400/drivers/hal/src/pmu_device.c b/87400/drivers/hal/src/pmu_device.c new file mode 100644 index 0000000..a60db75 --- /dev/null +++ b/87400/drivers/hal/src/pmu_device.c @@ -0,0 +1,203 @@ +/** + * @copyright 2017 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file pmu_device.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static __INLINE void WDTA_Start(void); + +void BOR_Handler(void) +{ + +} + +void PMU_BORInit(Bor1V5Thres_t lowThreshold, Bor3V3Thres_t highThreshold) +{ + TRIMHV_SFRS->PMUTRIM.TRIM_VREF_BUF = HWCFG_GetBGBUFFCalibValue(); + + TRIMHV_SFRS->PMUTRIM.VDD3V3_LDO_TRIM = HWCFG_Get3V3CalibValue(); + TRIMHV_SFRS->PMUTRIM.OCP_CTRL_3V3 = HWCFG_Get3V3_OCPValue(); + TRIMHV_SFRS->PMUTRIM.VDD1V5_LDO_TRIM = HWCFG_Get1V5_CalibValue(); + TRIMHV_SFRS->PMUTRIM.OCP_CTRL_1V5 = HWCFG_Get1V5_OCPValue(); + + + TRIMHV_SFRS->BORCONFIG.S_BOR_1P5V = (uint8_t)lowThreshold; + TRIMHV_SFRS->BORCONFIG.S_BOR_3P3V = (uint8_t)highThreshold; + TRIMHV_SFRS->BORACTION.VDD1V5 = (uint8_t)PMU_BROWNOUT_RESET; + TRIMHV_SFRS->BORACTION.VDD3V3 = (uint8_t)PMU_BROWNOUT_RESET; + + TRIMHV_SFRS->BORACTION.BOR_1V5_LOCK = 1U; + TRIMHV_SFRS->BORACTION.BOR_3V3_LOCK = 1U; + TRIMHV_SFRS->OVTEMPCONFIG.TEMPSENSE_EN = 1U; /* enable temperature sensor */ + EVTHOLD_SFRS->HOLD = 0U; /* clear Lullaby_Handler after wake up */ + + +} + +void PMU_WakeTimerInit(PMU_WAKEUP_TIMEER_MODE_t mode, PMU_WAKEUP_TIMEER_Interval_t interval) +{ + if (mode == WAKEUP_TIMEER_DISABLE){ + WICA_SFRS->CTRL.TIMER_ENA = 0U; + }else{ + WICA_SFRS->CTRL.TIMER_TAPSEL = (uint8_t)interval; + WICA_SFRS->CTRL.TIMER_ENA = 1U; + } +} + +void PMU_EnterDeepSleepMode(void) +{ + CRGA_SFRS->MODULERSTREQ |= MODUE_SOFT_RESET_PWM; + /* Add GPIO function here for low power mode*/ + /* set gpios to input with power up resistor */ +// for (uint8_t i = (uint8_t)GPIO_INIT_PORT_1; i<= (uint8_t)GPIO_INIT_PORT_4; i++ ){ +// GPIO_Init((GpioInitPort_t)i,GPIO_MUX_GPIO,GPIO_DIR_INPUT,GPIO_PULL_UP); +// } + /* end of GPIO settigns */ + TRIMHV_SFRS->OVTEMPCONFIG.TEMPSENSE_EN = 0U; /* disbale temperature sensor when sleep */ + CRGA_SFRS->OVTEMPACTION.OVERTEMP_EN = 0U; + TRIMHV_SFRS->VBATTRIM.BAT_UV_EN = 0U; + TRIMHV_SFRS->VBATTRIM.BAT_OV_EN = 0U; + + +// SYSCTRLA_REG_PMU_ACCESS_KEY.PMU_ACCESS_KEY = 0x0A; +// PMUA_SFRS->CTRL.PD1V5_ENA_HIBERNATE = 1U; + + /*IOCTRLA_SFRS->LINSGFCONF.LINSRXGF3RD_ENA = 0U;*/ + /* clear all of wake up flags */ + /* Enable wakeup detect and IRQ when LINS is in sleep mode(LINS_REG_CTRL.SLEEP = 1U;) */ + WICA_SFRS->CTRL.LINS_IRQCLR = 1U; + WICA_SFRS->CTRL.LINS_IRQENA = 1U; + WICA_SFRS->CTRL.LINS_ENA = 1U; + WICA_SFRS->CTRL.LINS_IRQENA = 1U; + + NVIC_EnableIRQ(WULIN_IRQn); + NVIC_EnableIRQ(Lullaby_IRQn); /* Enable Lullaby interrupt*/ + EVTHOLD_SFRS->HOLD = 1U; /* Trigger ISR then entering sleep in ISR */ + /* Waiting to enter sleep mode */ + for(;;){ + } +} + +/* Please make sure here and don't delete these functions!!!! or it would cause severe error*/ +/* hibernate wake up interrupt ISR */ +void Lullaby_Handler(void) +{ + /* Set lin to sleep mode */ + if (TRIMHV_SFRS->LINS.LINS_SLEEP == 1U){ + TRIMHV_SFRS->LINS.LINS_SLEEP = 0U; + } + TRIMHV_SFRS->LINS.LINS_SLEEP = 1U; + /* Enter sleep mode */ + PMUA_SFRS->CTRL.HIBERNATE = 1U; +} + +#pragma optimize=none +static __INLINE void WDTA_Start(void) +{ + CRGA_SFRS->WDTACTION.WDTBARKCNTCLR = 1U; + WDTA_SFRS->CTRL.TIMEOUTSEL = (uint8_t)WDTA_INTERVAL_9216MS; + WDTA_SFRS->CLEAR = 0x3c574ad6U; + WDTA_SFRS->STOPR.STOP = 0U;/* start wdt*/ +} + + +void NMI_Handler(void) +{ + + uint32_t temp = FLASH_SFRS->FLSECCR.ADDRECC; + FLASH_SFRS->FLSECCR.ECCD = 1; + FLASH_SFRS->FLSECCR.ECCC = 1; + + SYSCFG_SFRS->SRAMCFGR.SRAMECCD = 1; + SYSCFG_SFRS->SRAMCFGR.SRAMECCC = 1; + + for(;;){} + +} + + +void HardFault_Handler(void) +{ + WDTA_Start(); + for(;;){} +} + +void SVC_Handler(void) +{ + WDTA_Start(); + for(;;){} +} + +void PendSV_Handler(void) +{ + WDTA_Start(); + for(;;){} +} + + +void MemManage_Handler(void) +{ + +} + +void BusFault_Handler(void) +{ + +} + +void UsageFault_Handler(void) +{ + +} + + +void Divider_Handler(void) +{ + +} + +void FlashEcc_Handler(void) +{ + +} + +void RamEcc_Handler(void) +{ + +} + + +void CR_Handler(void) +{ + +} + + +void CSA_OCP_Handler(void) +{ + +} + +void error(void) +{ + +} + diff --git a/87400/drivers/hal/src/pwm_aux_device.c b/87400/drivers/hal/src/pwm_aux_device.c new file mode 100644 index 0000000..153578a --- /dev/null +++ b/87400/drivers/hal/src/pwm_aux_device.c @@ -0,0 +1,77 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file pwmAux_device.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/03/18 + */ + +#include +#include +#include + + +static PwmAuxIsrCallback_t pwmAuxReloadCallback[2] = {NULL,NULL}; + + +void PWM_AUX_Handler(void) +{ + uint8_t status = PWM_AUX_SFRS->INTPERIOD.STATUS.PERIOD; + + if ((status & (1U << (uint8_t)PWMAUX_BASE_0)) == (1U << (uint8_t)PWMAUX_BASE_0)){ + if (pwmAuxReloadCallback[(uint8_t)PWMAUX_BASE_0]!= NULL){ + pwmAuxReloadCallback[(uint8_t)PWMAUX_BASE_0](); + } + PWM_AUX_SFRS->INTPERIOD.CLEAR.PERIOD = (1U << (uint8_t)PWMAUX_BASE_0); + } + + if ((status & (1U << (uint8_t)PWMAUX_BASE_1)) == (1U << (uint8_t)PWMAUX_BASE_1)){ + if (pwmAuxReloadCallback[(uint8_t)PWMAUX_BASE_1]!= NULL){ + pwmAuxReloadCallback[(uint8_t)PWMAUX_BASE_1](); + } + PWM_AUX_SFRS->INTPERIOD.CLEAR.PERIOD = (1U << (uint8_t)PWMAUX_BASE_1); + } +} + +void PWMAUX_Init(PwmAuxChannel_t channel,PWMAUX_ClockSource_t source,PWMAUX_Prescaler_t divider,uint16_t peroid) +{ + PWM_AUX_SFRS->PWM_AUX[(uint8_t)source].BASE.PRESCALESEL = (uint8_t)divider; + PWM_AUX_SFRS->PWM_AUX[(uint8_t)source].BASE.PERIOD = peroid; + uint8_t temp = PWM_AUX_SFRS->BASE_SEL; + temp = temp & (~(1U << (uint8_t)channel)); + temp |= (uint8_t)source << (uint8_t)channel; /* channel connected to which clock source */ + PWM_AUX_SFRS->BASE_SEL = temp; + PWM_AUX_SFRS->ENAREQ.ENAREQ |= 1U << (uint8_t)channel; /* enable PWM channel:0-4 */ +} + + +void PWMAUX_RegisterReloadIRQ(PWMAUX_ClockSource_t source, PwmAuxIsrCallback_t callback) +{ + PWM_AUX_SFRS->INTPERIOD.CLEAR.PERIOD = 1U << (uint8_t)source; + PWM_AUX_SFRS->INTPERIOD.ENABLE.PERIOD |= 1U << (uint8_t)source; + pwmAuxReloadCallback[(uint8_t)source] = callback; + NVIC_EnableIRQ(PWM_AUX_IRQn); +} + +void PWMAUX_UnRegisterReloadIRQ(PWMAUX_ClockSource_t source) +{ + PWM_AUX_SFRS->INTPERIOD.CLEAR.PERIOD = 1U << (uint8_t)source; + PWM_AUX_SFRS->INTPERIOD.ENABLE.PERIOD &= ~(1U << (uint8_t)source); + pwmAuxReloadCallback[(uint8_t)source] = NULL; + NVIC_DisableIRQ(PWM_AUX_IRQn); +} + + +void PWMAUX_SetMatchValue(PwmAuxChannel_t channel, uint16_t matchRisingValue, uint16_t matchFaillValue) +{ + PWM_AUX_SFRS->PULSE[((uint8_t)channel)].WORD = (uint32_t)matchFaillValue + ((uint32_t)matchRisingValue << 16); + PWM_AUX_SFRS->UPDATE = 0x03U; +} + + diff --git a/87400/drivers/hal/src/pwm_device.c b/87400/drivers/hal/src/pwm_device.c new file mode 100644 index 0000000..0caa1b3 --- /dev/null +++ b/87400/drivers/hal/src/pwm_device.c @@ -0,0 +1,231 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file pwm_device.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void PWM_INTOL0_Handler(void) +{ + +} + +void PWM_INTOL1_Handler(void) +{ + +} + +void PWM_INTOL2_Handler(void) +{ + +} + +void PWM_INTOL3_Handler(void) +{ + + +} + +void PWM_Init(GpioGroup_t group,GpioPort_t port,PWM_CH_t channel,PWM_ClockSource_t source,PWM_Prescaler_t divider,uint16_t peroid) +{ + /* IO configuration */ + + switch(channel) + { + case PWM_CH0_0: + if(group==GROUP_GPIOB){ + if(port==GPIO_PORT_0){ + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOB] |= (uint32_t)0x03U; // PB0 0x3: PWM0_0. + }else if(port==GPIO_PORT_5){ + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOB] |= (uint32_t)0x02U << 20U; // PB5 0x2: PWM0_0. + }else{ + + } + }else if(group==GROUP_GPIOC){ + if(port==GPIO_PORT_0){ + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOC] |= (uint32_t)0x03U; // PC0 0x3: PWM0_0. + } + }else{ + + } + break; + case PWM_CH0_1: + if(group==GROUP_GPIOB){ + if(port==GPIO_PORT_6 || port==GPIO_PORT_7){ + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOB] |= (uint32_t)0x02<<((uint8_t)port * 4U); // PB6/PB7 0x2: PWM0_1. + } + }else if(group==GROUP_GPIOC){ + if(port==GPIO_PORT_1){ + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOC] |= (uint32_t)0x02<<((uint8_t)port * 4U); // PC1 0x2: PWM0_1. + } + }else{ + + } + break; + case PWM_CH1_0: + if(group==GROUP_GPIOB){ + if(port==GPIO_PORT_1){ + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOB] |= (uint32_t)0x03<<((uint8_t)port * 4U); // PB1 0x3: PWM1_0. + } + }else if(group==GROUP_GPIOC){ + if(port==GPIO_PORT_3){ + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOC] |= (uint32_t)0x02<<((uint8_t)port * 4U); // PC3 0x2: PWM1_0. + } + }else{ + + } + break; + case PWM_CH1_1: + if(group==GROUP_GPIOC){ + if(port==GPIO_PORT_4){ + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOC] |= (uint32_t)0x02<<((uint8_t)port * 4U); // PC4 0x2: PWM1_1. + } + } + break; + case PWM_CH2_0: + if(group==GROUP_GPIOB){ + if(port==GPIO_PORT_1){ + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOB] |= (uint32_t)0x02<<((uint8_t)port * 4U); // PB1 0x2: PWM2_0. + }else if(port==GPIO_PORT_2){ + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOB] |= (uint32_t)0x03<<((uint8_t)port * 4U); // PB2 0x3: PWM2_0. + }else{ + + } + } + break; + case PWM_CH2_1: + if(group==GROUP_GPIOB){ + if(port==GPIO_PORT_2){ + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOB] |= (uint32_t)0x02<<((uint8_t)port * 4U); // PB2 0x2: PWM2_1. + } + } + break; + case PWM_CH3_0: + if(group==GROUP_GPIOB){ + if(port==GPIO_PORT_3){ + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOB] |= (uint32_t)0x02<<((uint8_t)port * 4U); // PB3 0x2: PWM3_0. + } + } + break; + case PWM_CH3_1: + if(group==GROUP_GPIOB){ + if(port==GPIO_PORT_4){ + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOB] |= (uint32_t)0x02<<((uint8_t)port * 4U); // PB4 0x2: PWM3_1. + } + } + break; + default: + break; + } + + IOCTRLA_SFRS->CTRL_MODE[(uint8_t)group].PU &= ~(1U << (uint8_t)port); + IOCTRLA_SFRS->CTRL_MODE[(uint8_t)group].PD &= ~(1U << (uint8_t)port); + IOCTRLA_SFRS->CTRL_MODE[(uint8_t)group].RE |= (1U << (uint8_t)port); + + if (group == GROUP_GPIOA){ + GPIO_SFRS->GPIOA[port].DIR = (uint8_t)GPIO_DIR_OUTPUT; + }else if(group == GROUP_GPIOB){ + GPIO_SFRS->GPIOB[port].DIR = (uint8_t)GPIO_DIR_OUTPUT; + }else{ + GPIO_SFRS->GPIOC[port].DIR = (uint8_t)GPIO_DIR_OUTPUT; + } + + if(source == PWM_BASE_0){ + PWM_SFRS->PT0PERIOD = peroid; + PWM_SFRS->CTRL1R.PT0PRES = (uint8_t)divider; + }else{ + PWM_SFRS->PT1PERIOD = peroid; + PWM_SFRS->CTRL1R.PT1PRES = (uint8_t)divider; + } +} + +void PWM_SetMatchValue(PWM_ClockSource_t source,PWM_Pulse_t pulse,uint16_t matchRisingValue, uint16_t matchFaillValue) +{ + PWM_SFRS->MODCTRLR.MCEN = 0;//0x1: ENABLED: The modulation of the corresponding output signal by the multi-channel pattern according to bit field MCPTN is enabled + PWM_SFRS->MODCTRLR.CCXMODEN = 0XFF;//0x1: ENABLED: The modulation of the corresponding output signal by CC0~3 pattern is enabled + + PWM_SFRS->MCOUTR.MCUPR= 1;//0x1: By_software: Bit field MCPTN is updated by MCPTNS immediately + PWM_SFRS->MCOUTR.MCPTNS = 0XFF; + + if(source == PWM_BASE_0){ + PWM_SFRS->CTRL0R.PT0RC = 1U;//0x1: PT0R is cleared, PT0 stops counting + }else{ + PWM_SFRS->CTRL0R.PT1RC = 1U;//0x1: PT0R is cleared, PT0 stops counting + } + + if(pulse == PULSE_0){ + PWM_SFRS->PULSE0R.PRISE0 = matchRisingValue; + PWM_SFRS->PULSE0R.PFALL0 = matchFaillValue; + }else if(pulse == PULSE_1){ + PWM_SFRS->PULSE1R.PRISE1 = matchRisingValue; + PWM_SFRS->PULSE1R.PFALL1 = matchFaillValue; + }else if(pulse == PULSE_2){ + PWM_SFRS->PULSE2R.PRISE2 = matchRisingValue; + PWM_SFRS->PULSE2R.PFALL2 = matchFaillValue; + }else if(pulse == PULSE_3){ + PWM_SFRS->PULSE3R.PRISE3 = matchRisingValue; + PWM_SFRS->PULSE3R.PFALL3 = matchFaillValue; + }else{ + + } + if(source == PWM_BASE_0){ + PWM_SFRS->CTRL0R.PT0UPES = 1;//0x1: PT0UPE is set, enabling update + PWM_SFRS->CTRL0R.PT0RS = 1;//0x1: PT0R is set, PT0 start counting + }else{ + PWM_SFRS->CTRL0R.PT1UPES = 1;//0x1: PT0UPE is set, enabling update + PWM_SFRS->CTRL0R.PT1RS = 1;//0x1: PT0R is set, PT0 start counting + } + +} + +void PWM_Listofotherparameters_Init(void) +{ + PWM_SFRS->CTRL1R.CC1CNTS = 0; + PWM_SFRS->CTRL1R.CC2CNTS = 0; + PWM_SFRS->CTRL1R.CC3CNTS = 0; + PWM_SFRS->CTRL1R.PT0MODE = 0;//0x0: Edge_aligned_mode: + + PWM_SFRS->DTCR.CCXDTE = 0;//0x0: DISABLED: Dead-time generation is disabled. + PWM_SFRS->DTCR.PT1DT = 0; + PWM_SFRS->DTCR.PT0DT = 0; + + PWM_SFRS->CHREMAPR.PWM0RMP = 0;//0x0: Select CC0 + PWM_SFRS->CHREMAPR.PWM1RMP = 0;//0x0: Select CC0 + PWM_SFRS->CHREMAPR.PWM2RMP = 0;//0x0: Select CC0 + PWM_SFRS->CHREMAPR.PWM3RMP = 0;//0x0: Select CC0 + + PWM_SFRS->CMPSTATR.CC00PS = 0;//0x0: CC0_0 drives passive level while CC0CS is 0, i.e. driven by CC0CS + PWM_SFRS->CMPSTATR.CC01PS = 0; + PWM_SFRS->CMPSTATR.CC10PS = 0;//0x0: CC1_0 drives passive level while CC0CS is 0, i.e. driven by CC0CS + PWM_SFRS->CMPSTATR.CC11PS = 0; + PWM_SFRS->CMPSTATR.CC20PS = 0;//0x0: CC2_0 drives passive level while CC0CS is 0, i.e. driven by CC0CS + PWM_SFRS->CMPSTATR.CC21PS = 0; + PWM_SFRS->CMPSTATR.CC30PS = 0;//0x0: CC3_0 drives passive level while CC0CS is 0, i.e. driven by CC0CS + PWM_SFRS->CMPSTATR.CC31PS = 0; + + PWM_SFRS->PSL = 0X0;//0x0: Level_0: The passive level is 0 + + PWM_SFRS->MODCTRLR.MCEN = 0;//0x1: ENABLED: The modulation of the corresponding output signal by the multi-channel pattern according to bit field MCPTN is enabled + PWM_SFRS->MODCTRLR.CCXMODEN = 0XFF;//0x1: ENABLED: The modulation of the corresponding output signal by CC0~3 pattern is enabled + + PWM_SFRS->MCOUTR.MCUPR= 1;//0x1: By_software: Bit field MCPTN is updated by MCPTNS immediately + PWM_SFRS->MCOUTR.MCPTNS = 0XFF; +} diff --git a/87400/drivers/hal/src/spi_device.c b/87400/drivers/hal/src/spi_device.c new file mode 100644 index 0000000..80afb8e --- /dev/null +++ b/87400/drivers/hal/src/spi_device.c @@ -0,0 +1,114 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file spi_device.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/03/18 + */ + +#include +#include +#include +#include +#include + + +//PA3-MISO +//PA4-MOSI +//PA5-SCK +//PA6-CS + +int8_t SPI_Init(SpiClkDevider_t devider) +{ + GPIO_Init(GROUP_GPIOA, GPIO_PORT_3,GPIO_DIR_INPUT,GPIO_PULL_NONE); + GPIO_Init(GROUP_GPIOA, GPIO_PORT_4,GPIO_DIR_OUTPUT,GPIO_PULL_NONE); + GPIO_Init(GROUP_GPIOA, GPIO_PORT_5,GPIO_DIR_OUTPUT,GPIO_PULL_NONE); + GPIO_Init(GROUP_GPIOA, GPIO_PORT_6,GPIO_DIR_OUTPUT,GPIO_PULL_NONE); + + IOCTRLA_SFRS->PORT_GROUP_MUX[0] &= (~((0x0FU)<<(4U*3U))); + IOCTRLA_SFRS->PORT_GROUP_MUX[0] |= ((0x03U)<<(4U*3U)); + + IOCTRLA_SFRS->PORT_GROUP_MUX[0] &= (~((0x0FU)<<(4U*4U))); + IOCTRLA_SFRS->PORT_GROUP_MUX[0] |= ((0x03U)<<(4U*4U)); + + IOCTRLA_SFRS->PORT_GROUP_MUX[0] &= (~((0x0FU)<<(4U*5U))); + IOCTRLA_SFRS->PORT_GROUP_MUX[0] |= ((0x03U)<<(4U*5U)); + + IOCTRLA_SFRS->PORT_GROUP_MUX[0] &= (~((0x0FU)<<(4U*6U))); + IOCTRLA_SFRS->PORT_GROUP_MUX[0] |= ((0x03U)<<(4U*6U)); + + SPI_SFRS->SPICTRL.FIFOSOFTRESET = 1U; + SPI_SFRS->SPICTRL.CPOL = 1U; + SPI_SFRS->SPICTRL.CPHA = 0U; + SPI_SFRS->SPICTRL.LPBK = 0U; + SPI_SFRS->SPICTRL.SCKEXT = ((uint8_t)devider >> 2); + SPI_SFRS->SPICTRL.SPR = (uint8_t)devider &0x03U; + SPI_SFRS->SPICTRL.ENA_REQ = 1U; + return 0; +} + + +/*#pragma optimize=none*/ +int8_t SPI_SendBuff(uint8_t * const buff, uint16_t length) +{ + uint8_t data = 0U; + SPI_SFRS->SPICTRL.FIFOSOFTRESET = 1U; + for (uint16_t i = 0U; i < length; i++){ + SPI_SFRS->TXDATA = buff[i]; + while(SPI_SFRS->SPISTATUS.RXFIFOEMPTY == 1U){}/* waiting for rx completed*/ + data = SPI_SFRS->RXDATA; + + } + return (int8_t)data; +} + +int8_t SPI_ReadBuff(uint8_t * const buff, uint16_t length) +{ + SPI_SFRS->SPICTRL.FIFOSOFTRESET = 1U; + for (uint16_t i = 0; i < length; i++){ + SPI_SFRS->TXDATA = buff[i]; + while(SPI_SFRS->SPISTATUS.RXFIFOEMPTY == 1U){}/* waiting for rx completed */ + buff[i] = SPI_SFRS->RXDATA; + } + return 0; +} + + + +uint8_t SPI_ReadWriteOneByte(uint8_t data) +{ + uint8_t temp; + + /* Send data */ + SPI_SFRS->TXDATA = data; + /*wait TXFIFO empty*/ + while(SPI_SFRS->SPISTATUS.TXFIFOEMPTY==0U){} + /*wait RXFIFO not empty */ + while(SPI_SFRS->SPISTATUS.RXFIFOEMPTY==1U){} + /*read data*/ + temp = SPI_SFRS->RXDATA; + + return temp; +} + +void SPI_Handler(void) +{ + if( SPI_SFRS->SPIINTSTATUS.INTTXFIFOOF == 1U) + { + SPI_SFRS->SPIINTCLEAR.INTTXFIFOOFCLR = 1U; + } + if( SPI_SFRS->SPIINTSTATUS.INTRXFIFOUF == 1U) + { + SPI_SFRS->SPIINTCLEAR.INTRXFIFOUFCLR = 1U; + } + if( SPI_SFRS->SPIINTSTATUS.INTXFERCNT == 1U) + { + SPI_SFRS->SPIINTCLEAR.INTXFERCNTCLR = 1U; + } +} \ No newline at end of file diff --git a/87400/drivers/hal/src/systick_device.c b/87400/drivers/hal/src/systick_device.c new file mode 100644 index 0000000..a2a7038 --- /dev/null +++ b/87400/drivers/hal/src/systick_device.c @@ -0,0 +1,52 @@ +/** + * @copyright 2016 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file systick_device.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ + +#include +#include "errno.h" +#include +#include "systick_sfrs.h" +#include "systick_device.h" +#include "clock_device.h" +#include + +static sysTick_cb_func_t sysTickCallback = NULL; + +void SysTick_Handler(void) +{ + if (sysTickCallback != NULL){ + sysTickCallback(); + } +} + +void SysTick_Init(uint32_t ticks, sysTick_cb_func_t callback) +{ + SysTick->VAL = 0U; + SysTick->LOAD = ticks; + sysTickCallback = callback; + SysTick->CTRL |= (SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk); +} + +uint32_t SysTick_GetCount(void) +{ + uint32_t count = SysTick->VAL; + return count; +} + +uint32_t SysTick_GetLoad(void) +{ + uint32_t count = SysTick->LOAD; + return count; +} + + diff --git a/87400/drivers/hal/src/uart_device.c b/87400/drivers/hal/src/uart_device.c new file mode 100644 index 0000000..c56f8a0 --- /dev/null +++ b/87400/drivers/hal/src/uart_device.c @@ -0,0 +1,111 @@ +#include +#include +#include + +static uartRx_cb_func_t uartRxDataCallback; +static uint8_t rxBuff[RX_BUFF_SIZE]; + +int8_t UART_Init(uint32_t baudRate, BitSize_t bitSize, Parity_t parity,StopBits_t stopBits) +{ + int8_t result = 0; + + uint16_t baudRateDiv; + + /*PA4 mode2 UART_TX*/ + IOCTRLA_SFRS->PORT_GROUP_MUX[0] &= (~((0x0FU)<<(4U*4U))); + IOCTRLA_SFRS->PORT_GROUP_MUX[0] |= ((0x02U)<<(4U*4U)); + GPIO_SFRS->GPIOA[4].DIR = 1U; + /*PA5 mode2 UART_RX*/ + IOCTRLA_SFRS->PORT_GROUP_MUX[0] &= (~((0x0FU)<<(4U*5U))); + IOCTRLA_SFRS->PORT_GROUP_MUX[0] |= ((0x02U)<<(4U*5U)); + /*IOCTRLA_SFRS->PORT_GROUP_MUX[0] |= ((0x1)<<(4*5));*/ + GPIO_SFRS->GPIOA[5].DIR = 0U; + + baudRateDiv = (uint16_t)(16000000U*8U/(16U*baudRate)-8U); + UART0_SFRS->UARTBAUD.OSR = 16U; + UART0_SFRS->UARTBAUD.BAUDDIV = (uint8_t)(baudRateDiv/8U); + UART0_SFRS->UARTBAUD.FDIV = (uint8_t)(baudRateDiv%8U); + + UART0_SFRS->MSGCTRL.SIZE = (uint8_t)bitSize; + UART0_SFRS->MSGCTRL.STOP = (uint8_t)stopBits; + UART0_SFRS->MSGCTRL.PARITY = (uint8_t)parity; + UART0_SFRS->MSGCTRL.ENABLE = 1U; + + return result; +} + + +void UART0_Handler(void) +{ + if (uartRxDataCallback != NULL){ + uint8_t statusRXM = UART0_SFRS->UARTINT.IRQ.RXMULTDONE; + uint8_t statusRXT = UART0_SFRS->UARTINT2.IRQ.RXTOUT; + if ( (statusRXM != 0U) || (statusRXT != 0U) ){ + uint8_t length = UART0_SFRS->UARTFIFO.RXCOUNT; + for (uint8_t i = 0; i < length; i++){ + rxBuff[i] = UART0_SFRS->DATA.BYTE; + } + UART0_SFRS->UARTINT.CLEAR.BYTE = 0xFFU; + UART0_SFRS->UARTINT2.CLEAR.RXTOUT = 1U; + UART0_SFRS->MSGCTRL.RXXFERCNTCLR = 1U; /* clear fifo buff counter to 0 */ + uartRxDataCallback(rxBuff,length); + } + } + +} + + +void UART_RegisterIRQ(uartRx_cb_func_t rxDowncallback) +{ + /* FIFO reset */ + UART0_SFRS->MSGCTRL.UFIFOSOFTRESET = 1U; + /* multi-Rx settings */ + uartRxDataCallback = rxDowncallback; + UART0_SFRS->MSGCTRL.RXXFERCNTCLR = 1U; + UART0_SFRS->UARTINT.CLEAR.RXMULTDONE = 1; + UART0_SFRS->UARTFIFO.RXMULTIPLEXFERDONECNT = 16; + UART0_SFRS->UARTINT.ENABLE.RXMULTDONE = 1U; + + /* Received timeout settings */ + UART0_SFRS->UARTINT2.CLEAR.RXTOUT = 1U; + UART0_SFRS->UARTINT2.ENABLE.RXTOUT = 1U; + + NVIC_EnableIRQ((IRQn_Type)((int32_t)UART0_IRQn)); + +} + +void UART_UnRegisterIRQ(void) +{ + uartRxDataCallback = NULL; + UART0_SFRS->UARTINT.CLEAR.RXDONE = 1U; + NVIC_DisableIRQ((IRQn_Type)((int32_t)UART0_IRQn)); +} + + +int8_t UART_SendBuff(uint8_t *buff, uint16_t length) +{ + int8_t result = 0; + + for (uint8_t i = 0U; i < length; i++){ + UART0_SFRS->DATA.BYTE = buff[i]; + while(UART0_SFRS->UARTINT.STATUS.TXDONE == 0U){} + UART0_SFRS->UARTINT.CLEAR.TXDONE = 1U; + } + + return result; +} + +uint8_t UART_ReadByte(void) +{ + uint8_t temp; + + /* wait rx done */ + while(UART0_SFRS->UARTINT.STATUS.RXDONE == 0U){} + + /* read data */ + temp = UART0_SFRS->DATA.BYTE; + UART0_SFRS->UARTINT.CLEAR.RXDONE = 1U; + + return temp; + +} \ No newline at end of file diff --git a/87400/drivers/hal/src/wdt_device.c b/87400/drivers/hal/src/wdt_device.c new file mode 100644 index 0000000..2b055e2 --- /dev/null +++ b/87400/drivers/hal/src/wdt_device.c @@ -0,0 +1,77 @@ +/** + * @copyright 2017 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file wdt_device.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ + +#include +#include +#include "wdt_device.h" +#include "errno.h" +#include +/** + * @brief The instance of WDT device + */ + +void WatchdogA_Handler(void) +{ + +} + +void WDTA_Enable(WDTAInterval_t interval) +{ + WDTA_SFRS->CTRL.TIMEOUTSEL = (uint8_t)interval; + CRGA_SFRS->WDTACTION.WDTBARKCNT = 5; + WDTA_SFRS->CTRL.UPDATE = 1U; + WDTA_SFRS->CLEAR = 0x3c574ad6U; + WDTA_SFRS->STOPR.STOP = 0U;/* start wdt*/ + +} + +void WDTA_Disable(void) +{ + WDTA_SFRS->STOPR.STOP = 0xC3U;/* stop wdt*/ +} + +void WDTA_Clear(void) +{ + WDTA_SFRS->CLEAR = 0x3c574ad6U; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/87400/drivers/hdf/meta.h b/87400/drivers/hdf/meta.h new file mode 100644 index 0000000..ce1ccd0 --- /dev/null +++ b/87400/drivers/hdf/meta.h @@ -0,0 +1,66 @@ +#ifndef META_H__ +#define META_H__ + +// declare an enumerated type that can be used to refer to interrupts by name, e.g. in calls to the NVIC configuration +// functions - the definitions here must match the vector table positions, offset so that IRQ0 (the 1st ASIC IRQ) has +// the value 0... +// +typedef enum IRQn +{ + // Cortex-M0 core exceptions... + Reset_IRQn = -15, + NMI_IRQn = -14, + HardFault_IRQn = -13, + SVC_IRQn = -5, + PendSV_IRQn = -2, + SysTick_IRQn = -1, + // ASIC-specific IRQs... (should match the vector defined in dig_meta_top.sv) + IOCTRLA_IRQn = 0, + OVTEMP_IRQn = 1, + GPIO_IRQn = 2, + PWM_AUX_IRQn = 3, + GT4_5_IRQn = 4, + WUTIMER_IRQn = 5, + WatchdogA_IRQn = 6, + ADC_IRQn = 7, + SPI_IRQn = 8, + WULIN_IRQn = 9, + UART0_IRQn = 10, + DIV_IRQn = 11, + LIN_IRQn = 12, + FLASH_IRQn = 13, + SRAM_ECCC_IQn = 14, + GT1_IRQn = 15, + GT2_IRQn = 16, + GT3_IRQn = 17, + CT2_IRQn = 18, + CT3_IRQn = 19, + CT4_IRQn = 20, + CT5_IRQn = 21, + CT6_IRQn = 22, + CR_IRQn = 23, + PWM_INTOL0_IRQn = 24, + PWM_INTOL1_IRQn = 25, + PWM_INTOL2_IRQn = 26, + PWM_INTOL3_IRQn = 27, + BOR_IRQn = 28, + UV_OV_IRQn = 29, + CSP_OCP_IRQn = 30, + Lullaby_IRQn = 31 + +} IRQn_Type; +// +// and define a tell-tale macro that will prevent the clough.h header from attempting to re-define this with the +// default (non-ASIC-specific) version... +// +#define __IRQn_Type + +#define TRUE (1U) +#define FALSE (0U) + +#include +#include "sfrs/meta_sfr.h" +#include "verne.h" + +#endif + diff --git a/87400/drivers/hdf/sfrs/crc_sfr.h b/87400/drivers/hdf/sfrs/crc_sfr.h new file mode 100644 index 0000000..34f9dda --- /dev/null +++ b/87400/drivers/hdf/sfrs/crc_sfr.h @@ -0,0 +1,94 @@ +/** + * @copyright 2023 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file crc_sfr.h + */ + +#ifndef CRC_SFR_H__ +#define CRC_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for CRC. + */ +typedef struct { + + union { + struct { + uint8_t CRCDATA0 : 8; /*!< CRC data bits */ + uint8_t CRCDATA1 : 8; /*!< CRC data bits */ + uint8_t CRCDATA2 : 8; /*!< CRC data bits */ + uint8_t CRCDATA3 : 8; /*!< CRC data bits */ + }; + uint32_t WORD; + } CRCDR; /* +0x000 */ + + uint32_t CRCINIT; /*CRC initial value +0x004 */ + + union { + struct { + uint8_t REVIN : 2; /*!< Reverse input data */ + uint8_t REVOUT : 1; /*!< Reverse output data */ + uint8_t : 5; /* (reserved) */ + uint32_t : 24; /* (reserved) */ + }; + uint32_t WORD; + } CRCCR; /* +0x008 */ + +} CRC_SFRS_t; + +/* -------- End of section using anonymous unions and disabling warnings -------- */ +#if defined (__CC_ARM) + #pragma pop +#elif defined (__ICCARM__) + /* leave anonymous unions enabled */ +#elif (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of CRC SFRS. + */ +#define CRC_SFRS ((__IO CRC_SFRS_t *)0x40021c00) + +#endif /* end of __CRC_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/crga_sfr.h b/87400/drivers/hdf/sfrs/crga_sfr.h new file mode 100644 index 0000000..3bebdc1 --- /dev/null +++ b/87400/drivers/hdf/sfrs/crga_sfr.h @@ -0,0 +1,247 @@ +/** + * @copyright 2023 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file crga_sfr.h + */ + +#ifndef CRGA_SFR_H__ +#define CRGA_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for CRGA. + */ +typedef struct { + + union { + struct { + uint8_t LFRCSTS : 8; /*!< Slow oscillator status */ + uint8_t : 8; /*!< LF Clock Source select */ + uint16_t : 16; /* (reserved) */ + }; + uint32_t WORD; + } LFCLKCTRL; /* +0x000 */ + union { + struct { + uint8_t HFRCENA : 1; /*!< HF oscillator enable */ + uint8_t HFRCSTS : 1; /*!< Fast oscillator status */ + uint8_t UHFRCENA : 1; /*!< Ultra high frequency oscillator enable */ + uint8_t UHFRCHIGHBWEN : 1; /*!< Ultra high frequency oscillator comparator high bandwidth enable */ + uint8_t : 4; /* (reserved) */ + uint8_t SYSCLKSEL : 1; /*!< System clock select */ + uint8_t SELFASTCLK : 1; /*!< Fast clock select */ + uint8_t : 6; /* (reserved) */ + uint8_t DIVSYSCLK : 3; /*!< Clock div select */ + uint8_t : 1; /* (reserved) */ + uint8_t HF_RC_LDO_VSEL : 2; + uint8_t UHFRCLDOVSEL : 2; + uint8_t CLKSOFTSTRTEN : 1; + uint8_t : 1; /* (reserved) */ + uint8_t CLKSOFTSTRTDLY : 3; + uint8_t : 3; /* (reserved) */ + }; + uint32_t WORD; + } SYSCLKCTRL; /* +0x004 */ + + union { + struct { + uint8_t PORFLAG : 1; /*!< Power on reset flag */ + uint8_t OVFLAG : 1; /*!< Over Voltage Monitor flag */ + uint8_t BOR3V3FLAG : 1; /*!< BOR 3v3 flag */ + uint8_t UVFLAG : 1; /*!< Under Voltage Monitor flag */ + uint8_t BOR1V5FLAG : 1; /*!< BOR 1v5 flag */ + uint8_t WDTFLAG : 1; /*!< Watchdog bark flag */ + uint8_t OVTEMPFLAG : 1; /*!< Over Temp Violation flag */ + uint8_t FSSOFLAG : 1; /*!< FSSO flag */ + uint8_t PORFLAGCLR : 1; /*!< POR flag clear */ + uint8_t OVFLAGCLR : 1; /*!< OV flag clear */ + uint8_t : 1; /* (reserved) */ + uint8_t UVFLAGCLR : 1; /*!< UV flag clear */ + uint8_t : 1; /* (reserved) */ + uint8_t WDTFLAGCLR : 1; /*!< WDT flag clear */ + uint8_t OVTEMPFLAGCLR : 1; /*!< OVTEMP flag clear */ + uint8_t FSSOFLAGCLR : 1; /*!< FSSO flag clear */ + uint8_t HARDRSTREQ : 1; /*!< Hard reset request */ + uint8_t SAFEMODEREQ : 1; /*!< Safe Mode request */ + uint8_t : 2; /* (reserved) */ + uint8_t SAFEMODEENA : 1; /*!< Safe Mode enable */ + uint8_t : 3; /* (reserved) */ + uint8_t SOFTRSTREQ : 8; /*!< Soft reset request */ + }; + uint32_t WORD; + } RESETCTRL; /* +0x008 */ + + union { + struct { + uint8_t ADCSTOP : 1; /*!< ADC Stop */ + uint8_t PWMSTOP : 1; /*!< PWM Stop */ + uint8_t CTTSTOP : 1; /*!< CTT Stop */ + uint8_t GTMSTOP : 1; /*!< GTM Stop */ + uint8_t SPISTOP : 1; /*!< SPI Stop */ + uint8_t UARTSTOP : 1; /*!< UART Stop */ + uint8_t MATHDIVSTOP : 1; /*!< MATHDIV Stop */ + uint8_t CRCSTOP : 1; /*!< CRC Stop */ + uint8_t PWMAUXSTOP : 8; /*!< PWMAUX Stop */ + uint16_t : 16; /* (reserved) */ + }; + uint32_t WORD; + } MODUCLKSTOP; /* +0x00C */ + + union { + struct { + uint8_t ADCSLEEPEN : 1; /*!< ADC Clock Enable in CPU Sleep Mode */ + uint8_t PWMSLEEPEN : 1; /*!< PWM Clock Enable in CPU Sleep Mode */ + uint8_t CTTSLEEPEN : 1; /*!< CTT Clock Enable in CPU Sleep Mode */ + uint8_t GTMSLEEPEN : 1; /*!< GTM Clock Enable in CPU Sleep Mode */ + uint8_t SPISLEEPEN : 1; /*!< SPI Clock Enable in CPU Sleep Mode */ + uint8_t UARTSLEEPEN : 1; /*!< UART Clock Enable in CPU Sleep Mode */ + uint8_t MATHDIVSLEEPEN : 1; /*!< MATHDIV Clock Enable in CPU Sleep Mode */ + uint8_t CRCSLEEPEN : 1; /*!< CRC Clock Enable in CPU Sleep Mode */ + uint8_t PWMAUXSLEEPEN : 1; /*!< PWMAUX Clock Enable in CPU Sleep Mode */ + uint8_t : 6; /* (reserved) */ + uint8_t FLASHSLEEPEN : 1; /*!< Flash Clock Enable in CPU Sleep Mode */ + uint16_t : 16; /* (reserved) */ + }; + uint32_t WORD; + } MODUSLEEPEN; /* +0x010 */ + + union { + struct { + uint8_t ADCDEEPSLEEPEN : 1; /*!< ADC Clock Enable in CPU Deep Sleep Mode */ + uint8_t PWMDEEPSLEEPEN : 1; /*!< PWM Clock Enable in CPU Deep Sleep Mode */ + uint8_t CTTDEEPSLEEPEN : 1; /*!< CTT Clock Enable in CPU Deep Sleep Mode */ + uint8_t GTMDEEPSLEEPEN : 1; /*!< GTM Clock Enable in CPU Deep Sleep Mode */ + uint8_t SPIDEEPSLEEPEN : 1; /*!< SPI Clock Enable in CPU Deep Sleep Mode */ + uint8_t UARTDEEPSLEEPEN : 1; /*!< UART Clock Enable in CPU Deep Sleep Mode */ + uint8_t MATHDIVDEEPSLEEPEN : 1; /*!< MATHDIV Clock Enable in CPU Deep Sleep Mode */ + uint8_t CRCDEEPSLEEPEN : 1; /*!< CRC Clock Enable in CPU Deep Sleep Mode */ + uint8_t PWMAUXDEEPSLEEPEN : 1; /*!< PWMAUX Clock Enable in CPU Deep Sleep Mode */ + uint8_t : 6; /* (reserved) */ + uint8_t FLASHDEEPSLEEPEN : 1; /*!< Flash Clock Enable in CPU Deep Sleep Mode */ + uint16_t : 16; /* (reserved) */ + }; + uint32_t WORD; + } MODUDEEPSLEEPEN; /* +0x014 */ + + uint16_t MODULERSTREQ; /*= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of CRGA SFRS. + */ +#define CRGA_SFRS ((__IO CRGA_SFRS_t *)0x40000000) + +#endif /* end of __CRGA_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/ctt_sfr.h b/87400/drivers/hdf/sfrs/ctt_sfr.h new file mode 100644 index 0000000..6b517fe --- /dev/null +++ b/87400/drivers/hdf/sfrs/ctt_sfr.h @@ -0,0 +1,271 @@ +/** + * @copyright 2023 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file ctt_sfr.h + */ + +#ifndef CTT_SFR_H__ +#define CTT_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for CTT. + */ +typedef struct { + + union { + struct { + uint8_t SELCT2IN : 1; /*!< Select for CT2IN */ + uint8_t SELCT2EUD : 1; /*!< Select for CT2EUD */ + uint8_t SELCT3IN : 2; /*!< Select for CT3IN */ + uint8_t SELCT3EUD : 1; /*!< Select for CT3EUD */ + uint8_t : 1; /* (reserved) */ + uint8_t SELCT4IN : 2; /*!< Select for CT4IN */ + uint8_t SELCT4EUD : 1; /*!< Select for CT4EUD */ + uint8_t : 1; /* (reserved) */ + uint8_t SELCT5IN : 1; /*!< Select for CT5IN */ + uint8_t SELCT5EUD : 1; /*!< Select for CT5EUD */ + uint8_t SELCT6IN : 1; /*!< Select for CT6IN */ + uint8_t SELCT6EUD : 1; /*!< Select for CT6EUD */ + uint8_t SELCAPIN : 2; /*!< Select for CAPIN */ + uint16_t : 16; /* (reserved) */ + }; + uint32_t WORD; + } CTTINSR; /* +0x000 */ + + union { + struct { + uint8_t CT2I : 3; /*!< Timer CT2 Input Parameter Selection */ + uint8_t CT2M : 3; /*!< Timer CT2 Mode Control */ + uint8_t CT2R : 1; /*!< Timer CT2 Run Bit */ + uint8_t CT2UD : 1; /*!< Timer CT2 Up/Down Control */ + uint8_t CT2EUDE : 1; /*!< Timer CT2 External Up/Down Enable */ + uint8_t CT2RC : 1; /*!< Timer CT2 Remote Control */ + uint8_t : 2; /* (reserved) */ + uint8_t CT2IIMIDIS : 1; /*!< Timer CT2 Incrmental Interrupt Disable */ + uint8_t CT2EDGE : 1; /*!< Timer CT2 Edge Detection */ + uint8_t CT2DIRCH : 1; /*!< Timer CT2 Count Direction Change */ + uint8_t CT2DIR : 1; /*!< Timer CT2 Count Direction */ + uint8_t CT2PRESHI : 1; /*!< Timer CT2 Prescaler High Bit */ + uint8_t : 1; /* (reserved) */ + uint8_t CT2EDGEC : 1; /*!< Timer CT2 Edge Detection Clear */ + uint8_t : 1; /* (reserved) */ + uint8_t CT2DIRCHC : 1; /*!< Timer CT2 Count Direction Change Clear */ + uint8_t : 3; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } CT2CTRLR; /* +0x004 */ + + union { + struct { + uint8_t CT3I : 3; /*!< Timer CT3 Input Parameter Selection */ + uint8_t CT3M : 3; /*!< Timer CT3 Mode Control */ + uint8_t CT3R : 1; /*!< Timer CT3 Run Bit */ + uint8_t CT3UD : 1; /*!< Timer CT3 Up/Down Control */ + uint8_t CT3EUDE : 1; /*!< Timer CT3 External Up/Down Enable */ + uint8_t CT3OE : 1; /*!< Timer CT3 Output Enable */ + uint8_t CT3OTL : 1; /*!< Timer CT3 Overflow/underflow Toggle Latch */ + uint8_t : 1; /* (reserved) */ + uint8_t CT3IIMIDIS : 1; /*!< Timer CT3 Incrmental Interrupt Disable */ + uint8_t CT3EDGE : 1; /*!< Timer CT3 Edge Detection */ + uint8_t CT3DIRCH : 1; /*!< Timer CT3 Count Direction Change */ + uint8_t CT3DIR : 1; /*!< Timer CT3 Count Direction */ + uint8_t CT3PRESHI : 1; /*!< Timer CT3 Prescaler High Bit */ + uint8_t : 1; /* (reserved) */ + uint8_t CT3EDGEC : 1; /*!< Timer CT3 Edge Detection Clear */ + uint8_t : 1; /* (reserved) */ + uint8_t CT3DIRCHC : 1; /*!< Timer CT3 Count Direction Change Clear */ + uint8_t : 3; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } CT3CTRLR; /* +0x008 */ + + union { + struct { + uint8_t CT4I : 3; /*!< Timer CT4 Input Parameter Selection */ + uint8_t CT4M : 3; /*!< Timer CT4 Mode Control */ + uint8_t CT4R : 1; /*!< Timer CT4 Run Bit */ + uint8_t CT4UD : 1; /*!< Timer CT4 Up/Down Control */ + uint8_t CT4EUDE : 1; /*!< Timer CT4 External Up/Down Enable */ + uint8_t CT4RC : 1; /*!< Timer CT4 Remote Control */ + uint8_t CLRCT2EN : 1; /*!< Clear Timer CT2 Enable */ + uint8_t CLRCT3EN : 1; /*!< Clear Timer CT3 Enable */ + uint8_t CT4IIMIDIS : 1; /*!< Timer CT4 Incrmental Interrupt Disable */ + uint8_t CT4EDGE : 1; /*!< Timer CT4 Edge Detection */ + uint8_t CT4DIRCH : 1; /*!< Timer CT4 Count Direction Change */ + uint8_t CT4DIR : 1; /*!< Timer CT4 Count Direction */ + uint8_t CT4PRESHI : 1; /*!< Timer CT4 Prescaler High Bit */ + uint8_t : 1; /* (reserved) */ + uint8_t CT4EDGEC : 1; /*!< Timer CT4 Edge Detection Clear */ + uint8_t : 1; /* (reserved) */ + uint8_t CT4DIRCHC : 1; /*!< Timer CT4 Count Direction Change Clear */ + uint8_t : 3; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } CT4CTRLR; /* +0x00C */ + + union { + struct { + uint8_t CT5I : 3; /*!< Timer CT5 Input Parameter Selection */ + uint8_t CT5M : 2; /*!< Timer CT5 Mode Control */ + uint8_t : 1; /* (reserved) */ + uint8_t CT5R : 1; /*!< Timer CT5 Run Bit */ + uint8_t CT5UD : 1; /*!< Timer CT5 Up/Down Control */ + uint8_t CT5EUDE : 1; /*!< Timer CT5 External Up/Down Enable */ + uint8_t CT5RC : 1; /*!< Timer CT5 Remote Control */ + uint8_t CT3CTS : 1; /*!< Capture Trigger Selection */ + uint8_t : 1; /* (reserved) */ + uint8_t CTS : 2; /*!< Register CAPRLD Capture Trigger Selection */ + uint8_t CT5CLRE : 1; /*!< Timer CT5 Clear Enable Bit */ + uint8_t CT5DIR : 1; /*!< Timer CT5 Count Direction */ + uint8_t CT5PRESHI : 1; /*!< Timer CT5 Prescaler High Bit */ + uint8_t CT5CE : 1; /*!< Timer CT5 Capture Mode Enable */ + uint8_t : 6; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } CT5CTRLR; /* +0x010 */ + + union { + struct { + uint8_t CT6I : 3; /*!< Timer CT6 Input Parameter Selection */ + uint8_t CT6M : 2; /*!< Timer CT6 Mode Control */ + uint8_t : 1; /* (reserved) */ + uint8_t CT6R : 1; /*!< Timer CT6 Run Bit */ + uint8_t CT6UD : 1; /*!< Timer CT6 Up/Down Control */ + uint8_t CT6EUDE : 1; /*!< Timer CT6 External Up/Down Enable */ + uint8_t CT6OE : 1; /*!< Timer CT6 Output Enable */ + uint8_t CT6OTL : 1; /*!< Timer CT6 Overflow/underflow Toggle Latch */ + uint8_t : 3; /* (reserved) */ + uint8_t CT6CLRE : 1; /*!< Timer CT6 Clear Enable Bit */ + uint8_t CT6DIR : 1; /*!< Timer CT6 Count Direction */ + uint8_t CT6PRESHI : 1; /*!< Timer CT6 Prescaler High Bit */ + uint8_t CT6RE : 1; /*!< Timer CT6 Reload Mode Enable */ + uint8_t : 6; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } CT6CTRLR; /* +0x014 */ + + uint16_t CAPRLD; /*Reload value or Captured value +0x018 */ + uint8_t _RESERVED_1A[2]; /* +0x01A */ + + uint16_t CT2CV; /*Timer CT2 Current Value +0x01C */ + uint8_t _RESERVED_1E[2]; /* +0x01E */ + + uint16_t CT3CV; /*Timer CT3 Current Value +0x020 */ + uint8_t _RESERVED_22[2]; /* +0x022 */ + + uint16_t CT4CV; /*Timer CT4 Current Value +0x024 */ + uint8_t _RESERVED_26[2]; /* +0x026 */ + + uint16_t CT5CV; /*Timer CT5 Current Value +0x028 */ + uint8_t _RESERVED_2A[2]; /* +0x02A */ + + uint16_t CT6CV; /*Timer CT6 Current Value +0x02C */ + uint8_t _RESERVED_2E[2]; /* +0x02E */ + + union { + struct { + uint8_t CT2IE : 1; /*!< CT2 interrupt enable */ + uint8_t CT3IE : 1; /*!< CT3 interrupt enable */ + uint8_t CT4IE : 1; /*!< CT4 interrupt enable */ + uint8_t CT5IE : 1; /*!< CT5 interrupt enable */ + uint8_t CT6IE : 1; /*!< CT6 interrupt enable */ + uint8_t CRIE : 1; /*!< CAPREL capture interrupt enable */ + uint8_t : 2; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + uint8_t CT2IC : 1; /*!< CT2 interrupt clear */ + uint8_t CT3IC : 1; /*!< CT3 interrupt clear */ + uint8_t CT4IC : 1; /*!< CT4 interrupt clear */ + uint8_t CT5IC : 1; /*!< CT5 interrupt clear */ + uint8_t CT6IC : 1; /*!< CT6 interrupt clear */ + uint8_t CRIC : 1; /*!< CAPREL capture interrupt clear */ + uint8_t : 2; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } INTCTRLR; /* +0x030 */ + + union { + struct { + uint8_t CT2IF : 1; /*!< CT2 interrupt flag */ + uint8_t CT3IF : 1; /*!< CT3 interrupt flag */ + uint8_t CT4IF : 1; /*!< CT4 interrupt flag */ + uint8_t CT5IF : 1; /*!< CT5 interrupt flag */ + uint8_t CT6IF : 1; /*!< CT6 interrupt flag */ + uint8_t CRIF : 1; /*!< CAPREL capture interrupt flag */ + uint8_t : 2; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + uint8_t CT2IRQ : 1; /*!< CT2 interrupt active */ + uint8_t CT3IRQ : 1; /*!< CT3 interrupt active */ + uint8_t CT4IRQ : 1; /*!< CT4 interrupt active */ + uint8_t CT5IRQ : 1; /*!< CT5 interrupt active */ + uint8_t CT6IRQ : 1; /*!< CT6 interrupt active */ + uint8_t CRIRQ : 1; /*!< CAPREL capture interrupt active */ + uint8_t : 2; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } INTSTATR; /* +0x034 */ + +} CTT_SFRS_t; + +/* -------- End of section using anonymous unions and disabling warnings -------- */ +#if defined (__CC_ARM) + #pragma pop +#elif defined (__ICCARM__) + /* leave anonymous unions enabled */ +#elif (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of CTT SFRS. + */ +#define CTT_SFRS ((__IO CTT_SFRS_t *)0x40010400) + +#endif /* end of __CTT_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/evthold_sfr.h b/87400/drivers/hdf/sfrs/evthold_sfr.h new file mode 100644 index 0000000..56a7283 --- /dev/null +++ b/87400/drivers/hdf/sfrs/evthold_sfr.h @@ -0,0 +1,75 @@ +/** + * @copyright 2023 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file evthold_sfr.h + */ + +#ifndef EVTHOLD_SFR_H__ +#define EVTHOLD_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for EVTHOLD. + */ +typedef struct { + + uint8_t HOLD; /* +0x000 */ + uint8_t _RESERVED_01[3]; /* +0x001 */ + +} EVTHOLD_SFRS_t; + +/* -------- End of section using anonymous unions and disabling warnings -------- */ +#if defined (__CC_ARM) + #pragma pop +#elif defined (__ICCARM__) + /* leave anonymous unions enabled */ +#elif (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of EVTHOLD SFRS. + */ +#define EVTHOLD_SFRS ((__IO EVTHOLD_SFRS_t *)0x40013000) + +#endif /* end of __EVTHOLD_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/flash_sfr.h b/87400/drivers/hdf/sfrs/flash_sfr.h new file mode 100644 index 0000000..8c303df --- /dev/null +++ b/87400/drivers/hdf/sfrs/flash_sfr.h @@ -0,0 +1,162 @@ +/** + * @copyright 2023 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file flash_sfr.h + */ + +#ifndef FLASH_SFR_H__ +#define FLASH_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for FLASH. + */ +typedef struct { + + union { + struct { + uint8_t : 3; /* (reserved) */ + uint16_t FLASHADDR : 13; + uint8_t NVR : 8; + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } FLADDR; /* +0x000 */ + + uint32_t DATAL; /*= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of FLASH SFRS. + */ +#define FLASH_SFRS ((__IO FLASH_SFRS_t *)0x40020800) + +#endif /* end of __FLASH_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/gpio_sfr.h b/87400/drivers/hdf/sfrs/gpio_sfr.h new file mode 100644 index 0000000..b88666c --- /dev/null +++ b/87400/drivers/hdf/sfrs/gpio_sfr.h @@ -0,0 +1,106 @@ +/** + * @copyright 2023 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file gpio_sfr.h + */ + +#ifndef GPIO_SFR_H__ +#define GPIO_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for GPIO. + */ + +typedef struct { + uint8_t DATA : 8; /*!< Port A data */ + uint8_t : 8; /* (reserved) */ + uint8_t DATASET : 8; + uint8_t DATACLR : 8; +}GpioSet_t; + + +typedef struct { + uint8_t DIR : 1; /*!< GPIO PIN output enable */ + uint8_t IE : 1; /*!< GPIO PIN interrupt mask */ + uint8_t EDGE : 2; /* 00: disable, 01: rising, 10: falling, 11: both */ + uint8_t CLR : 1; /*!< GPIO PIN interrupt clear */ + uint8_t ACTDET : 1; /*!< GPIO PIN activity interrupt */ + uint8_t ACTDETRE : 1; /*!< GPIO PIN activity rise status */ + uint8_t ACTDETFE : 1; /*!< GPIO PIN activity fall status */ +} GPIO_Cfg_t; /* +0x1000 */ + + +typedef struct { + GpioSet_t GPIO_SET[3]; /* only PA2-PA7 PB0-PB7, PC0-PC4 available */ + GPIO_Cfg_t GPIOA[8]; /* only PA2-PA7 available */ + GPIO_Cfg_t GPIOB[8]; + GPIO_Cfg_t GPIOC[8]; /* only PC0-PC4 available */ + union { + struct { + uint8_t GPAENA : 1; + uint8_t GPBENA : 1; + uint8_t GPCENA : 1; + uint8_t : 5; /* (reserved) */ + uint32_t : 24; /* (reserved) */ + }; + uint32_t WORD; + } GPENA; /* +0x024 */ + +} GPIO_SFRS_t; + +/* -------- End of section using anonymous unions and disabling warnings -------- */ +#if defined (__CC_ARM) + #pragma pop +#elif defined (__ICCARM__) + /* leave anonymous unions enabled */ +#elif (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of GPIO SFRS. + */ +#define GPIO_SFRS ((__IO GPIO_SFRS_t *)0x40004400) + +#endif /* end of __GPIO_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/gtimer_sfr.h b/87400/drivers/hdf/sfrs/gtimer_sfr.h new file mode 100644 index 0000000..15cbe0d --- /dev/null +++ b/87400/drivers/hdf/sfrs/gtimer_sfr.h @@ -0,0 +1,113 @@ +/** + * @copyright 2022 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file gtimer_sfr.h + */ + +#ifndef GTIMER_SFR_H__ +#define GTIMER_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +typedef struct { + union { + struct { + uint8_t GTDCEN : 1; /*!< GT1 Direction Control Enable */ + uint8_t GTPRES : 4; /*!< Prescaler select */ + uint8_t GTEDGE : 1; /*!< GT1 Edge select in capture mode/reload mode */ + uint8_t GTHRSEL : 2; /*!< GT1 hardware run selection */ + uint8_t GTCAPEN : 1; /*!< GT1 Capture Enable */ + uint8_t GTCNTEN : 1; /*!< GT1 Counter Mode Enable */ + uint8_t GTR : 1; /*!< Timer GT1 run bit */ + uint8_t GTEXTEN : 1; /*!< GT1 external enable control */ + uint8_t GTSSE : 1; /*!< GT1 single shot enable */ + uint8_t : 1; /* (reserved) */ + uint8_t GTEXTF : 1; /*!< GT1 external flag */ + uint8_t GTTF : 1; /*!< GT1 overflow/underflow flag */ + uint16_t : 16; /* (reserved) */ + }; + uint32_t WORD; + } GTCTRLR; /* +0x000 */ + + union { + struct { + uint8_t : 6; /* (reserved) */ + uint8_t GTEXTFIE : 1; /*!< External interrupt enable */ + uint8_t GTTFIE : 1; /*!< Overflow/underflow interrupt enable */ + uint8_t : 6; /* (reserved) */ + uint8_t GTEXTFC : 1; /*!< GT1EXTF Clear */ + uint8_t GTTFC : 1; /*!< GT1TF Clear */ + uint16_t : 16; /* (reserved) */ + }; + uint32_t WORD; + } GTINTCTRLR; /* +0x004 */ + uint16_t GTRCV; /*GT1 Reload/Capture Value +0x008 */ + uint8_t _RESERVED_0A[2]; /* +0x00A */ + uint16_t GTCV; /* +0x00C */ + uint8_t _RESERVED_0E[2]; /* +0x00E */ +}GTimer_t; + + + + +/** + * @brief A structure to represent Special Function Registers for GTIMER. + */ +typedef struct { + GTimer_t TIMER[5]; +} GTIMER_SFRS_t; + +/* -------- End of section using anonymous unions and disabling warnings -------- */ +#if defined (__CC_ARM) + #pragma pop +#elif defined (__ICCARM__) + /* leave anonymous unions enabled */ +#elif (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of GTIMER SFRS. + */ +#define GTIMER_SFRS ((__IO GTIMER_SFRS_t *)0x40010c00) + +#endif /* end of __GTIMER_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/ioctrla_sfr.h b/87400/drivers/hdf/sfrs/ioctrla_sfr.h new file mode 100644 index 0000000..0195af1 --- /dev/null +++ b/87400/drivers/hdf/sfrs/ioctrla_sfr.h @@ -0,0 +1,238 @@ +/** + * @copyright 2023 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file ioctrla_sfr.h + */ + +#ifndef IOCTRLA_SFR_H__ +#define IOCTRLA_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for IOCTRLA. + */ + +typedef struct { + uint8_t PU : 8; /*!< Pull-up enable */ + uint8_t PD : 8; /*!< Pull-down enable */ + uint8_t RE : 8; /*!< Read enable */ + uint8_t : 8; /* (reserved) */ +}PortGroupCtrlMode_t; + + +typedef struct { + uint32_t PORT_GROUP_MUX[3]; + PortGroupCtrlMode_t CTRL_MODE[3]; + union { + struct { + uint8_t TESTMUX0 : 8; + uint8_t TESTMUX1 : 8; + uint8_t TESTMUX2 : 8; + uint8_t TESTMUX3 : 8; + }; + uint32_t WORD; + } TESTMUX; /* +0x018 */ + + union { + struct { + uint8_t LINSRXGFENA : 2; /*!< LINS RXD Glitch Filter enables */ + uint8_t LINS_RX_GF_ENA_1ST : 1; /*!< LINS RXD 1st Glitch Filter enables */ + uint8_t LINS_RX_GF_ENA_2ND : 1; /*!< LINS RXD 2nd Glitch Filter enables */ + uint8_t LINS_DBNC_PRESCALE_EN : 1; /*!< LINS Debounce prescale enable */ + uint8_t LINS_DBNC_PRESCALE : 2; /*!< LINS Debounce prescaler select */ + uint8_t : 1; /* (reserved) */ + uint8_t LINSDBNCTHRES0 : 8; /*!< 3rd Stage LINS Debounce Threshold for 1 to 0 */ + uint8_t LINSDBNCTHRES1 : 8; /*!< 3rd Stage LINS Debounce Threshold for 0 to 1 */ + uint8_t LINS_RX_GF_SEL_1ST : 8; /*!< LINS RXD 1st Glitch Filter select dualedge or single-edge */ + }; + uint32_t WORD; + } LINSGFCONF; /* +0x01C */ + + union { + struct { + uint8_t LINS_DBNC_THRES0_1ST : 8; /*!< 1st Stage LINS Debounce Threshold for 1 to 0 */ + uint8_t LINS_DBNC_THRES1_1ST : 8; /*!< 1st Stage LINS Debounce Threshold for 0 to 1 */ + uint8_t LINS_DBNC_THRES0_2ND : 8; /*!< 2nd Stage LINS Debounce Threshold for 1 to 0 */ + uint8_t LINS_DBNC_THRES1_2ND : 8; /*!< 2nd Stage LINS Debounce Threshold for 0 to 1 */ + }; + uint32_t WORD; + } LINSGFCONF1; /* +0x020 */ + + union { + struct { + uint8_t : 8; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + uint8_t : 7; /* (reserved) */ + uint8_t FILT_UNLOCK : 1; + }; + uint32_t WORD; + } FILT_ACCESS; /* +0x024 */ + + union { + struct { + uint8_t LINSTXDMONITORENA : 8; /*!< LINS TxD Monitor enable */ + uint8_t LINSTXDTIMEOUTDOMINANT : 8; /*!< Tx Dominant Timeout */ + uint16_t : 16; /* (reserved) */ + }; + uint32_t WORD; + } LINTXDMONITOR; /* +0x028 */ + + union { + struct { + union { + struct { + uint8_t INT_LINS_TXD_DOM_ENA : 8; /*!< LINS TXD Dominant Monitor interrupt enable */ + }; + uint8_t BYTE; + } ENABLE; + union { + struct { + uint8_t INT_LINS_TXD_DOM_CLR : 8; /*!< LINS TXD Dominant Monitor interrupt clear */ + }; + uint8_t BYTE; + } CLEAR; + union { + struct { + uint8_t INT_LINS_TXD_DOM_STS : 8; /*!< LINS TXD Dominant Monitor interrupt status */ + }; + uint8_t BYTE; + } STATUS; + union { + struct { + uint8_t INT_LINS_TXD_DOM_ACT : 8; /*!< LINS TXD Dominant Monitor interrupt active */ + }; + uint8_t BYTE; + } IRQ; + }; + uint32_t WORD; + } IRQ; /* +0x02C */ + + union { + struct { + uint8_t GPIOCONSEL : 1; /*!< Hardware/Firmware Select */ + uint8_t : 2; /* (reserved) */ + uint16_t GPIOCONREG : 13; /*!< Analog test MUX select */ + uint16_t ANASELREG : 16; /*!< Analog Select Control */ + }; + uint32_t WORD; + } ANALOGTESTMUXOVERRIDE; /* +0x030 */ + + union { + struct { + uint8_t PRESCALE_EN : 1; /*!< prescale enable */ + uint8_t PRESCALE : 2; /*!< prescaler select */ + uint8_t : 5; /* (reserved) */ + uint32_t IODBNCEN : 17; /*!< IO Debounce Enable */ + uint8_t : 7; /* (reserved) */ + }; + uint32_t WORD; + } IODBNC; /* +0x034 */ + + union { + struct { + uint8_t IOGRP0_DBNC_THRES0 : 8; /*!< IO Group0 Debounce Threshold for 1 to 0 */ + uint8_t IOGRP0_DBNC_THRES1 : 8; /*!< IO Group0 Debounce Threshold for 0 to 1 */ + uint8_t IOGRP1_DBNC_THRES0 : 8; /*!< IO Group1 Debounce Threshold for 1 to 0 */ + uint8_t IOGRP1_DBNC_THRES1 : 8; /*!< IO Group1 Debounce Threshold for 0 to 1 */ + }; + uint32_t WORD; + } IOGFCONF0; /* +0x038 */ + + union { + struct { + uint8_t IOGRP2_DBNC_THRES0 : 8; /*!< IO Group2 Debounce Threshold for 1 to 0 */ + uint8_t IOGRP2_DBNC_THRES1 : 8; /*!< IO Group2 Debounce Threshold for 0 to 1 */ + uint8_t IOGRP3_DBNC_THRES0 : 8; /*!< IO Group3 Debounce Threshold for 1 to 0 */ + uint8_t IOGRP3_DBNC_THRES1 : 8; /*!< IO Group3 Debounce Threshold for 0 to 1 */ + }; + uint32_t WORD; + } IOGFCONF1; /* +0x03C */ + + union { + struct { + uint8_t ID_GRPS_PA2 : 2; /*!< PA2 debounce Group Selection */ + uint8_t ID_GRPS_PA3 : 2; /*!< PA3 debounce Group Selection */ + uint8_t ID_GRPS_PA4 : 2; /*!< PA4 debounce Group Selection */ + uint8_t ID_GRPS_PA5 : 2; /*!< PA5 debounce Group Selection */ + uint8_t ID_GRPS_PA6 : 8; /*!< PA6 debounce Group Selection */ + uint8_t ID_GRPS_PB0 : 2; /*!< PB0 debounce Group Selection */ + uint8_t ID_GRPS_PB1 : 2; /*!< PB1 debounce Group Selection */ + uint8_t ID_GRPS_PB2 : 2; /*!< PB2 debounce Group Selection */ + uint8_t ID_GRPS_PB3 : 2; /*!< PB3 debounce Group Selection */ + uint8_t ID_GRPS_PB4 : 2; /*!< PB4 debounce Group Selection */ + uint8_t ID_GRPS_PB5 : 2; /*!< PB5 debounce Group Selection */ + uint8_t ID_GRPS_PB6 : 2; /*!< PB6 debounce Group Selection */ + uint8_t ID_GRPS_PB7 : 2; /*!< PB7 debounce Group Selection */ + }; + uint32_t WORD; + } IODBNCGRPS0; /* +0x040 */ + + union { + struct { + uint8_t ID_GRPS_SWDIO : 2; /*!< SWDIO debounce Group Selection */ + uint8_t ID_GRPS_SWCLK : 2; /*!< SWCLK debounce Group Selection */ + uint8_t ID_GRPS_PC3 : 2; /*!< PC3 debounce Group Selection */ + uint8_t ID_GRPS_PC4 : 2; /*!< PC4 debounce Group Selection */ + uint32_t : 24; /* (reserved) */ + }; + uint32_t WORD; + } IODBNCGRPS1; /* +0x044 */ + +} IOCTRLA_SFRS_t; + +/* -------- End of section using anonymous unions and disabling warnings -------- */ +#if defined (__CC_ARM) + #pragma pop +#elif defined (__ICCARM__) + /* leave anonymous unions enabled */ +#elif (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of IOCTRLA SFRS. + */ +#define IOCTRLA_SFRS ((__IO IOCTRLA_SFRS_t *)0x40000c00) + +#endif /* end of __IOCTRLA_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/lins_sfr.h b/87400/drivers/hdf/sfrs/lins_sfr.h new file mode 100644 index 0000000..fe9efb6 --- /dev/null +++ b/87400/drivers/hdf/sfrs/lins_sfr.h @@ -0,0 +1,261 @@ +/** + * @copyright 2022 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file lins_sfr.h + */ + +#ifndef LINS_SFR_H__ +#define LINS_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + + +#define LINS_DL_LENGTH_POS (0) +#define LINS_DL_DISBITMON_POS (6) +#define LINS_DL_ENHCHK_POS (7) + +#define DATAACK_TPYE_RECEIVE (0x01) +#define DATAACK_TPYE_TRANSMIT (0x03) +/** + * @brief A structure to represent Special Function Registers for LINS. + */ +typedef union{ + struct{ + uint8_t DATA; /*= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of LINS SFRS. + */ +#define LINS_SFRS ((__IO LINS_SFRS_t *)0x40001C00) + +#endif /* end of __LINS_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/mathdiv_sfr.h b/87400/drivers/hdf/sfrs/mathdiv_sfr.h new file mode 100644 index 0000000..d4cef70 --- /dev/null +++ b/87400/drivers/hdf/sfrs/mathdiv_sfr.h @@ -0,0 +1,142 @@ +/** + * @copyright 2023 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file mathdiv_sfr.h + */ + +#ifndef MATHDIV_SFR_H__ +#define MATHDIV_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for MATHDIV. + */ +typedef struct { + + union { + struct { + uint8_t DVDRC : 2; /*!< Dividend Register Result Chaining */ + uint8_t : 1; /* (reserved) */ + uint8_t DVSRC : 2; /*!< Dividend Register Result Chaining */ + uint8_t : 3; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + uint8_t SUSCFG : 8; /*!< Suspend Mode Configuration */ + uint8_t : 7; /* (reserved) */ + uint8_t MATHEN : 1; /*!< Enable Math Module */ + }; + uint32_t WORD; + } GLBCON; /* +0x000 */ + + union { + struct { + uint8_t DIVEOCQ : 1; + uint8_t DIVERRQ : 1; + uint8_t : 6; /* (reserved) */ + uint8_t DIVEOC : 1; + uint8_t DIVERR : 1; + uint8_t : 6; /* (reserved) */ + uint16_t : 16; /* (reserved) */ + }; + uint32_t WORD; + } DIVINTSTATR; /* +0x004 */ + + union { + struct { + uint8_t DIVEOCS : 1; + uint8_t DIVERRS : 1; + uint8_t : 6; /* (reserved) */ + uint8_t DIVEOCC : 1; + uint8_t DIVERRC : 1; + uint8_t : 6; /* (reserved) */ + uint8_t DIVEOCIE : 1; + uint8_t DIVERRIE : 1; + uint8_t : 6; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } DIVINTPROCR; /* +0x008 */ + + uint32_t DVDVAL; /* +0x00C */ + + uint32_t DVSVAL; /* +0x010 */ + + uint32_t QUOTVAL; /* +0x014 */ + + uint32_t RMDVAL; /* +0x018 */ + + uint8_t BUSY; /* +0x01C */ + uint8_t _RESERVED_1D[3]; /* +0x01D */ + + union { + struct { + uint8_t ST : 1; /*!< Start Bit */ + uint8_t STMODE : 1; /*!< Start Mode */ + uint8_t USIGN : 1; /*!< Unsigned Division Enable */ + uint8_t DIVMODE : 2; /*!< Division Mode */ + uint8_t : 3; /* (reserved) */ + uint8_t QSCNT : 5; /*!< Quotient Shift Count */ + uint8_t : 2; /* (reserved) */ + uint8_t QSDIR : 1; /*!< Quotient Shift Direction */ + uint8_t DVDSLC : 8; /*!< Dividend Shift Left Count */ + uint8_t DVSSRC : 8; /*!< Divisor Shift Right Count */ + }; + uint32_t WORD; + } DIVCON; /* +0x020 */ + +} MATHDIV_SFRS_t; + +/* -------- End of section using anonymous unions and disabling warnings -------- */ +#if defined (__CC_ARM) + #pragma pop +#elif defined (__ICCARM__) + /* leave anonymous unions enabled */ +#elif (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of MATHDIV SFRS. + */ +#define MATHDIV_SFRS ((__IO MATHDIV_SFRS_t *)0x40021800) + +#endif /* end of __MATHDIV_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/meta_sfr.h b/87400/drivers/hdf/sfrs/meta_sfr.h new file mode 100644 index 0000000..488a7ed --- /dev/null +++ b/87400/drivers/hdf/sfrs/meta_sfr.h @@ -0,0 +1,31 @@ +/* this header brings in the individual files that define the + * struct typdefs for all the special function registers of META + */ + +#ifndef META_SFR_H__ +#define META_SFR_H__ + +#include "sram_sfr.h" +#include "crga_sfr.h" +#include "pmua_sfr.h" +#include "sysctrla_sfr.h" +#include "trimhv_sfr.h" +#include "ioctrla_sfr.h" +#include "wica_sfr.h" +#include "wdta_sfr.h" +#include "lins_sfr.h" +#include "gpio_sfr.h" +#include "pwm_sfr.h" +#include "ctt_sfr.h" +#include "pwm_aux_sfr.h" +#include "gtimer_sfr.h" +#include "evthold_sfr.h" +#include "sar_ctrl_sfr.h" +#include "spi_sfr.h" +#include "uart0_sfr.h" +#include "syscfg_sfr.h" +#include "flash_sfr.h" +#include "mathdiv_sfr.h" +#include "crc_sfr.h" + +#endif diff --git a/87400/drivers/hdf/sfrs/pmua_sfr.h b/87400/drivers/hdf/sfrs/pmua_sfr.h new file mode 100644 index 0000000..74d35a6 --- /dev/null +++ b/87400/drivers/hdf/sfrs/pmua_sfr.h @@ -0,0 +1,175 @@ +/** + * @copyright 2023 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file pmua_sfr.h + */ + +#ifndef PMUA_SFR_H__ +#define PMUA_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for PMUA. + */ +typedef struct { + + union { + struct { + uint8_t HIBERNATE : 1; + uint8_t FASTBOOT : 1; /*!< Fast boot */ + uint8_t : 6; /* (reserved) */ + uint32_t : 24; /* (reserved) */ + }; + uint32_t WORD; + } CTRL; /* +0x000 */ + + union { + struct { + uint8_t ENABLE_1V5 : 4; /*!< Enable 1.5V dwell time */ + uint8_t ATTACH_1V5 : 4; /*!< Attach 1.5V dwell time */ + uint8_t ATTACH_3V3 : 4; /*!< Attach 3.3V dwell time */ + uint8_t POWER_DOWN_MCU : 4; /*!< Power down MCU dwell time */ + uint16_t : 16; /* (reserved) */ + }; + uint32_t WORD; + } DWELL; /* +0x004 */ + + union { + struct { + uint8_t : 2; /* (reserved) */ + uint8_t UV_POL : 1; /*!< Reserved */ + uint8_t OV_POL : 1; /*!< Reserved */ + uint8_t : 4; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + uint8_t LOW : 1; /*!< Battery Voltage Low Status */ + uint8_t HIGH : 1; /*!< Battery Voltage High Status */ + /* + uint8_t LOW_DBNC : 1; !< Battery Voltage Low Status after debouncing + uint8_t HIGH_DBNC : 1; !< Battery Voltage High Status after deboucing + */ + uint8_t BAT_STATE : 2; + uint8_t : 4; /* (reserved) */ + }; + uint32_t WORD; + } VBATCTRL; /* +0x008 */ + + union { + struct { + uint8_t UV : 1; /*!< under voltage signal debounce enable */ + uint8_t OV : 1; /*!< over voltage signal debounce enable */ + uint8_t UVSTRB0SEL : 1; /*!< Clock select for UV low debouncing */ + uint8_t UVSTRB1SEL : 1; /*!< Clock select for UV high debouncing */ + uint8_t OVSTRB0SEL : 1; /*!< Clock select for OV low debouncing */ + uint8_t OVSTRB1SEL : 1; /*!< Clock select for OV high debouncing */ + uint8_t : 2; /* (reserved) */ + uint32_t : 24; /* (reserved) */ + }; + uint32_t WORD; + } VBATDBNC; /* +0x00C */ + + union { + struct { + uint8_t UVTHRES1 : 8; /*!< Under Voltage debouncing threshold for 0to1 Transition */ + uint8_t OVTHRES1 : 8; /*!< Over Voltage debouncing threshold for 0to1 Transition */ + uint8_t UVTHRES0 : 8; /*!< Under Voltage debouncing threshold for 1to0 Transition */ + uint8_t OVTHRES0 : 8; /*!< Over Voltage debouncing threshold for 1to0 Transition */ + }; + uint32_t WORD; + } VBATDBNCTHRES; /* +0x010 */ + + union { + struct { + union { + struct { + uint8_t UV_ENA : 1; /*!< under voltage interrupt enable */ + uint8_t OV_ENA : 1; /*!< over voltage interrupt enable */ + uint8_t : 6; /* (reserved) */ + }; + uint8_t BYTE; + } ENABLE; + union { + struct { + uint8_t UV_CLR : 1; /*!< under voltage interrupt clear */ + uint8_t OV_CLR : 1; /*!< over voltage interrupt clear */ + uint8_t : 6; /* (reserved) */ + }; + uint8_t BYTE; + } CLEAR; + union { + struct { + uint8_t UV_STS : 1; /*!< under voltage interrupt status */ + uint8_t OV_STS : 1; /*!< over voltage interrupt status */ + uint8_t : 6; /* (reserved) */ + }; + uint8_t BYTE; + } STATUS; + union { + struct { + uint8_t UV_ACT : 1; /*!< under voltage interrupt active */ + uint8_t OV_ACT : 1; /*!< over voltage interrupt active */ + uint8_t : 6; /* (reserved) */ + }; + uint8_t BYTE; + } IRQ; + }; + uint32_t WORD; + } PMUIRQ; /* +0x014 */ + +} PMUA_SFRS_t; + +/* -------- End of section using anonymous unions and disabling warnings -------- */ +#if defined (__CC_ARM) + #pragma pop +#elif defined (__ICCARM__) + /* leave anonymous unions enabled */ +#elif (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of PMUA SFRS. + */ +#define PMUA_SFRS ((__IO PMUA_SFRS_t *)0x40000400) + +#endif /* end of __PMUA_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/pwm_aux_sfr.h b/87400/drivers/hdf/sfrs/pwm_aux_sfr.h new file mode 100644 index 0000000..8af9d58 --- /dev/null +++ b/87400/drivers/hdf/sfrs/pwm_aux_sfr.h @@ -0,0 +1,207 @@ +/** + * @copyright 2022 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file pwm_aux_sfr.h + */ + +#ifndef PWM_AUX_SFR_H__ +#define PWM_AUX_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for PWM_AUX. + */ + +typedef struct { + struct { + uint8_t : 8; /* (reserved) */ + uint8_t PRESCALESEL : 8; /*!< Prescaler select */ + uint16_t PERIOD : 16; /*!< Period */ + }BASE; /* +0x000 */ + uint16_t PWMCNT; /* +0x004 */ + uint8_t _RESERVED[2]; /* +0x006 */ +}PWM_AUX_t; + + +typedef union { + struct { + uint16_t PFALL : 16; /*!< Pulse Fall */ + uint16_t PRISE : 16; /*!< Pulse Rise */ + }; + uint32_t WORD; +}PWM_AUX_PULSE_t; /* +0x028 */ + + +typedef struct { + PWM_AUX_t PWM_AUX[2]; + uint8_t BASE_SEL; /* +0x010 */ + uint8_t _RESERVED_11[3]; /* +0x011 */ + + union { + struct { + uint8_t ENAREQ : 8; + uint8_t : 8; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + uint8_t ENAREQALL : 1; + uint8_t CLRREQALL : 1; + uint8_t FORCEINACTIVE : 1; + uint8_t : 5; /* (reserved) */ + }; + uint32_t WORD; + } ENAREQ; /* +0x014 */ + + uint8_t ENASTS; /* +0x018 */ + uint8_t _RESERVED_19[3]; /* +0x019 */ + + uint8_t INIT; /* +0x01C */ + uint8_t _RESERVED_1D[3]; /* +0x01D */ + + uint8_t INVERT; /* +0x020 */ + uint8_t _RESERVED_21[3]; /* +0x021 */ + + uint8_t UPDATE; /* +0x024 */ + uint8_t _RESERVED_25[3]; /* +0x025 */ + + PWM_AUX_PULSE_t PULSE[6]; + + uint8_t INTPOSEDGENA; /*= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of PWM_AUX SFRS. + */ +#define PWM_AUX_SFRS ((__IO PWM_AUX_SFRS_t *)0x40010800) + +#endif /* end of __PWM_AUX_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/pwm_sfr.h b/87400/drivers/hdf/sfrs/pwm_sfr.h new file mode 100644 index 0000000..88998fa --- /dev/null +++ b/87400/drivers/hdf/sfrs/pwm_sfr.h @@ -0,0 +1,412 @@ +/** + * @copyright 2023 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file pwm_sfr.h + */ + +#ifndef PWM_SFR_H__ +#define PWM_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for PWM. + */ +typedef struct { + + uint16_t PT0PERIOD; /*Period +0x000 */ + uint8_t _RESERVED_02[2]; /* +0x002 */ + + uint16_t PT0CV; /* +0x004 */ + uint8_t _RESERVED_06[2]; /* +0x006 */ + + uint16_t PT1PERIOD; /*Period +0x008 */ + uint8_t _RESERVED_0A[2]; /* +0x00A */ + + uint16_t PT1CV; /* +0x00C */ + uint8_t _RESERVED_0E[2]; /* +0x00E */ + + union { + struct { + uint8_t PT0RC : 1; + uint8_t PT0RS : 1; + uint8_t PT0RST : 1; /*!< PT0 reset */ + uint8_t PT0DTR : 1; /*!< PT0 dead-time counter reset */ + uint8_t : 1; /* (reserved) */ + uint8_t PT0CEVT : 1; /*!< PT0 count event */ + uint8_t PT0UPEC : 1; + uint8_t PT0UPES : 1; + uint8_t : 8; /* (reserved) */ + uint8_t PT1RC : 1; + uint8_t PT1RS : 1; + uint8_t PT1RST : 1; /*!< PT1 reset */ + uint8_t PT1DTR : 1; /*!< PT1 dead-time counter reset */ + uint8_t : 1; /* (reserved) */ + uint8_t PT1CEVT : 1; /*!< PT1 count event */ + uint8_t PT1UPEC : 1; + uint8_t PT1UPES : 1; + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } CTRL0R; /* +0x010 */ + + union { + struct { + uint8_t PT0PRES : 4; /*!< Prescaler select */ + uint8_t PT0R : 1; /*!< Timer PT0 run bit */ + uint8_t PT0UPE : 1; /*!< Timer PT0 update enable */ + uint8_t PT0CDWN : 1; /*!< Count direction of timer PT0 */ + uint8_t PT0MODE : 1; /*!< PT0 operating mode */ + uint8_t PT0CIN : 2; /*!< Input event select for PT0 counting */ + uint8_t PT0SSE : 1; /*!< PT0 single shot enable */ + uint8_t PT0HRSEL : 2; /*!< PT0 hardware run selection */ + uint8_t : 3; /* (reserved) */ + uint8_t PT1PRES : 4; /*!< Prescaler select */ + uint8_t PT1R : 1; /*!< Timer PT1 run bit */ + uint8_t PT1UPE : 1; /*!< Timer PT1 update enable */ + uint8_t PT1CDWN : 1; /*!< Count direction of timer PT1 */ + uint8_t PT1MODE : 1; /*!< PT1 operating mode */ + uint8_t PT1CIN : 2; /*!< Input event select for PT1 counting */ + uint8_t PT1SSE : 1; /*!< PT1 single shot enable */ + uint8_t PT1HRSEL : 2; /*!< PT1 hardware run selection */ + uint8_t CC1CNTS : 1; /*!< Compare Channel 1 counter selection */ + uint8_t CC2CNTS : 1; /*!< Compare Channel 2 counter selection */ + uint8_t CC3CNTS : 1; /*!< Compare Channel 3 counter selection */ + }; + uint32_t WORD; + } CTRL1R; /* +0x014 */ + + union { + struct { + uint8_t PT1TES : 4; + uint8_t PT1TED : 2; + uint8_t : 2; /* (reserved) */ + uint32_t : 24; /* (reserved) */ + }; + uint32_t WORD; + } TRIGR; /* +0x018 */ + + union { + struct { + uint8_t PT0DT : 8; + uint8_t PT1DT : 8; + uint8_t CCXDTE : 8; + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } DTCR; /* +0x01C */ + + union { + struct { + uint16_t PFALL0 : 16; /*!< State Pulse Fall CC0 */ + uint16_t PRISE0 : 16; /*!< State Pulse Rise CC0 */ + }; + uint32_t WORD; + } PULSE0R; /* +0x020 */ + + union { + struct { + uint16_t PFALL1 : 16; /*!< State Pulse Fall CC1 */ + uint16_t PRISE1 : 16; /*!< State Pulse Rise CC1 */ + }; + uint32_t WORD; + } PULSE1R; /* +0x024 */ + + union { + struct { + uint16_t PFALL2 : 16; /*!< State Pulse Fall CC2 */ + uint16_t PRISE2 : 16; /*!< State Pulse Rise CC2 */ + }; + uint32_t WORD; + } PULSE2R; /* +0x028 */ + + union { + struct { + uint16_t PFALL3 : 16; /*!< State Pulse Fall CC3 */ + uint16_t PRISE3 : 16; /*!< State Pulse Rise CC3 */ + }; + uint32_t WORD; + } PULSE3R; /* +0x02C */ + + union { + struct { + uint8_t CCXCS : 8; + uint8_t CC00PS : 1; + uint8_t CC01PS : 1; + uint8_t CC10PS : 1; + uint8_t CC11PS : 1; + uint8_t CC20PS : 1; + uint8_t CC21PS : 1; + uint8_t CC30PS : 1; + uint8_t CC31PS : 1; + uint8_t CC30IM : 8; + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } CMPSTATR; /* +0x030 */ + + union { + struct { + uint8_t CCXCSS : 8; + uint8_t CCXCSC : 8; + uint16_t : 16; /* (reserved) */ + }; + uint32_t WORD; + } CMPMDFIR; /* +0x034 */ + + uint8_t PSL; /* +0x038 */ + uint8_t _RESERVED_39[3]; /* +0x039 */ + + union { + struct { + uint8_t SWSEL : 3; + uint8_t : 1; /* (reserved) */ + uint8_t SWSYNC : 2; + uint8_t : 2; /* (reserved) */ + uint8_t MCUPEPT0U : 1; + uint8_t MCUPEPT0D : 1; + uint8_t MCUPEPT1U : 1; + uint8_t MCUPEPT1D : 1; + uint8_t : 4; /* (reserved) */ + uint16_t : 16; /* (reserved) */ + }; + uint32_t WORD; + } MCCTRLR; /* +0x03C */ + + union { + struct { + uint8_t MCPTN : 8; + uint8_t : 1; /* (reserved) */ + uint8_t NTIF : 1; + uint8_t : 6; /* (reserved) */ + uint8_t MCPTNS : 8; + uint8_t MCUPR : 8; + }; + uint32_t WORD; + } MCOUTR; /* +0x040 */ + + union { + struct { + uint8_t TRPSCM : 2; + uint8_t TRPFCM : 1; + uint8_t : 5; /* (reserved) */ + uint8_t TRPEN : 8; + uint8_t TRPPEN : 1; + uint8_t OCPFAST : 1; + uint8_t : 2; /* (reserved) */ + uint8_t OCPFILTS : 4; + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } TRPCTRLR; /* +0x044 */ + + union { + struct { + uint8_t CCXMODEN : 8; + uint8_t PT1MODEN : 8; + uint8_t MCEN : 8; + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } MODCTRLR; /* +0x048 */ + + union { + struct { + uint8_t PWM0RMP : 2; /*!< PWM0 remap selection */ + uint8_t : 2; /* (reserved) */ + uint8_t PWM1RMP : 2; /*!< PWM1 remap selection */ + uint8_t : 2; /* (reserved) */ + uint8_t PWM2RMP : 2; /*!< PWM2 remap selection */ + uint8_t : 2; /* (reserved) */ + uint8_t PWM3RMP : 2; /*!< PWM3 remap selection */ + uint8_t : 2; /* (reserved) */ + uint16_t : 16; /* (reserved) */ + }; + uint32_t WORD; + } CHREMAPR; /* +0x04C */ + + union { + struct { + uint16_t CMPTRIG0V : 16; /*!< Trigger0 Compare Value */ + uint8_t TRIG0PT : 1; /*!< Trigger0 Compare Counter Selection */ + uint8_t : 3; /* (reserved) */ + uint8_t TRIG0MD : 1; /*!< Trigger0 Compare Mode */ + uint8_t : 3; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } CMPTRIG0R; /* +0x050 */ + + union { + struct { + uint16_t CMPTRIG1V : 16; /*!< Trigger1 Compare Value */ + uint8_t TRIG1PT : 1; /*!< Trigger1 Compare Counter Selection */ + uint8_t : 3; /* (reserved) */ + uint8_t TRIG1MD : 1; /*!< Trigger1 Compare Mode */ + uint8_t : 3; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } CMPTRIG1R; /* +0x054 */ + + union { + struct { + uint8_t CC0INTOL : 2; /*!< CC0 interrupt output line selection */ + uint8_t CC1INTOL : 2; /*!< CC1 interrupt output line selection */ + uint8_t CC2INTOL : 2; /*!< CC2 interrupt output line selection */ + uint8_t CC3INTOL : 2; /*!< CC3 interrupt output line selection */ + uint8_t PT0INTOL : 2; /*!< PT0 interrupt output line selection */ + uint8_t PT1INTOL : 2; /*!< PT1 interrupt output line selection */ + uint8_t MCUPFINTOL : 2; /*!< MCUPF interrupt output line selection */ + uint8_t TRPINTOL : 2; /*!< TRPIS interrupt output line selection */ + uint8_t CT0FINTOL : 2; /*!< CT0F interrupt output line selection */ + uint8_t CT1FINTOL : 2; /*!< CT1F interrupt output line selection */ + uint8_t : 4; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } INTOLR; /* +0x058 */ + + union { + struct { + uint8_t CCXRIE : 4; /*!< CCx Rise-Match interrupt enable */ + uint8_t CCXFIE : 4; /*!< CCx Fall-Match interrupt enable */ + uint8_t PTXOMIE : 2; /*!< PTx One-Match interrupt enable */ + uint8_t PTXPMIE : 2; /*!< PTx Period-Match interrupt enable */ + uint8_t MCUPFIE : 1; /*!< Multi-channel mode updated interrupt enable */ + uint8_t : 2; /* (reserved) */ + uint8_t TRPIE : 1; /*!< Trap interrupt enable */ + uint8_t CT0IE : 1; /*!< Compare Trigger0 interrupt enable */ + uint8_t CT1IE : 1; /*!< Compare Trigger1 interrupt enable */ + uint8_t : 6; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } INTCTRLR; /* +0x05C */ + + union { + struct { + uint8_t CCXRS : 4; /*!< CCx Rise-Match Flag Set */ + uint8_t CCXFS : 4; /*!< CCx Fall-Match Flag Set */ + uint8_t PTXOMS : 2; /*!< PTx One-Match Flag Set */ + uint8_t PTXPMS : 2; /*!< PTx Period-Match Flag Set */ + uint8_t MCUPFS : 1; /*!< Multi-channel mode updated Flag Set */ + uint8_t : 2; /* (reserved) */ + uint8_t TRPISS : 1; /*!< Trap Interrupt Status Set */ + uint8_t CT0FS : 1; /*!< Compare Trigger0 Interrupt Status Set */ + uint8_t CT1FS : 1; /*!< Compare Trigger1 Interrupt Status Set */ + uint8_t : 6; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } INTSETR; /* +0x060 */ + + union { + struct { + uint8_t CCXRC : 4; /*!< CCx Rise-Match Flag Clear */ + uint8_t CCXFC : 4; /*!< CCx Fall-Match Flag Clear */ + uint8_t PTXOMC : 2; /*!< PTx One-Match Flag Clear */ + uint8_t PTXPMC : 2; /*!< PTx Period-Match Flag Clear */ + uint8_t MCUPFC : 1; /*!< Multi-channel mode updated Flag Clear */ + uint8_t TRPFC : 1; /*!< Trap Flag Clear */ + uint8_t : 1; /* (reserved) */ + uint8_t TRPISC : 1; /*!< Trap Interrupt Status Clear */ + uint8_t CT0FC : 1; /*!< Compare Trigger0 Interrupt Status Clear */ + uint8_t CT1FC : 1; /*!< Compare Trigger1 Interrupt Status Clear */ + uint8_t : 6; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } INTCLRR; /* +0x064 */ + + union { + struct { + uint8_t CCXR : 4; /*!< CCx Rise-Match Flag */ + uint8_t CCXF : 4; /*!< CCx Fall-Match Flag */ + uint8_t PTXOM : 2; /*!< PTx One-Match Flag */ + uint8_t PTXPM : 2; /*!< PTx Period-Match Flag */ + uint8_t MCUPF : 1; /*!< Multi-channel mode updated Flag */ + uint8_t TRPF : 1; /*!< Trap Flag */ + uint8_t TRPS : 1; /*!< Trap State */ + uint8_t TRPIS : 1; /*!< Trap Interrupt Status */ + uint8_t CT0F : 1; /*!< Compare trigger0 Flag */ + uint8_t CT1F : 1; /*!< Compare trigger1 Flag */ + uint8_t : 6; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } INTRAWSTATR; /* +0x068 */ + + union { + struct { + uint8_t CCXRIRQ : 4; /*!< Corresponding CCx Rise-Match interrupt active */ + uint8_t CCXFIRQ : 4; /*!< Corresponding CCx Fall-Match interrupt active */ + uint8_t PTXOMIRQ : 2; /*!< Corresponding PTx One-Match interrupt active */ + uint8_t PTXPMIRQ : 2; /*!< Corresponding PTx Period-Match interrupt active */ + uint8_t MCUPFIRQ : 1; /*!< Multi-channel mode updated interrupt active */ + uint8_t : 2; /* (reserved) */ + uint8_t TRPIRQ : 1; /*!< Trap interrupt active */ + uint8_t CT0IRQ : 1; /*!< Compare trigger0 interrupt active */ + uint8_t CT1IRQ : 1; /*!< Compare trigger1 interrupt active */ + uint8_t : 6; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } INTACTSTATR; /* +0x06C */ + +} PWM_SFRS_t; + +/* -------- End of section using anonymous unions and disabling warnings -------- */ +#if defined (__CC_ARM) + #pragma pop +#elif defined (__ICCARM__) + /* leave anonymous unions enabled */ +#elif (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of PWM SFRS. + */ +#define PWM_SFRS ((__IO PWM_SFRS_t *)0x40010000) + +#endif /* end of __PWM_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/sar_ctrl_sfr.h b/87400/drivers/hdf/sfrs/sar_ctrl_sfr.h new file mode 100644 index 0000000..6896b27 --- /dev/null +++ b/87400/drivers/hdf/sfrs/sar_ctrl_sfr.h @@ -0,0 +1,246 @@ +/** + * @copyright 2022 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file sar_ctrl_sfr.h + */ + +#ifndef SAR_CTRL_SFR_H__ +#define SAR_CTRL_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for SAR_CTRL. + */ + +typedef struct { + uint16_t DATA; /* +0x000 */ + uint16_t _RESERVED; /* +0x002 */ +}SAR_Data_t; + +typedef struct { + SAR_Data_t DATA[10]; /* +0x000 */ + union { + struct { + uint8_t : 7; /* (reserved) */ + uint8_t ROUND : 1; /*!< ADC round enable */ + uint8_t TRIGSRC : 8; /*!< SAR Converion Trigger Source Selects */ + uint8_t PWMAUXTRIGSEL : 4; /*!< SAR Converion Trigger Selects of PWMAUX */ + uint8_t PWMAUXCHSEL : 3; /*!< PWMAUX Trigger Channel Selects */ + uint8_t TRIGSEL : 1; /*!< SAR Trigger Signal Selects */ + uint8_t TRIGDLY : 8; /*!< trigger delay */ + }; + uint32_t WORD; + } SARCFG; /* +0x028 */ + + union { + struct { + uint8_t ADCSELVINVCMEXT : 1; /*!< Select External Inputs to ADC */ + uint8_t : 6; /* (reserved) */ + uint8_t SARAFEEN : 1; /*!< ADC AFE Enable */ + uint8_t SARPREAMPEN : 8; /*!< adc pre-amp enable */ + uint16_t : 16; /* (reserved) */ + }; + uint32_t WORD; + } AFECTRL; /* +0x02C */ + + union { + struct { + uint8_t SARENAREQ : 8; /*!< SAR ADC Enable */ + uint8_t : 2; /* (reserved) */ + uint8_t DIGRESET : 1; /*!< SAR Digital Part Reset */ + uint8_t : 5; /* (reserved) */ + uint8_t CONVERT : 1; /*!< ADC START/STATUS Register */ + uint8_t : 1; /* (reserved) */ + uint8_t CONT : 1; /*!< Continuous Conversion Enable */ + uint8_t : 5; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } SARCTRL; /* +0x030 */ + + union { + struct { + uint8_t SEQCNT : 4; /*!< Channel Sequence count */ + uint8_t : 1; /* (reserved) */ + uint32_t CH1SEL : 5; /*!< Channel1 Selection !!misaligned!! */ + uint8_t CH2SEL : 5; /*!< Channel2 Selection */ + uint8_t : 1; /* (reserved) */ + uint8_t CH3SEL : 8; /*!< Channel3 Selection */ + uint8_t CH4SEL : 5; /*!< Channel4 Selection */ + uint8_t : 2; /* (reserved) */ + uint8_t TESTBATTERYGAINCHOOSE : 1; /*!< VBAT Gain Select */ + }; + uint32_t WORD; + } ADCCHCONF; /* +0x034 */ + + union { + struct { + uint8_t CH5SEL : 5; /*!< Channel5 Selection */ + uint32_t CH6SEL : 5; /*!< Channel6 Selection !!misaligned!! */ + uint8_t CH7SEL : 5; /*!< Channel7 Selection */ + uint32_t CH8SEL : 5; /*!< Channel8 Selection !!misaligned!! */ + uint32_t CH9SEL : 5; /*!< Channel9 Selection !!misaligned!! */ + uint8_t CH10SEL : 5; /*!< Channel10 Selection */ + uint8_t : 2; /* (reserved) */ + }; + uint32_t WORD; + } ADCCHSELR; /* +0x038 */ + + union { + struct { + uint8_t SAR_INPUT_MODE_CH1 : 2; /*!< CH1 AFE Input Modes */ + uint8_t SAR_INPUT_MODE_CH2 : 2; /*!< CH2 AFE Input Modes */ + uint8_t SAR_INPUT_MODE_CH3 : 2; /*!< CH3 AFE Input Modes */ + uint8_t SAR_INPUT_MODE_CH4 : 2; /*!< CH4 AFE Input Modes */ + uint8_t SAR_INPUT_MODE_CH5 : 2; /*!< CH5 AFE Input Modes */ + uint8_t SAR_INPUT_MODE_CH6 : 2; /*!< CH6 AFE Input Modes */ + uint8_t SAR_INPUT_MODE_CH7 : 2; /*!< CH7 AFE Input Modes */ + uint8_t SAR_INPUT_MODE_CH8 : 2; /*!< CH8 AFE Input Modes */ + uint8_t SAR_INPUT_MODE_CH9 : 2; /*!< CH9 AFE Input Modes */ + uint8_t SAR_INPUT_MODE_CH10 : 2; /*!< CH10 AFE Input Modes */ + uint8_t SARINPUTGAINCH1 : 1; /*!< ADC Channel1 input gain */ + uint8_t SARINPUTGAINCH2 : 1; /*!< ADC Channel2 input gain */ + uint8_t SARINPUTGAINCH3 : 1; /*!< ADC Channel3 input gain */ + uint8_t SARINPUTGAINCH4 : 1; /*!< ADC Channel4 input gain */ + uint8_t SARINPUTGAINCH5 : 1; /*!< ADC Channel5 input gain */ + uint8_t SARINPUTGAINCH6 : 1; /*!< ADC Channel6 input gain */ + uint8_t SARINPUTGAINCH7 : 1; /*!< ADC Channel7 input gain */ + uint8_t SARINPUTGAINCH8 : 1; /*!< ADC Channel8 input gain */ + uint8_t SARINPUTGAINCH9 : 1; /*!< ADC Channel9 input gain */ + uint8_t SARINPUTGAINCH10 : 1; /*!< ADC Channel10 input gain */ + uint8_t : 2; /* (reserved) */ + }; + uint32_t WORD; + } ADCCHCTRL0R; /* +0x03C */ + + union { + struct { + uint8_t SAMPCYCCH1 : 4; /*!< Channel1 Sample cycle */ + uint8_t SAMPCYCCH2 : 4; /*!< Channel2 Sample cycle */ + uint8_t SAMPCYCCH3 : 4; /*!< Channel3 Sample cycle */ + uint8_t SAMPCYCCH4 : 4; /*!< Channel4 Sample cycle */ + uint8_t SAMPCYCCH5 : 4; /*!< Channel5 Sample cycle */ + uint8_t SAMPCYCCH6 : 4; /*!< Channel6 Sample cycle */ + uint8_t SAMPCYCCH7 : 4; /*!< Channel7 Sample cycle */ + uint8_t SAMPCYCCH8 : 4; /*!< Channel8 Sample cycle */ + }; + uint32_t WORD; + } ADCCHCTRL1R; /* +0x040 */ + + union { + struct { + uint8_t SAMPCYCCH9 : 4; /*!< Channel9 Sample cycle */ + uint8_t SAMPCYCCH10 : 4; /*!< Channel10 Sample cycle */ + uint8_t ADCVREFSELCH1 : 2; /*!< Channel1 adc vref select */ + uint8_t ADCVREFSELCH2 : 2; /*!< Channel2 adc vref select */ + uint8_t ADCVREFSELCH3 : 2; /*!< Channel3 adc vref select */ + uint8_t ADCVREFSELCH4 : 2; /*!< Channel4 adc vref select */ + uint8_t ADCVREFSELCH5 : 2; /*!< Channel5 adc vref select */ + uint8_t ADCVREFSELCH6 : 2; /*!< Channel6 adc vref select */ + uint8_t ADCVREFSELCH7 : 2; /*!< Channel7 adc vref select */ + uint8_t ADCVREFSELCH8 : 2; /*!< Channel8 adc vref select */ + uint8_t ADCVREFSELCH9 : 2; /*!< Channel9 adc vref select */ + uint8_t ADCVREFSELCH10 : 2; /*!< Channel10 adc vref select */ + uint8_t : 4; /* (reserved) */ + }; + uint32_t WORD; + } ADCCHCTRL2R; /* +0x044 */ + + union { + struct { + union { + struct { + uint8_t INT_CONV_DONE_ENA : 1; /*!< Convert Done Interrupt Enable */ + uint8_t INT_TRIG_CLASH_ENA : 1; /*!< Trigger Clash Interrupt Enable */ + uint8_t : 6; /* (reserved) */ + }; + uint8_t BYTE; + } ENABLE; + union { + struct { + uint8_t INT_CONV_DONE_CLR : 1; /*!< Convert Done Interrupt Clear */ + uint8_t INT_TRIG_CLASH_CLR : 1; /*!< Trigger Clash Interrupt Clear */ + uint8_t : 6; /* (reserved) */ + }; + uint8_t BYTE; + } CLEAR; + union { + struct { + uint8_t CONV_DONE : 1; /*!< Convert Done */ + uint8_t TRIG_CLASH : 1; /*!< Trigger Clash */ + uint8_t : 6; /* (reserved) */ + }; + uint8_t BYTE; + } STATUS; + union { + struct { + uint8_t INT_CONV_DONE : 1; /*!< Convert Done Interrupt */ + uint8_t INT_TRIG_CLASH : 1; /*!< Trigger Clash Interrupt */ + uint8_t : 6; /* (reserved) */ + }; + uint8_t BYTE; + } IRQ; + }; + uint32_t WORD; + } SARINT; /* +0x048 */ + + uint8_t SARCLKDIV; /*= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of SAR_CTRL SFRS. + */ +#define SAR_CTRL_SFRS ((__IO SAR_CTRL_SFRS_t *)0x40013400) + +#endif /* end of __SAR_CTRL_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/spi_sfr.h b/87400/drivers/hdf/sfrs/spi_sfr.h new file mode 100644 index 0000000..e501b1c --- /dev/null +++ b/87400/drivers/hdf/sfrs/spi_sfr.h @@ -0,0 +1,143 @@ +/** + * @copyright 2023 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file spi_sfr.h + */ + +#ifndef SPI_SFR_H__ +#define SPI_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for SPI. + */ +typedef struct { + + uint8_t RXDATA; /*= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of SPI SFRS. + */ +#define SPI_SFRS ((__IO SPI_SFRS_t *)0x40015000) + +#endif /* end of __SPI_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/sram_sfr.h b/87400/drivers/hdf/sfrs/sram_sfr.h new file mode 100644 index 0000000..71bddcc --- /dev/null +++ b/87400/drivers/hdf/sfrs/sram_sfr.h @@ -0,0 +1,74 @@ +/** + * @copyright 2023 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file sram_sfr.h + */ + +#ifndef SRAM_SFR_H__ +#define SRAM_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for SRAM. + */ +typedef struct { + + uint32_t DATA; /*= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of SRAM SFRS. + */ +#define SRAM_SFRS ((__IO SRAM_SFRS_t *)0x20000000) + +#endif /* end of __SRAM_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/syscfg_sfr.h b/87400/drivers/hdf/sfrs/syscfg_sfr.h new file mode 100644 index 0000000..a3b5872 --- /dev/null +++ b/87400/drivers/hdf/sfrs/syscfg_sfr.h @@ -0,0 +1,149 @@ +/** + * @copyright 2023 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file syscfg_sfr.h + */ + +#ifndef SYSCFG_SFR_H__ +#define SYSCFG_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for SYSCFG. + */ +typedef struct { + + union { + struct { + uint8_t GT1INS : 1; /*!< GT1IN Selection */ + uint8_t GT2INS : 1; /*!< GT2IN Selection */ + uint8_t GT3INS : 1; /*!< GT3IN Selection */ + uint8_t GT4INS : 1; /*!< GT4IN Selection */ + uint8_t GT5INS : 1; /*!< GT5IN Selection */ + uint8_t : 3; /* (reserved) */ + uint8_t GT1EXTS : 2; /*!< GT1EXT Selection */ + uint8_t GT2EXTS : 1; /*!< GT2EXT Selection */ + uint8_t GT3EXTS : 1; /*!< GT3EXT Selection */ + uint8_t GT4EXTS : 1; /*!< GT4EXT Selection */ + uint8_t GT5EXTS : 1; /*!< GT5EXT Selection */ + uint8_t : 2; /* (reserved) */ + uint8_t GT1EXTC : 1; /*!< GT1EXT Input Control */ + uint8_t GT2EXTC : 1; /*!< GT2EXT Input Control */ + uint8_t GT3EXTC : 1; /*!< GT3EXT Input Control */ + uint8_t : 5; /* (reserved) */ + uint8_t GT3TRIGS : 8; /*!< GT3 Trigger Select */ + }; + uint32_t WORD; + } GTINSR; /* +0x000 */ + + union { + struct { + uint8_t PT0HRS : 1; /*!< PT0HR Selection */ + uint8_t PT1HRS : 1; /*!< PT1HR Selection */ + uint8_t : 6; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + uint8_t PT0HRC : 1; /*!< PT0HR Input Control */ + uint8_t PT1HRC : 1; /*!< PT1HR Input Control */ + uint8_t : 6; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } PWMINSR; /* +0x004 */ + + uint8_t CTINS; /*= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of SYSCFG SFRS. + */ +#define SYSCFG_SFRS ((__IO SYSCFG_SFRS_t *)0x40020000) + +#endif /* end of __SYSCFG_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/sysctrla_sfr.h b/87400/drivers/hdf/sfrs/sysctrla_sfr.h new file mode 100644 index 0000000..e91d706 --- /dev/null +++ b/87400/drivers/hdf/sfrs/sysctrla_sfr.h @@ -0,0 +1,187 @@ +/** + * @copyright 2023 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file sysctrla_sfr.h + */ + +#ifndef SYSCTRLA_SFR_H__ +#define SYSCTRLA_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for SYSCTRLA. + */ +typedef struct { + + union { + struct { + uint8_t DEBUG_ACCESS_KEY : 8; + uint8_t : 8; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + uint8_t : 7; /* (reserved) */ + uint8_t DEBUG_LOCK : 1; + }; + uint32_t WORD; + } DEBUG_ACCESS_KEY; /* +0x000 */ + + uint8_t DEBUG_ACCESS_ENABLED; /* +0x004 */ + uint8_t _RESERVED_05[3]; /* +0x005 */ + + union { + struct { + uint8_t TRIM_ACCESS_KEY : 8; + uint8_t : 8; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + uint8_t : 7; /* (reserved) */ + uint8_t TRIM_LOCK : 1; + }; + uint32_t WORD; + } TRIM_ACCESS_KEY; /* +0x008 */ + + uint8_t TRIM_ACCESS_ENABLED; /* +0x00C */ + uint8_t _RESERVED_0D[3]; /* +0x00D */ + + union { + struct { + uint8_t PMU_ACCESS_KEY : 8; + uint8_t : 8; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + uint8_t : 7; /* (reserved) */ + uint8_t PMU_LOCK : 1; + }; + uint32_t WORD; + } PMU_ACCESS_KEY; /* +0x010 */ + + uint8_t PMU_ACCESS_ENABLED; /* +0x014 */ + uint8_t _RESERVED_15[3]; /* +0x015 */ + + union { + struct { + uint8_t TRIM_HF_RC : 8; /*!< High Frequency RC Oscillator trim */ + uint8_t SSCENA : 1; /*!< SSC Enable */ + uint8_t SSCDEEP : 3; /*!< SSC Depth Configuration */ + uint8_t : 4; /* (reserved) */ + uint8_t SSCDIV : 8; /*!< SSC Clock Divider */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } HF_OSC_TRIM; /* +0x018 */ + + union { + struct { + uint8_t TRIM_UHF_RC : 8; /*!< Ultra High Frequency RC Oscillator trim */ + uint8_t UHFSSCENA : 8; /*!< UHF Oscillator SSC Enable */ + uint16_t : 16; /* (reserved) */ + }; + uint32_t WORD; + } UHF_OSC_TRIM; /* +0x01C */ + + union { + struct { + uint8_t CSAPOWEN : 1; /*!< Current sensor amplifier enable */ + uint8_t CSAZEROEN : 1; /*!< Current sensor amplifier offset measure enable */ + uint8_t : 2; /* (reserved) */ + uint8_t CSAGBWSEL : 2; /*!< Current sensor amplifier bandwidth select */ + uint8_t CSAGAINSEL : 2; /*!< Current sensor amplifier gain select */ + uint8_t CSOCPPOWEN : 1; /*!< Current sensor over current protect enable */ + uint8_t CSOCPBWSEL : 1; /*!< Current sensor over current protect comparator high bandwidth enable */ + uint8_t : 2; /* (reserved) */ + uint8_t CSOCPHYSSEL : 2; /*!< Current sensor over current protect comparator hysteresis select */ + uint8_t CS_OCP_DAC_POW_EN : 1; /*!< Current sensor DAC enable */ + uint8_t : 1; /* (reserved) */ + uint8_t CS_OCP_DAC : 8; /*!< Current sensor over current protect threshold level select */ + uint8_t CS_OCP_STS : 1; /*!< Current Sensor Over Current Protection Status */ + uint8_t : 6; /* (reserved) */ + uint8_t CSOCPIE : 1; /*!< Current Sensor Over Current Protection interrupt enable */ + }; + uint32_t WORD; + } CSACTRLR; /* +0x020 */ + + union { + struct { + uint8_t DFTCODE : 8; + uint8_t : 8; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + uint8_t : 7; /* (reserved) */ + uint8_t DFT_LOCK : 1; + }; + uint32_t WORD; + } DFTCODE; /* +0x024 */ + + uint8_t DFT_ACCESS_ENABLED; /* +0x028 */ + uint8_t _RESERVED_29[3]; /* +0x029 */ + + union { + struct { + uint8_t : 1; /* (reserved) */ + uint8_t FLASHTESTMODESTART : 1; + uint8_t FLASHOSCTESTMODESTART : 1; + uint8_t SRAMBISTMODESTART : 1; + uint8_t : 4; /* (reserved) */ + uint32_t : 24; /* (reserved) */ + }; + uint32_t WORD; + } DFTTESTMODESTART; /* +0x02C */ + + uint32_t NAME; /*= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of SYSCTRLA SFRS. + */ +#define SYSCTRLA_SFRS ((__IO SYSCTRLA_SFRS_t *)0x40000800) + +#endif /* end of __SYSCTRLA_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/trimhv_sfr.h b/87400/drivers/hdf/sfrs/trimhv_sfr.h new file mode 100644 index 0000000..c47ec82 --- /dev/null +++ b/87400/drivers/hdf/sfrs/trimhv_sfr.h @@ -0,0 +1,250 @@ +/** + * @copyright 2023 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file trimhv_sfr.h + */ + +#ifndef TRIMHV_SFR_H__ +#define TRIMHV_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for TRIMHV. + */ +typedef struct { + + union { + struct { + uint8_t RETAIN0 : 8; /*!< Firmware scratch register 0 */ + uint8_t RETAIN1 : 8; /*!< Firmware scratch register 1 */ + uint16_t : 16; /* (reserved) */ + }; + uint32_t WORD; + } RETAIN; /* +0x000 */ + + uint8_t TRIM_LF_RC; /*= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of TRIMHV SFRS. + */ +#define TRIMHV_SFRS ((__IO TRIMHV_SFRS_t *)0x40000900) + +#endif /* end of __TRIMHV_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/uart0_sfr.h b/87400/drivers/hdf/sfrs/uart0_sfr.h new file mode 100644 index 0000000..1030fdf --- /dev/null +++ b/87400/drivers/hdf/sfrs/uart0_sfr.h @@ -0,0 +1,243 @@ +/** + * @copyright 2023 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file uart0_sfr.h + */ + +#ifndef UART0_SFR_H__ +#define UART0_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for UART0. + */ +typedef struct { + + union { + struct { + uint8_t BYTE : 8; /*!< Data */ + uint8_t DUMMY0 : 8; /*!< Data */ + uint8_t DUMMY1 : 8; /*!< Data */ + uint8_t DUMMY2 : 8; /*!< Data */ + }; + uint32_t WORD; + } DATA; /* +0x000 */ + + union { + struct { + uint8_t FRAMEERROR : 1; /*!< Framing Error */ + uint8_t PARITYERROR : 1; /*!< Parity Error */ + uint8_t BREAKERROR : 1; /*!< Break Error */ + uint8_t : 5; /* (reserved) */ + uint32_t : 24; /* (reserved) */ + }; + uint32_t WORD; + } UARTDATARECEIVESTATUS; /* +0x004 */ + + union { + struct { + uint8_t ENABLE : 1; + uint8_t ENABLE_STS : 1; /*!< Enable status */ + uint8_t UFIFOSOFTRESET : 1; /*!< FIFO SOFT RESET */ + uint8_t RXXFERCNTCLR : 1; /*!< RX Transfer Counter Clear */ + uint8_t TXXFERCNTCLR : 1; /*!< TX Transfer Counter Clear */ + uint8_t : 3; /* (reserved) */ + uint8_t SIZE : 2; /*!< Transmission word size */ + uint8_t STOP : 1; /*!< Stop bit control */ + uint8_t PARITY : 2; /*!< Parity: 00: NONE, 01: EVEN, 11: ODD */ + uint8_t STICKENA : 1; /*!< Sticky parity enable */ + uint8_t : 2; /* (reserved) */ + uint8_t : 6; /* (reserved) */ + uint8_t BREAKENA : 1; /*!< Break enable */ + uint8_t LOOPENA : 1; /*!< Loopback enable */ + uint8_t : 8; /* (reserved) */ + }; + uint32_t WORD; + } MSGCTRL; /* +0x008 */ + + union { + struct { + union { + struct { + uint8_t RXDONE : 1; /*!< Rx Data ready Interrupt Enable */ + uint8_t OVRUNERR : 1; /*!< RX FIFO overflow error Interrupt Enable */ + uint8_t FRMERR : 1; /*!< Framing error Interrupt Enable */ + uint8_t PRTYERR : 1; /*!< Parity Error Interrupt Enable */ + uint8_t BREAKKERR : 1; /*!< Break Error Interrupt Enable */ + uint8_t TXDONE : 1; /*!< Transmission done Interrupt Enable */ + uint8_t RXMULTDONE : 1; /*!< Multiple Receive Transactions Done Interrupt Enable */ + uint8_t TXMULTDONE : 1; /*!< Multiple Transmit Transactions Done Interrupt Enable */ + }; + uint8_t BYTE; + } ENABLE; + union { + struct { + uint8_t RXDONE : 1; /*!< Rx Data ready Interrupt Clear */ + uint8_t OVRUNERR : 1; /*!< RX FIFO overflow error Interrupt Clear */ + uint8_t FRMERR : 1; /*!< Framing error Interrupt Clear */ + uint8_t PRTYERR : 1; /*!< Parity Error Interrupt Clear */ + uint8_t BREAKKERR : 1; /*!< Break Error Interrupt Clear */ + uint8_t TXDONE : 1; /*!< Transmission done Interrupt Clear */ + uint8_t RXMULTDONE : 1; /*!< Multiple Receive Transactions Done Interrupt Clear */ + uint8_t TXMULTDONE : 1; /*!< Multiple Transmit Transactions Done Interrupt Clear */ + }; + uint8_t BYTE; + } CLEAR; + union { + struct { + uint8_t RXDONE : 1; /*!< Rx Data ready */ + uint8_t OVRUNERR : 1; /*!< RX FIFO overflow error */ + uint8_t FRMERR : 1; /*!< Framing error */ + uint8_t PRTYERR : 1; /*!< Parity Error */ + uint8_t BREAKKERR : 1; /*!< Break IRQ */ + uint8_t TXDONE : 1; /*!< Transmission is done */ + uint8_t RXMULTDONE : 1; /*!< Multiple Receive Transactions Done */ + uint8_t TXMULTDONE : 1; /*!< Multiple Transmit Transactions Done */ + }; + uint8_t BYTE; + } STATUS; + union { + struct { + uint8_t RXDONE : 1; /*!< Rx Data ready Interrupt */ + uint8_t OVRUNERR : 1; /*!< RX FIFO overflow error Interrupt */ + uint8_t FRMERR : 1; /*!< Framing error Interrupt */ + uint8_t PRTYERR : 1; /*!< Parity Error Interrupt */ + uint8_t BREAKKERR : 1; /*!< Break Error Interrupt */ + uint8_t TXDONE : 1; /*!< Transmission done Interrupt */ + uint8_t RXMULTDONE : 1; /*!< Multiple Receive Transactions Done Interrupt */ + uint8_t TXMULTDONE : 1; /*!< Multiple Transmit Transactions Done Interrupt */ + }; + uint8_t BYTE; + } IRQ; + }; + uint32_t WORD; + } UARTINT; /* +0x00C */ + + union { + struct { + union { + struct { + uint8_t RXTOUT : 1; /*!< Rx Time-out Interrupt Enable */ + uint8_t UNRUNERR : 1; /*!< RX FIFO underflow error Interrupt Enable */ + uint8_t OVERRUNERR : 1; /*!< TX FIFO overflow error Interrupt Enable */ + uint8_t : 5; /* (reserved) */ + }; + uint8_t BYTE; + } ENABLE; + union { + struct { + uint8_t RXTOUT : 1; /*!< Rx Time-out Interrupt Clear */ + uint8_t UNRUNERR : 1; /*!< RX FIFO underflow error Interrupt Clear */ + uint8_t OVERRUNERR : 1; /*!< TX FIFO overflow error Interrupt Clear */ + uint8_t : 5; /* (reserved) */ + }; + uint8_t BYTE; + } CLEAR; + union { + struct { + uint8_t RXTOUT : 1; /*!< Rx Time-out */ + uint8_t UNRUNERR : 1; /*!< RX FIFO underflow error */ + uint8_t OVERRUNERR : 1; /*!< TX FIFO overflow error */ + uint8_t : 5; /* (reserved) */ + }; + uint8_t BYTE; + } STATUS; + union { + struct { + uint8_t RXTOUT : 1; /*!< Rx Time-out Interrupt */ + uint8_t UNRUNERR : 1; /*!< RX FIFO underflow error Interrupt */ + uint8_t OVERRUNERR : 1; /*!< TX FIFO overflow error Interrupt */ + uint8_t : 5; /* (reserved) */ + }; + uint8_t BYTE; + } IRQ; + }; + uint32_t WORD; + } UARTINT2; /* +0x010 */ + + union { + struct { + uint8_t FDIV : 3; /*!< Fractional divider */ + uint32_t BAUDDIV : 16; /*!< Baud rate divider !!misaligned!! */ + uint8_t : 5; /* (reserved) */ + uint8_t OSR : 5; /*!< Over-sampling ratio */ + uint8_t UADVANCE : 1; /*!< Advance Register */ + uint8_t URETARD : 1; /*!< Retard Register */ + uint8_t : 1; /* (reserved) */ + }; + uint32_t WORD; + } UARTBAUD; /* +0x014 */ + + union { + struct { + uint8_t : 1; /* (reserved) */ + uint8_t RXEMPTY : 1; /*!< Reception FIFO empty */ + uint8_t RXFULL : 1; /*!< Reception FIFO full */ + uint8_t RXCOUNT : 5; /*!< Reception FIFO current count */ + uint8_t : 1; /* (reserved) */ + uint8_t TXEMPTY : 1; /*!< Transmit FIFO empty */ + uint8_t TXFULL : 1; /*!< Transmit FIFO full */ + uint8_t TXCOUNT : 5; /*!< Transmit FIFO current count */ + uint8_t RXMULTIPLEXFERDONECNT : 8; /*!< Receive Data Count Interrupt */ + uint8_t TXMULTIPLEXFERDONECNT : 8; /*!< Transmit Data Count Interrupt */ + }; + uint32_t WORD; + } UARTFIFO; /* +0x018 */ + +} UART0_SFRS_t; + +/* -------- End of section using anonymous unions and disabling warnings -------- */ +#if defined (__CC_ARM) + #pragma pop +#elif defined (__ICCARM__) + /* leave anonymous unions enabled */ +#elif (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of UART0 SFRS. + */ +#define UART0_SFRS ((__IO UART0_SFRS_t *)0x40015400) + +#endif /* end of __UART0_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/wdta_sfr.h b/87400/drivers/hdf/sfrs/wdta_sfr.h new file mode 100644 index 0000000..9f1bd31 --- /dev/null +++ b/87400/drivers/hdf/sfrs/wdta_sfr.h @@ -0,0 +1,140 @@ +/** + * @copyright 2023 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file wdta_sfr.h + */ + +#ifndef WDTA_SFR_H__ +#define WDTA_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for WDTA. + */ +typedef struct { + + union { + struct { + uint8_t UPDATE : 1; /*!< Window Mode Enable */ + uint8_t RUNNING : 1; /*!< Running status */ + uint8_t : 6; /* (reserved) */ + uint8_t TIMEOUTSEL : 3; /*!< Timeout select */ + uint8_t WINOPENENA : 1; /*!< Window Mode Enable */ + uint8_t WINOPENSEL : 2; /*!< Window Mode open select */ + uint8_t WINOPENFLAG : 1; /*!< Window open flag */ + uint8_t : 1; /* (reserved) */ + uint16_t : 16; /* (reserved) */ + }; + uint32_t WORD; + } CTRL; /* +0x000 */ + + union { + struct { + uint8_t STOP : 8; + uint8_t : 8; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + uint8_t : 7; /* (reserved) */ + uint8_t STOP_LOCK : 1; + }; + uint32_t WORD; + } STOPR; /* +0x004 */ + + uint32_t CLEAR; /* +0x008 */ + + uint32_t CNTVAL; /*= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of WDTA SFRS. + */ +#define WDTA_SFRS ((__IO WDTA_SFRS_t *)0x40001400) + +#endif /* end of __WDTA_SFR_H__ section */ + + diff --git a/87400/drivers/hdf/sfrs/wica_sfr.h b/87400/drivers/hdf/sfrs/wica_sfr.h new file mode 100644 index 0000000..862944c --- /dev/null +++ b/87400/drivers/hdf/sfrs/wica_sfr.h @@ -0,0 +1,103 @@ +/** + * @copyright 2023 indie Semiconductor + * + * This file is proprietary to indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of indie Semiconductor. + * + * @file wica_sfr.h + */ + +#ifndef WICA_SFR_H__ +#define WICA_SFR_H__ + +#include + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) + #pragma push + #pragma anon_unions +#elif defined (__ICCARM__) + #pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wc11-extensions" + #pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning 586 +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief A structure to represent Special Function Registers for WICA. + */ +typedef struct { + + union { + struct { + uint8_t LINS_ENA : 1; /*!< LIN Slave Wakeup Enable */ + uint8_t LINS_WICA_SEL : 1; /*!< LIN Slave Wakeup Source Select at Deepsleep mode */ + uint8_t TIMER_ENA : 1; /*!< Wakeup Timer Enable */ + uint8_t : 2; /* (reserved) */ + uint32_t TIMER_TAPSEL : 4; /*!< WakeUp Timer Tap Select !!misaligned!! */ + uint8_t LINS_IRQENA : 1; /*!< LIN Slave Wakeup Interrupt Enable */ + uint8_t TIMER_IRQENA : 1; /*!< Timer Wakeup Interrupt Enable */ + uint8_t : 1; /* (reserved) */ + uint8_t LINS_IRQCLR : 1; /*!< clear the wulin_irq */ + uint8_t : 1; /* (reserved) */ + uint8_t TIMER_IRQCLR : 1; /*!< clear the wutimer_irq */ + uint8_t : 1; /* (reserved) */ + uint16_t : 16; /* (reserved) */ + }; + uint32_t WORD; + } CTRL; /* +0x000 */ + + union { + struct { + uint8_t LINS : 1; /*!< LIN Slave Wakeup Status */ + uint8_t : 1; /* (reserved) */ + uint8_t TIMER : 1; /*!< Wakeup Timer Status */ + uint8_t : 5; /* (reserved) */ + uint8_t : 8; /* (reserved) */ + uint16_t TIMERCNT : 16; /*!< Wakeup Timer Counter Value */ + }; + uint32_t WORD; + } STATUS; /* +0x004 */ + +} WICA_SFRS_t; + +/* -------- End of section using anonymous unions and disabling warnings -------- */ +#if defined (__CC_ARM) + #pragma pop +#elif defined (__ICCARM__) + /* leave anonymous unions enabled */ +#elif (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic pop +#elif defined (__GNUC__) + /* anonymous unions are enabled by default */ +#elif defined (__TMS470__) + /* anonymous unions are enabled by default */ +#elif defined (__TASKING__) + #pragma warning restore +#elif defined (__CSMC__) + /* anonymous unions are enabled by default */ +#else + #warning Not supported compiler type +#endif + +/** + * @brief The starting address of WICA SFRS. + */ +#define WICA_SFRS ((__IO WICA_SFRS_t *)0x40001000) + +#endif /* end of __WICA_SFR_H__ section */ + + diff --git a/87400/drivers/hwcfg/inc/hwcfg.h b/87400/drivers/hwcfg/inc/hwcfg.h new file mode 100644 index 0000000..9ada60a --- /dev/null +++ b/87400/drivers/hwcfg/inc/hwcfg.h @@ -0,0 +1,143 @@ +/** + * @copyright 2017 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file hwcfg.h + */ + +#ifndef HWCFG_H__ +#define HWCFG_H__ + +#include + +/** + * @brief A structure to represent the data in hardware config block. + */ +typedef enum { + GAIN_05TIMES = 0x00U, /* 0.2V input */ + GAIN_10TIMES, /* 0.1V input */ + GAIN_20TIMES, /* 0.05V input */ + GAIN_40TIMES, /* 0.025V input */ +}CSA_GAIN_SEL_t; + + + +typedef struct{ + uint16_t V1_mV; /* mV */ + uint16_t V2_mV; /* mV */ + uint16_t V1_CODE; /* 2*ADC Code */ + uint16_t V2_CODE; /* 2*ADC Code */ + uint16_t GAIN; /* GAIN = real gain*1024 */ + uint16_t RESVD; +}CSA_GainParam_t; + + +typedef union { + struct { + uint32_t OSC_TRIM; + uint32_t OSC_TRIM_RESVD; + + uint16_t VDD3V3_LDO_TRIM; + uint16_t OCP_CTRL_3V3; + uint16_t VDD3V3EXT_LDO_TRIM; + uint16_t OCP_CTRL_3V3_EXT; + uint16_t VDD1V5_LDO_TRIM; + uint16_t OCP_CTRL_1V5; + uint16_t TRIM_BG; + uint16_t TRIM_VREF_BUF; + uint16_t TRIM_LF_RC; /* 250KHz trim code */ + uint16_t TRIM_HF_RC; /* 16MHz trim code */ + uint16_t TRIM_UHF_RC; /* 48MHz trim code */ + uint16_t LINS_TX_DUTY; + uint16_t LINS_TX_SLOPE; + uint16_t LINS_TX_BIAS_BOOST; + uint16_t S_BOR_1P5V; + uint16_t S_BOR_3P3V; + uint16_t RESVD0[44]; + + uint16_t BANDGAP_2TIMES_VOLT_mV; + uint16_t ADC_CODE_2P0V; /* adc code *2 SARINPUTGAIN=0x1(31/32),SAR_INPUT_MODE=0x1(VINP buffered, VINN external)adc_vref=2*vbg */ + uint16_t ADC_CODE_1P0V; /* adc code *2 SARINPUTGAIN=0x1(31/32),SAR_INPUT_MODE=0x1(VINP buffered, VINN external)adc_vref=2*vbg*/ + uint16_t ADC_CODE_0P5V; /* adc code *2 SARINPUTGAIN=0x1(31/32),SAR_INPUT_MODE=0x1(VINP buffered, VINN external)adc_vref=2*vbg*/ + uint16_t ADC_CODE_VBAT_13P5V; /* adc code *2 SARINPUTGAIN=0x1(31/32),SAR_INPUT_MODE=0x1(VINP buffered, VINN external)adc_vref=2*vbg gain=1/14*/ + uint16_t ADC_CODE_VBAT_8P0V; /* adc code *2 SARINPUTGAIN=0x1(31/32),SAR_INPUT_MODE=0x1(VINP buffered, VINN external)adc_vref=2*vbg gain=1/14*/ + uint16_t ADC_CODE_TEMPSENSOR_25C; /* adc code *2 SARINPUTGAIN=0x1(31/32),SAR_INPUT_MODE=0x1(VINP buffered, VINN external)adc_vref=2*vbg*/ + uint16_t VOLTAGE_TEMPSENSOR_25C; + + CSA_GainParam_t CSA_GAIN[4]; + uint16_t RESVD1[32]; + + uint32_t CHIP_NAME; + uint32_t CHIP_VERSION; + uint32_t LOT_ID_L; + uint32_t LOT_ID_H; + uint32_t YEAR; + uint16_t MON; + uint16_t DAY; + uint32_t CHIP_ID; + uint16_t CHIP_ID_B; + uint16_t CHIP_ID_S; + uint32_t TEST_PROGRAM_VERSION; + uint32_t RESVD4; + uint32_t TEST_FACTORY_L; + uint32_t TEST_FACTORY_H; + uint8_t LOTID[32]; + uint8_t RESVD2[168]; + uint32_t CRC32; + uint32_t RESVD3; + }; + uint8_t payload[512]; + +} HWCFG_SFRS_t; + +/** + * @brief The starting address of hardware config block. + */ +#define HWCFG_SFRS ((__IO HWCFG_SFRS_t *) (0x00020000)) +#define HWCFG_SFRS_START ((HWCFG_SFRS_t *) (0x00020000)) + +uint8_t HWCFG_Get3V3CalibValue(void); +uint8_t HWCFG_Get3V3_OCPValue(void); +uint8_t HWCFG_Get3V3_EXT_CalibValue(void); +uint8_t HWCFG_Get3V3_EXT_OCPValue(void); +uint8_t HWCFG_Get1V5_CalibValue(void); +uint8_t HWCFG_Get1V5_OCPValue(void); + +uint8_t HWCFG_GetBGBUFFCalibValue(void); + +uint8_t HWCFG_GetRCLFClockCalibValue(void); +uint8_t HWCFG_GetRCHFClockCalibValue(void); + +uint8_t HWCFG_GetLINS_TxDuty(void); +uint8_t HWCFG_GetLINS_SlewRate(void); +uint8_t HWCFG_GetLINS_TxBiasBoost(void); + +uint8_t HWCFG_Get1P5VBOR_Code(void); +uint8_t HWCFG_Get3P3VBOR_Code(void); + +uint16_t HWCFG_Get2VBG(void); +uint16_t HWCFG_GetADCCode_GPIO2V0(void); +uint16_t HWCFG_GetADCCode_GPIO1V0(void); +uint16_t HWCFG_GetADCCode_GPIO0V5(void); + +uint16_t HWCFG_GetADCCode_VBAT13V5(void); +uint16_t HWCFG_GetADCCode_VBAT8V0(void); +uint16_t HWCFG_GetADCCode_PTATLED(void); + +uint16_t HWCFG_GetCSA_GAIN_VOLT_LOW_mV(CSA_GAIN_SEL_t gain); +uint16_t HWCFG_GetCSA_GAIN_VOLT_HIGH_mV(CSA_GAIN_SEL_t gain); +uint16_t HWCFG_GetCSA_GAIN_VOLT_LOW_CODE(CSA_GAIN_SEL_t gain); +uint16_t HWCFG_GetCSA_GAIN_VOLT_HIGH_CODE(CSA_GAIN_SEL_t gain); +uint16_t HWCFG_GetCSA_GAIN(CSA_GAIN_SEL_t gain); + +uint32_t HWCFG_GetCalibrationVersion(void); +void HWCFG_TrimAccessUnlock(void); +void HWCFG_TrimAccessLockUntilReset(void); + + +#endif /* __HWCFG_H__ */ + diff --git a/87400/drivers/hwcfg/src/hwcfg.c b/87400/drivers/hwcfg/src/hwcfg.c new file mode 100644 index 0000000..926a023 --- /dev/null +++ b/87400/drivers/hwcfg/src/hwcfg.c @@ -0,0 +1,277 @@ +/** + * @copyright 2017 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file hwcfg.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ + +#include +#include +#include +#include +#include + +#define E_HWCFG_ADC_VBG (1200U*2U) /* 1.22V */ +#define E_HWCFG_ADC_PAT_LED (1066U) +#define E_HWCFG_ADC_VBAT_13V5 (1646U) +#define E_HWCFG_ADC_VBAT_8V0 (975U) + + +uint8_t HWCFG_Get3V3CalibValue(void) +{ + uint8_t trim = (uint8_t)HWCFG_SFRS->VDD3V3_LDO_TRIM; + if (trim == 0xFFU){ + trim = 0x00; + } + return trim; +} + +uint8_t HWCFG_Get3V3_OCPValue(void) +{ + uint8_t trim = (uint8_t)HWCFG_SFRS->OCP_CTRL_3V3; + if (trim == 0xFFU){ + trim = 0x08; + } + return trim; +} + +uint8_t HWCFG_Get3V3_EXT_CalibValue(void) +{ + uint8_t trim = (uint8_t)HWCFG_SFRS->VDD3V3EXT_LDO_TRIM; + if (trim == 0xFFU){ + trim = 0x00; + } + return trim; +} + +uint8_t HWCFG_Get3V3_EXT_OCPValue(void) +{ + uint8_t trim = (uint8_t)HWCFG_SFRS->OCP_CTRL_3V3_EXT; + if (trim == 0xFFU){ + trim = 0x08; + } + return trim; +} + + +uint8_t HWCFG_Get1V5_CalibValue(void) +{ + uint8_t trim = (uint8_t)HWCFG_SFRS->VDD1V5_LDO_TRIM; + if (trim == 0xFFU){ + trim = 0x00; + } + return trim; +} + +uint8_t HWCFG_Get1V5_OCPValue(void) +{ + uint8_t trim = (uint8_t)HWCFG_SFRS->OCP_CTRL_1V5; + if (trim == 0xFFU){ + trim = 0x04; + } + return trim; +} + +uint8_t HWCFG_GetBGBUFFCalibValue(void) +{ + uint8_t trim = (uint8_t)HWCFG_SFRS->TRIM_VREF_BUF; + if (trim == 0xFFU){ + trim = 0x00; + } + return trim; +} +uint8_t HWCFG_GetRCLFClockCalibValue(void) +{ + uint8_t trim = (uint8_t)HWCFG_SFRS->TRIM_LF_RC; + if (trim == 0xFFU){ + trim = 0xA0U; + } + return trim; +} + + +uint8_t HWCFG_GetRCHFClockCalibValue(void) +{ + uint8_t trim = (uint8_t)HWCFG_SFRS->TRIM_HF_RC; + if (trim == 0xFFU){ + trim = 0xA7; + } + return trim; +} + + +uint8_t HWCFG_GetLINS_TxDuty(void) +{ + uint8_t txDuty = (uint8_t)HWCFG_SFRS->LINS_TX_DUTY; + + if (txDuty == 0xFFU){ + txDuty = 5U; + } + return ((uint8_t)txDuty); +} + +uint8_t HWCFG_GetLINS_SlewRate(void) +{ + uint8_t slewRate = (uint8_t)HWCFG_SFRS->LINS_TX_SLOPE; + + if (slewRate == 0xFFU){ + slewRate = 4U; + } + return ((uint8_t)slewRate); +} + +uint8_t HWCFG_GetLINS_TxBiasBoost(void) +{ + uint8_t txBiasBoost = (uint8_t)HWCFG_SFRS->LINS_TX_BIAS_BOOST; + + if (txBiasBoost == 0xFFU){ + txBiasBoost = 4U; + } + return ((uint8_t)txBiasBoost); +} + +uint8_t HWCFG_Get1P5VBOR_Code(void) +{ + uint8_t bor1P5V = (uint8_t)HWCFG_SFRS->S_BOR_1P5V; + if (bor1P5V == 0xFFU){ + bor1P5V = 0x03U; + } + return (uint8_t)bor1P5V; +} + +uint8_t HWCFG_Get3P3VBOR_Code(void) +{ + uint8_t bor3P3V = (uint8_t)HWCFG_SFRS->S_BOR_3P3V; + if (bor3P3V == 0xFFU){ + bor3P3V = 0x0AU; + } + return (uint8_t)bor3P3V; +} + + +uint16_t HWCFG_Get2VBG(void) +{ + uint16_t volt = HWCFG_SFRS->BANDGAP_2TIMES_VOLT_mV;/* 2*VBG */ + + if (volt == 0xFFFFU){ + volt = E_HWCFG_ADC_VBG; + } + return volt; +} + +uint16_t HWCFG_GetADCCode_GPIO2V0(void) +{ + uint16_t code = HWCFG_SFRS->ADC_CODE_2P0V;/* GPIO 2000mV */ + return code; +} + +uint16_t HWCFG_GetADCCode_GPIO1V0(void) +{ + uint16_t code = HWCFG_SFRS->ADC_CODE_1P0V;/* GPIO 1000mV */ + return code; +} + +uint16_t HWCFG_GetADCCode_GPIO0V5(void) +{ + uint16_t code = HWCFG_SFRS->ADC_CODE_0P5V;/* GPIO 500mV */ + return code; +} + + +uint16_t HWCFG_GetADCCode_VBAT13V5(void) +{ + uint16_t volt = HWCFG_SFRS->ADC_CODE_VBAT_13P5V; + if (volt == 0xFFFFU){ + volt = E_HWCFG_ADC_VBAT_13V5; + } + return volt; +} + +uint16_t HWCFG_GetADCCode_VBAT8V0(void) +{ + uint16_t volt = HWCFG_SFRS->ADC_CODE_VBAT_8P0V; + if (volt == 0xFFFFU){ + volt = E_HWCFG_ADC_VBAT_8V0; + } + return volt; +} + + +uint16_t HWCFG_GetADCCode_PTATLED(void) +{ + uint16_t volt = HWCFG_SFRS->ADC_CODE_TEMPSENSOR_25C; + if (volt == 0xFFFFU){ + volt = E_HWCFG_ADC_PAT_LED; + } + return volt; +} + + +uint16_t HWCFG_GetCSA_GAIN_VOLT_LOW_mV(CSA_GAIN_SEL_t gain) +{ + uint16_t volt = HWCFG_SFRS->CSA_GAIN[gain].V1_mV; + if (volt == 0xFFFFU){ + volt = 1000U; + } + return volt; +} + +uint16_t HWCFG_GetCSA_GAIN_VOLT_HIGH_mV(CSA_GAIN_SEL_t gain) +{ + uint16_t volt = HWCFG_SFRS->CSA_GAIN[gain].V2_mV; + if (volt == 0xFFFFU){ + volt = 2000U; + } + return volt; +} + +uint16_t HWCFG_GetCSA_GAIN_VOLT_LOW_CODE(CSA_GAIN_SEL_t gain) +{ + uint16_t volt = HWCFG_SFRS->CSA_GAIN[gain].V1_CODE; + if (volt == 0xFFFFU){ + volt = 1800U; + } + return volt; +} + +uint16_t HWCFG_GetCSA_GAIN_VOLT_HIGH_CODE(CSA_GAIN_SEL_t gain) +{ + uint16_t volt = HWCFG_SFRS->CSA_GAIN[gain].V2_CODE; + if (volt == 0xFFFFU){ + volt = 3600U; + } + return volt; +} + +uint16_t HWCFG_GetCSA_GAIN(CSA_GAIN_SEL_t gain) +{ + uint16_t gainValue = HWCFG_SFRS->CSA_GAIN[(uint8_t)gain].GAIN; + if (gainValue == 0xFFFFU){ + gainValue = ((uint16_t)1U << gain)*1024U; + } + return gainValue; +} + +uint32_t HWCFG_GetCalibrationVersion(void) +{ + uint32_t version = HWCFG_SFRS->TEST_PROGRAM_VERSION; + return version; +} + +void HWCFG_TrimAccessUnlock(void) +{ + SYSCTRLA_SFRS->TRIM_ACCESS_KEY.TRIM_ACCESS_KEY = 0x0EU; +} + + +void HWCFG_TrimAccessLockUntilReset(void) +{ + SYSCTRLA_SFRS->TRIM_ACCESS_KEY.TRIM_LOCK = 1U; +} diff --git a/87400/generic_cortex.icf b/87400/generic_cortex.icf new file mode 100644 index 0000000..1ea6bb1 --- /dev/null +++ b/87400/generic_cortex.icf @@ -0,0 +1,165 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/ +/*-Editor annotation file-*/ +/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_4.xml" */ +/*-Specials-*/ +define symbol __ICFEDIT_intvec_start__ = 0x00000000; +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_IROM1_start__ = 0x00001000; +define symbol __ICFEDIT_region_IROM1_end__ = 0x0007FFFF; +define symbol __ICFEDIT_region_IROM2_start__ = 0x0; +define symbol __ICFEDIT_region_IROM2_end__ = 0x0; +define symbol __ICFEDIT_region_EROM1_start__ = 0x0; +define symbol __ICFEDIT_region_EROM1_end__ = 0x0; +define symbol __ICFEDIT_region_EROM2_start__ = 0x0; +define symbol __ICFEDIT_region_EROM2_end__ = 0x0; +define symbol __ICFEDIT_region_EROM3_start__ = 0x0; +define symbol __ICFEDIT_region_EROM3_end__ = 0x0; +define symbol __ICFEDIT_region_IRAM1_start__ = 0x20000000; +define symbol __ICFEDIT_region_IRAM1_end__ = 0x2000FFFF; +define symbol __ICFEDIT_region_IRAM2_start__ = 0x0; +define symbol __ICFEDIT_region_IRAM2_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM1_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM1_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM2_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM2_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM3_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM3_end__ = 0x0; +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = 0x400; +define symbol __ICFEDIT_size_proc_stack__ = 0x0; +define symbol __ICFEDIT_size_heap__ = 0x800; +/**** End of ICF editor section. ###ICF###*/ + +define memory mem with size = 4G; +define symbol use_IROM1 = (__ICFEDIT_region_IROM1_start__ != 0x0 || __ICFEDIT_region_IROM1_end__ != 0x0); +define symbol use_IROM2 = (__ICFEDIT_region_IROM2_start__ != 0x0 || __ICFEDIT_region_IROM2_end__ != 0x0); +define symbol use_EROM1 = (__ICFEDIT_region_EROM1_start__ != 0x0 || __ICFEDIT_region_EROM1_end__ != 0x0); +define symbol use_EROM2 = (__ICFEDIT_region_EROM2_start__ != 0x0 || __ICFEDIT_region_EROM2_end__ != 0x0); +define symbol use_EROM3 = (__ICFEDIT_region_EROM3_start__ != 0x0 || __ICFEDIT_region_EROM3_end__ != 0x0); +define symbol use_IRAM1 = (__ICFEDIT_region_IRAM1_start__ != 0x0 || __ICFEDIT_region_IRAM1_end__ != 0x0); +define symbol use_IRAM2 = (__ICFEDIT_region_IRAM2_start__ != 0x0 || __ICFEDIT_region_IRAM2_end__ != 0x0); +define symbol use_ERAM1 = (__ICFEDIT_region_ERAM1_start__ != 0x0 || __ICFEDIT_region_ERAM1_end__ != 0x0); +define symbol use_ERAM2 = (__ICFEDIT_region_ERAM2_start__ != 0x0 || __ICFEDIT_region_ERAM2_end__ != 0x0); +define symbol use_ERAM3 = (__ICFEDIT_region_ERAM3_start__ != 0x0 || __ICFEDIT_region_ERAM3_end__ != 0x0); + +if (use_IROM1) +{ + define region IROM1_region = mem:[from __ICFEDIT_region_IROM1_start__ to __ICFEDIT_region_IROM1_end__]; +} +else +{ + define region IROM1_region = []; +} + +if (use_IROM2) +{ + define region IROM2_region = mem:[from __ICFEDIT_region_IROM2_start__ to __ICFEDIT_region_IROM2_end__]; +} +else +{ + define region IROM2_region = []; +} +define region IROM_region = IROM1_region | IROM2_region; + +if (use_EROM1) +{ + define region EROM1_region = mem:[from __ICFEDIT_region_EROM1_start__ to __ICFEDIT_region_EROM1_end__]; +} +else +{ + define region EROM1_region = []; +} +if (use_EROM2) +{ + define region EROM2_region = mem:[from __ICFEDIT_region_EROM2_start__ to __ICFEDIT_region_EROM2_end__]; +} +else +{ + define region EROM2_region = []; +} +if (use_EROM3) +{ + define region EROM3_region = mem:[from __ICFEDIT_region_EROM3_start__ to __ICFEDIT_region_EROM3_end__]; +} +else +{ + define region EROM3_region = []; +} +define region EROM_region = EROM1_region | EROM2_region | EROM3_region; + +if (use_IRAM1) +{ + define region IRAM1_region = mem:[from __ICFEDIT_region_IRAM1_start__ to __ICFEDIT_region_IRAM1_end__]; +} +else +{ + define region IRAM1_region = []; +} +if (use_IRAM2) +{ + define region IRAM2_region = mem:[from __ICFEDIT_region_IRAM2_start__ to __ICFEDIT_region_IRAM2_end__]; +} +else +{ + define region IRAM2_region = []; +} +define region IRAM_region = IRAM1_region | IRAM2_region; + +if (use_ERAM1) +{ + define region ERAM1_region = mem:[from __ICFEDIT_region_ERAM1_start__ to __ICFEDIT_region_ERAM1_end__]; +} +else +{ + define region ERAM1_region = []; +} +if (use_ERAM2) +{ + define region ERAM2_region = mem:[from __ICFEDIT_region_ERAM2_start__ to __ICFEDIT_region_ERAM2_end__]; +} +else +{ + define region ERAM2_region = []; +} +if (use_ERAM3) +{ + define region ERAM3_region = mem:[from __ICFEDIT_region_ERAM3_start__ to __ICFEDIT_region_ERAM3_end__]; +} +else +{ + define region ERAM3_region = []; +} +define region ERAM_region = ERAM1_region | ERAM2_region | ERAM3_region; + +do not initialize { section .noinit }; +initialize by copy { readwrite }; +if (isdefinedsymbol(__USE_DLIB_PERTHREAD)) +{ + // Required in a multi-threaded application + initialize by copy with packing = none { section __DLIB_PERTHREAD }; +} + +place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; + +if (!isempty(IROM_region)) +{ + place in IROM_region { readonly }; +} + +if (!isempty(EROM_region)) +{ + place in EROM_region { readonly section application_specific_ro }; +} + +if (!isempty(IRAM_region)) +{ + define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; + define block PROC_STACK with alignment = 8, size = __ICFEDIT_size_proc_stack__ { }; + define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; + place in IRAM_region { readwrite, block CSTACK, block PROC_STACK, block HEAP }; +} + +if (!isempty(ERAM_region)) +{ + place in ERAM_region { readwrite section application_specific_rw }; +} diff --git a/87400/metaLite.eww b/87400/metaLite.eww new file mode 100644 index 0000000..c62c9e5 --- /dev/null +++ b/87400/metaLite.eww @@ -0,0 +1,10 @@ + + + + $WS_DIR$\application.ewp + + + $WS_DIR$\application_based_on_bootloader.ewp + + + diff --git a/87400/metaLite_app.icf b/87400/metaLite_app.icf new file mode 100644 index 0000000..2ea7068 --- /dev/null +++ b/87400/metaLite_app.icf @@ -0,0 +1,31 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/ +/*-Editor annotation file-*/ +/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */ +/*-Specials-*/ +define symbol __ICFEDIT_intvec_start__ = 0x00000000; +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_ROM_start__ = 0x00000000; +define symbol __ICFEDIT_region_ROM_end__ = 0x0000BFFF; +define symbol __ICFEDIT_region_RAM_start__ = 0x20000000; +define symbol __ICFEDIT_region_RAM_end__ = 0x20003FFF; +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = 0x800; +define symbol __ICFEDIT_size_heap__ = 0x800; +/**** End of ICF editor section. ###ICF###*/ + + +define memory mem with size = 4G; +define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__]; +define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__]; + +define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; +define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; + +initialize by copy { readwrite }; +do not initialize { section .noinit }; + +place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; + +place in ROM_region { readonly }; +place in RAM_region { readwrite, + block CSTACK, block HEAP }; \ No newline at end of file diff --git a/87400/metaLite_app_based_on_bootloader.icf b/87400/metaLite_app_based_on_bootloader.icf new file mode 100644 index 0000000..4640121 --- /dev/null +++ b/87400/metaLite_app_based_on_bootloader.icf @@ -0,0 +1,31 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/ +/*-Editor annotation file-*/ +/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */ +/*-Specials-*/ +define symbol __ICFEDIT_intvec_start__ = 0x00001C08; +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_ROM_start__ = 0x00001C08; +define symbol __ICFEDIT_region_ROM_end__ = 0x0000AC00; // //7K - 43K +define symbol __ICFEDIT_region_RAM_start__ = 0x20001800; // 10K RAM for APP +define symbol __ICFEDIT_region_RAM_end__ = 0x20003FFF; +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = 0x800; +define symbol __ICFEDIT_size_heap__ = 0x800; +/**** End of ICF editor section. ###ICF###*/ + + +define memory mem with size = 4G; +define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__]; +define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__]; + +define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; +define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; + +initialize by copy { readwrite }; +do not initialize { section .noinit }; + +place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; + +place in ROM_region { readonly }; +place in RAM_region { readwrite, + block CSTACK, block HEAP }; \ No newline at end of file diff --git a/87400/settings/application.Release.cspy.bat b/87400/settings/application.Release.cspy.bat new file mode 100644 index 0000000..fe5a797 --- /dev/null +++ b/87400/settings/application.Release.cspy.bat @@ -0,0 +1,40 @@ +@REM This batch file has been generated by the IAR Embedded Workbench +@REM C-SPY Debugger, as an aid to preparing a command line for running +@REM the cspybat command line utility using the appropriate settings. +@REM +@REM Note that this file is generated every time a new debug session +@REM is initialized, so you may want to move or rename the file before +@REM making changes. +@REM +@REM You can launch cspybat by typing the name of this batch file followed +@REM by the name of the debug file (usually an ELF/DWARF or UBROF file). +@REM +@REM Read about available command line parameters in the C-SPY Debugging +@REM Guide. Hints about additional command line parameters that may be +@REM useful in specific cases: +@REM --download_only Downloads a code image without starting a debug +@REM session afterwards. +@REM --silent Omits the sign-on message. +@REM --timeout Limits the maximum allowed execution time. +@REM + + +@echo off + +if not "%~1" == "" goto debugFile + +@echo on + +"E:\IAR Systems\Embedded Workbench 8.3\common\bin\cspybat" -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.A0.0.91_lin3.0.3\settings\application.Release.general.xcl" --backend -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.A0.0.91_lin3.0.3\settings\application.Release.driver.xcl" + +@echo off +goto end + +:debugFile + +@echo on + +"E:\IAR Systems\Embedded Workbench 8.3\common\bin\cspybat" -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.A0.0.91_lin3.0.3\settings\application.Release.general.xcl" "--debug_file=%~1" --backend -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.A0.0.91_lin3.0.3\settings\application.Release.driver.xcl" + +@echo off +:end \ No newline at end of file diff --git a/87400/settings/application.Release.cspy.ps1 b/87400/settings/application.Release.cspy.ps1 new file mode 100644 index 0000000..d6f5d30 --- /dev/null +++ b/87400/settings/application.Release.cspy.ps1 @@ -0,0 +1,31 @@ +param([String]$debugfile = ""); + +# This powershell file has been generated by the IAR Embedded Workbench +# C - SPY Debugger, as an aid to preparing a command line for running +# the cspybat command line utility using the appropriate settings. +# +# Note that this file is generated every time a new debug session +# is initialized, so you may want to move or rename the file before +# making changes. +# +# You can launch cspybat by typing Powershell.exe -File followed by the name of this batch file, followed +# by the name of the debug file (usually an ELF / DWARF or UBROF file). +# +# Read about available command line parameters in the C - SPY Debugging +# Guide. Hints about additional command line parameters that may be +# useful in specific cases : +# --download_only Downloads a code image without starting a debug +# session afterwards. +# --silent Omits the sign - on message. +# --timeout Limits the maximum allowed execution time. +# + + +if ($debugfile -eq "") +{ +& "E:\IAR Systems\Embedded Workbench 8.3\common\bin\cspybat" -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.A0.0.91_lin3.0.3\settings\application.Release.general.xcl" --backend -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.A0.0.91_lin3.0.3\settings\application.Release.driver.xcl" +} +else +{ +& "E:\IAR Systems\Embedded Workbench 8.3\common\bin\cspybat" -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.A0.0.91_lin3.0.3\settings\application.Release.general.xcl" --debug_file=$debugfile --backend -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.A0.0.91_lin3.0.3\settings\application.Release.driver.xcl" +} diff --git a/87400/settings/application.Release.driver.xcl b/87400/settings/application.Release.driver.xcl new file mode 100644 index 0000000..cc66f99 --- /dev/null +++ b/87400/settings/application.Release.driver.xcl @@ -0,0 +1,29 @@ +"--endian=little" + +"--cpu=Cortex-M0" + +"--fpu=None" + +"-p" + +"E:\IAR Systems\Embedded Workbench 8.3\arm\CONFIG\debugger\IndieSemi\metaLite.ddf" + +"--drv_verify_download" + +"--semihosting" + +"--device=metaLite" + +"--drv_communication=USB0" + +"--drv_interface_speed=1000" + +"--jlink_reset_strategy=0,0" + +"--drv_interface=SWD" + +"--drv_catch_exceptions=0x000" + + + + diff --git a/87400/settings/application.Release.general.xcl b/87400/settings/application.Release.general.xcl new file mode 100644 index 0000000..7346d45 --- /dev/null +++ b/87400/settings/application.Release.general.xcl @@ -0,0 +1,13 @@ +"E:\IAR Systems\Embedded Workbench 8.3\arm\bin\armproc.dll" + +"E:\IAR Systems\Embedded Workbench 8.3\arm\bin\armjlink2.dll" + +"F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.A0.0.91_lin3.0.3\Release\Exe\metaLite_app.out" + +--plugin="E:\IAR Systems\Embedded Workbench 8.3\arm\bin\armbat.dll" + +--flash_loader="E:\IAR Systems\Embedded Workbench 8.3\arm\config\flashloader\IndieSemi\FlashLoader_metaLite.board" + + + + diff --git a/87400/settings/application.crun b/87400/settings/application.crun new file mode 100644 index 0000000..d71ea55 --- /dev/null +++ b/87400/settings/application.crun @@ -0,0 +1,13 @@ + + + 1 + + + * + * + * + 0 + 1 + + + diff --git a/87400/settings/application.reggroups b/87400/settings/application.reggroups new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/87400/settings/application.reggroups @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/87400/settings/application_Release.jlink b/87400/settings/application_Release.jlink new file mode 100644 index 0000000..5acf46d --- /dev/null +++ b/87400/settings/application_Release.jlink @@ -0,0 +1,39 @@ +[BREAKPOINTS] +ForceImpTypeAny = 0 +ShowInfoWin = 1 +EnableFlashBP = 2 +BPDuringExecution = 0 +[CFI] +CFISize = 0x00 +CFIAddr = 0x00 +[CPU] +MonModeVTableAddr = 0xFFFFFFFF +MonModeDebug = 0 +MaxNumAPs = 0 +LowPowerHandlingMode = 0 +OverrideMemMap = 0 +AllowSimulation = 1 +ScriptFile="" +[FLASH] +CacheExcludeSize = 0x00 +CacheExcludeAddr = 0x00 +MinNumBytesFlashDL = 0 +SkipProgOnCRCMatch = 1 +VerifyDownload = 1 +AllowCaching = 1 +EnableFlashDL = 2 +Override = 1 +Device="iND87400" +[GENERAL] +WorkRAMSize = 0x00 +WorkRAMAddr = 0x00 +RAMUsageLimit = 0x00 +[SWO] +SWOLogFile="" +[MEM] +RdOverrideOrMask = 0x00 +RdOverrideAndMask = 0xFFFFFFFF +RdOverrideAddr = 0xFFFFFFFF +WrOverrideOrMask = 0x00 +WrOverrideAndMask = 0xFFFFFFFF +WrOverrideAddr = 0xFFFFFFFF diff --git a/87400/settings/application_based_on_bootloader.Release.cspy.bat b/87400/settings/application_based_on_bootloader.Release.cspy.bat new file mode 100644 index 0000000..f9b250c --- /dev/null +++ b/87400/settings/application_based_on_bootloader.Release.cspy.bat @@ -0,0 +1,40 @@ +@REM This batch file has been generated by the IAR Embedded Workbench +@REM C-SPY Debugger, as an aid to preparing a command line for running +@REM the cspybat command line utility using the appropriate settings. +@REM +@REM Note that this file is generated every time a new debug session +@REM is initialized, so you may want to move or rename the file before +@REM making changes. +@REM +@REM You can launch cspybat by typing the name of this batch file followed +@REM by the name of the debug file (usually an ELF/DWARF or UBROF file). +@REM +@REM Read about available command line parameters in the C-SPY Debugging +@REM Guide. Hints about additional command line parameters that may be +@REM useful in specific cases: +@REM --download_only Downloads a code image without starting a debug +@REM session afterwards. +@REM --silent Omits the sign-on message. +@REM --timeout Limits the maximum allowed execution time. +@REM + + +@echo off + +if not "%~1" == "" goto debugFile + +@echo on + +"E:\IAR Systems\Embedded Workbench 8.3\common\bin\cspybat" -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.A0.0.91_lin3.0.3\settings\application_based_on_bootloader.Release.general.xcl" --backend -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.A0.0.91_lin3.0.3\settings\application_based_on_bootloader.Release.driver.xcl" + +@echo off +goto end + +:debugFile + +@echo on + +"E:\IAR Systems\Embedded Workbench 8.3\common\bin\cspybat" -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.A0.0.91_lin3.0.3\settings\application_based_on_bootloader.Release.general.xcl" "--debug_file=%~1" --backend -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.A0.0.91_lin3.0.3\settings\application_based_on_bootloader.Release.driver.xcl" + +@echo off +:end \ No newline at end of file diff --git a/87400/settings/application_based_on_bootloader.Release.cspy.ps1 b/87400/settings/application_based_on_bootloader.Release.cspy.ps1 new file mode 100644 index 0000000..82fce16 --- /dev/null +++ b/87400/settings/application_based_on_bootloader.Release.cspy.ps1 @@ -0,0 +1,31 @@ +param([String]$debugfile = ""); + +# This powershell file has been generated by the IAR Embedded Workbench +# C - SPY Debugger, as an aid to preparing a command line for running +# the cspybat command line utility using the appropriate settings. +# +# Note that this file is generated every time a new debug session +# is initialized, so you may want to move or rename the file before +# making changes. +# +# You can launch cspybat by typing Powershell.exe -File followed by the name of this batch file, followed +# by the name of the debug file (usually an ELF / DWARF or UBROF file). +# +# Read about available command line parameters in the C - SPY Debugging +# Guide. Hints about additional command line parameters that may be +# useful in specific cases : +# --download_only Downloads a code image without starting a debug +# session afterwards. +# --silent Omits the sign - on message. +# --timeout Limits the maximum allowed execution time. +# + + +if ($debugfile -eq "") +{ +& "E:\IAR Systems\Embedded Workbench 8.3\common\bin\cspybat" -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.A0.0.91_lin3.0.3\settings\application_based_on_bootloader.Release.general.xcl" --backend -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.A0.0.91_lin3.0.3\settings\application_based_on_bootloader.Release.driver.xcl" +} +else +{ +& "E:\IAR Systems\Embedded Workbench 8.3\common\bin\cspybat" -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.A0.0.91_lin3.0.3\settings\application_based_on_bootloader.Release.general.xcl" --debug_file=$debugfile --backend -f "F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.A0.0.91_lin3.0.3\settings\application_based_on_bootloader.Release.driver.xcl" +} diff --git a/87400/settings/application_based_on_bootloader.Release.driver.xcl b/87400/settings/application_based_on_bootloader.Release.driver.xcl new file mode 100644 index 0000000..86a482e --- /dev/null +++ b/87400/settings/application_based_on_bootloader.Release.driver.xcl @@ -0,0 +1,27 @@ +"--endian=little" + +"--cpu=Cortex-M0" + +"--fpu=None" + +"--drv_verify_download" + +"--semihosting=none" + +"--device=metaLite" + +"--drv_communication=USB0" + +"--drv_interface_speed=auto" + +"--jlink_initial_speed=1000" + +"--jlink_reset_strategy=0,0" + +"--drv_interface=SWD" + +"--drv_catch_exceptions=0x000" + + + + diff --git a/87400/settings/application_based_on_bootloader.Release.general.xcl b/87400/settings/application_based_on_bootloader.Release.general.xcl new file mode 100644 index 0000000..9bf1f74 --- /dev/null +++ b/87400/settings/application_based_on_bootloader.Release.general.xcl @@ -0,0 +1,13 @@ +"E:\IAR Systems\Embedded Workbench 8.3\arm\bin\armproc.dll" + +"E:\IAR Systems\Embedded Workbench 8.3\arm\bin\armjlink2.dll" + +"F:\FCB_project\temp\K74\K74B_CODE\libdev_metaLite_app.A0.0.91_lin3.0.3\Release\Exe\metaLite_app_bootloader.out" + +--plugin="E:\IAR Systems\Embedded Workbench 8.3\arm\bin\armbat.dll" + +--flash_loader="E:\IAR Systems\Embedded Workbench 8.3\arm\config\flashloader\IndieSemi\FlashLoader_metaLite.board" + + + + diff --git a/87400/settings/application_based_on_bootloader.crun b/87400/settings/application_based_on_bootloader.crun new file mode 100644 index 0000000..d71ea55 --- /dev/null +++ b/87400/settings/application_based_on_bootloader.crun @@ -0,0 +1,13 @@ + + + 1 + + + * + * + * + 0 + 1 + + + diff --git a/87400/settings/application_based_on_bootloader_Release.jlink b/87400/settings/application_based_on_bootloader_Release.jlink new file mode 100644 index 0000000..838da55 --- /dev/null +++ b/87400/settings/application_based_on_bootloader_Release.jlink @@ -0,0 +1,35 @@ +[BREAKPOINTS] +ForceImpTypeAny = 0 +ShowInfoWin = 1 +EnableFlashBP = 2 +BPDuringExecution = 0 +[CFI] +CFISize = 0x00 +CFIAddr = 0x00 +[CPU] +OverrideMemMap = 0 +AllowSimulation = 1 +ScriptFile="" +[FLASH] +CacheExcludeSize = 0x00 +CacheExcludeAddr = 0x00 +MinNumBytesFlashDL = 0 +SkipProgOnCRCMatch = 1 +VerifyDownload = 1 +AllowCaching = 1 +EnableFlashDL = 2 +Override = 1 +Device="Unspecified" +[GENERAL] +WorkRAMSize = 0x00 +WorkRAMAddr = 0x00 +RAMUsageLimit = 0x00 +[SWO] +SWOLogFile="" +[MEM] +RdOverrideOrMask = 0x00 +RdOverrideAndMask = 0xFFFFFFFF +RdOverrideAddr = 0xFFFFFFFF +WrOverrideOrMask = 0x00 +WrOverrideAndMask = 0xFFFFFFFF +WrOverrideAddr = 0xFFFFFFFF diff --git a/87400/usr/common/appConfig.h b/87400/usr/common/appConfig.h new file mode 100644 index 0000000..82143eb --- /dev/null +++ b/87400/usr/common/appConfig.h @@ -0,0 +1,54 @@ +#ifndef APP_CONFIG_H__ +#define APP_CONFIG_H__ + +#include +#include +#include + +#define PRAGMA(x) _Pragma(#x) +#define BEGIN_PACK PRAGMA(pack(push, 1)) +#define END_PACK PRAGMA(pack(pop)) + +#define LIN_STACK_TYPE_LIN2_2A (0U) +#define LIN_STACK_TYPE_SAEJ2602 (1U) +#define LIN_STACK_TYPE_PRIVATE (2U) +#define LIN_STACK_TYPE_ISO17987 LIN_STACK_TYPE_LIN2_2A + +#define LIN_STACK_TYPE LIN_STACK_TYPE_LIN2_2A + + +#define SDK_APPL_VERSION (0x0090U) +/* ************************hardware config ********************************/ +#define MAIN_CPU_CLOCK 16U /*MHz*/ + +#if MAIN_CPU_CLOCK == 16U + #define SYS_MAIN_CLOCK_DIV CLOCK_DIV_1 +#else + #error MAIN_CPU_CLOCK MUST BE 16MHz!*/ +#endif + +#define ROOM_TEMPERATURE (24) /*Celsius degree*/ + + +/* ************************PWMs config ********************************/ +/* pwm resolution settings*/ +#define PWM_VALUE_MAX_POS (16U) +#define PWM_VALUE_MAX ((1UL << PWM_VALUE_MAX_POS) -1UL) + + +#define WATCH_DOG_EN (0U) + +/* ************************debug config *******************************/ +#define ENABLE_FUNCTION_VALIDATION (0U) +#define CODE_DEBUG_EN 1 + +#if CODE_DEBUG_EN == 1 + #include + #include + #include + #define DEBUG_OUT(...) printf(__VA_ARGS__) +#else + #define DEBUG_OUT(...) +#endif + +#endif \ No newline at end of file diff --git a/87400/usr/common/applicationTask.c b/87400/usr/common/applicationTask.c new file mode 100644 index 0000000..8964f5d --- /dev/null +++ b/87400/usr/common/applicationTask.c @@ -0,0 +1,236 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file applicationTask.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ + +#include +#include +#include +#include +#include "PINdef.h" +#include "hwCtrl.h" +#include "prjconfig.h" +/*static uint8_t ledNum = LED0;*/ +static TaskState_t applState = TASK_STATE_INIT; +void ApplTimerExpired(SoftTimer_t *timer); + +void KeyScanTimerExpired(SoftTimer_t *timer); +void TxMsgPro(void); + + +static SoftTimer_t KeyScanTimer = { + .mode = TIMER_PERIODIC_MODE, + .interval = 5U, + .handler = KeyScanTimerExpired +}; + + +static uint8_t LED_State = 0U; + + +uint8_t APPL_GetLEDState(void) +{ + return LED_State; +} + + + +static SoftTimer_t ApplTimer = { + .mode = TIMER_PERIODIC_MODE, + .interval = 50U, + .handler = ApplTimerExpired +}; + +void LED_Ctrl(void); + +void ApplTimerExpired(SoftTimer_t *timer) +{ + static uint8_t index = 0U; + if (index == 0U){ + index = 1U; + }else{ + index = 0; + + } + LED_Ctrl(); +} + +void APPL_TaskHandler(void) +{ + switch(applState){ + case TASK_STATE_INIT: + SoftTimer_Start(&ApplTimer); + SoftTimer_Start(&KeyScanTimer); + ADC_Init(ADC_MEASURE_ITEM_VBAT_VTEMP, 0); + ADC_Start(); + applState = TASK_STATE_ACTIVE; + break; + case TASK_STATE_ACTIVE: + break; + default: + break; + } +} + + +void APPL_HandleControlCommands(LIN_Device_Frame_t const *frame) +{ + +} + +uint8_t APPL_PrepareLedParamRequest(uint8_t reqSid,uint8_t *const dataBuff, DiagPublishInfo_t *const diagRsp) +{ + uint8_t response; + CommLedParamInfo_t *const info = (CommLedParamInfo_t *)((void *)dataBuff); + CommLedParamInfo_t *const infoRsp = (CommLedParamInfo_t *)((void *)diagRsp->payload); + + diagRsp->sid = reqSid; + infoRsp->command = info->command; + switch(info->command){ + case APP_DIAG_GET_SDK_VERSION: + infoRsp->Version.sdkApplication = SDK_APPL_VERSION; + infoRsp->Version.linStack = ls_get_lin_version(); + + diagRsp->packLength = 2U + (uint16_t)sizeof(CommVersion_t); + diagRsp->type = (diagRsp->packLength > SF_MAX_DATA_LENGTH)? PDU_TYPE_MULTI_PDU:PDU_TYPE_SINGLE_PDU; + response = TRUE; + break; + + default: + response = FALSE; + break; + } + return response; +} +/***************************************************************/ + +typedef struct +{ + //BYTE 0 + uint8_t HG:2;//滑轨 + uint8_t AM:2;//按摩 + uint8_t KB:2;//é èƒŒ + uint8_t REVERSE01:2; + //BYTE 1 + uint8_t TT:2; + uint8_t REVERSE11:2; + uint8_t ZY:2; + uint8_t REVERSE12:2; + //BYTE 2 + uint8_t REVERSE21:4; + uint8_t FW:1;//å¤ä½ + uint8_t REVERSE22:3; + //3-7 + uint8_t REVERSE3; + uint8_t REVERSE4; + uint8_t REVERSE5; + uint8_t REVERSE6; + uint8_t REVERSE7; +}LIN_MSG_TYPE; + +LIN_MSG_TYPE LIN_msg_buf; +const uint8_t LIN_Init_data[] = {0x00,0x00,0x80,0xff,0xff,0xff,0xff,0x0f}; + +static uint16_t keydelay[KEY_NUM]={0}; +static uint8_t keyflag[KEY_NUM]={0}; +uint8_t fan_state,heat_state; +#define KEY_DELAY_TIME 6 +void KeyScanTimerExpired(SoftTimer_t *timer) +{ + uint8_t keyval,i; + for (i = 0; i < KEY_NUM; i++) + { + keyval = GetKeyState(i+1); + if (keyval == 1 && keyflag[i] == 0) + { + keydelay[i]++; + if (keydelay[i] > KEY_DELAY_TIME)//30ms + { + keyflag[i] = 1; + keydelay[i] = KEY_DELAY_TIME; + } + + } + else if (keyval == 0) + { + keyflag[i] = 0; + keydelay[i] = 0; + } + + } + TxMsgPro(); + //ADC_Init(ADC_MEASURE_ITEM_VAMP, 0); + ADC_Start(); + +} +extern uint16_t g_AdVal[3]; + + + +uint8_t GetKeyFlag(uint8_t keyid) +{ + if (keyid > 0 && keyid <= KEY_NUM) + { + return keyflag[keyid-1]?1:0; + } + else + { + return 0; + } +} +uint8_t g_rxbuf[8],g_txbuf1[8],g_txbuf2[8]; + +void LED_Ctrl(void) +{ + fan_state = (g_rxbuf[0]&0xc0)>>6; + heat_state = (g_rxbuf[0]&0x30)>>4; + FanLED_Ctrl(fan_state); + HeatLED_Ctrl(heat_state); +} +void TxMsgPro(void) +{ + uint8_t temp=0,i; + temp = 0xf0; +#if BOARDCFG == LEFT_BOARD + LIN_msg_buf.FW = GetKeyFlag(SIGID_KEY13); + LIN_msg_buf.TT = GetKeyFlag(SIGID_KEY6)<<1|GetKeyFlag(SIGID_KEY5); + LIN_msg_buf.HG = GetKeyFlag(SIGID_KEY3)<<1|GetKeyFlag(SIGID_KEY4); + LIN_msg_buf.AM = GetKeyFlag(SIGID_KEY8)<<1|GetKeyFlag(SIGID_KEY7); + LIN_msg_buf.KB = GetKeyFlag(SIGID_KEY9)<<1|GetKeyFlag(SIGID_KEY11); + LIN_msg_buf.ZY = GetKeyFlag(SIGID_KEY12)<<1|GetKeyFlag(SIGID_KEY10); + temp |= GetKeyFlag(SIGID_KEY1)<<1; + temp |= GetKeyFlag(SIGID_KEY2)<<0; +#else + LIN_msg_buf.FW = GetKeyFlag(SIGID_KEY13); + LIN_msg_buf.HG = GetKeyFlag(SIGID_KEY5)<<1|GetKeyFlag(SIGID_KEY6); + LIN_msg_buf.TT = GetKeyFlag(SIGID_KEY4)<<1|GetKeyFlag(SIGID_KEY3); + LIN_msg_buf.AM = GetKeyFlag(SIGID_KEY7)<<1|GetKeyFlag(SIGID_KEY8); + LIN_msg_buf.KB = GetKeyFlag(SIGID_KEY9)<<1|GetKeyFlag(SIGID_KEY11); + LIN_msg_buf.ZY = GetKeyFlag(SIGID_KEY10)<<1|GetKeyFlag(SIGID_KEY12); + temp |= GetKeyFlag(SIGID_KEY1)<<0; + temp |= GetKeyFlag(SIGID_KEY2)<<1; +#endif + LIN_msg_buf.REVERSE01 = LIN_msg_buf.KB?1:0; + /* + LIN_msg_buf.REVERSE3 = (fan_state<<4) | (heat_state); + LIN_msg_buf.REVERSE4 = g_AdVal[0]>>8; + LIN_msg_buf.REVERSE5 = g_AdVal[0]&0xff; + LIN_msg_buf.REVERSE6 = g_AdVal[1]>>8; + LIN_msg_buf.REVERSE7 = g_AdVal[1]&0xff; + */ + for (i = 0; i < 8; i++) + { + g_txbuf1[i] = ((uint8_t *)(&LIN_msg_buf))[i]; + } + g_txbuf2[0] = temp; + g_txbuf2[1] = 0x0b; +} diff --git a/87400/usr/common/applicationTask.h b/87400/usr/common/applicationTask.h new file mode 100644 index 0000000..4017cb4 --- /dev/null +++ b/87400/usr/common/applicationTask.h @@ -0,0 +1,43 @@ +#ifndef _APPLICATION_H +#define _APPLICATION_H +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#define APP_DIAG_GET_SDK_VERSION (0x0FU) + +BEGIN_PACK + +typedef struct{ + uint16_t sdkApplication; + lin_stack_version_t linStack; +}CommVersion_t; + +typedef struct{ + uint16_t command; + union{ + CommVersion_t Version; + }; +}CommLedParamInfo_t; + +END_PACK + + +uint8_t APPL_GetLEDState(void); + +void APPL_TaskHandler(void); +void APPL_HandleControlCommands(LIN_Device_Frame_t const *frame); +/* Response enable */ +uint8_t APPL_PrepareLedParamRequest(uint8_t reqSid,uint8_t *const dataBuff, DiagPublishInfo_t *const diagRsp); +uint8_t APPL_HandleLedParamConfigRequest(uint8_t reqSid,uint8_t *const dataBuff,DiagPublishInfo_t *const diagRsp); + + +#endif \ No newline at end of file diff --git a/87400/usr/common/crc32.c b/87400/usr/common/crc32.c new file mode 100644 index 0000000..0a71e6a --- /dev/null +++ b/87400/usr/common/crc32.c @@ -0,0 +1,57 @@ +#include +#include + + +#if 0 +/*************Software CRC32**************************/ +static uint32_t CRC32_Table[256U]; + +void CRC32_Init(void) +{ + uint32_t c; + + for (uint32_t i = 0U; i < 256U; i++) { + c = i; + for (uint32_t j = 0U; j < 8U; j++) { + if ((c & 0x01U)!= 0U){ + c = 0xEDB88320UL ^ (c >> 1U); + }else{ + c = c >> 1U; + } + } + CRC32_Table[i] = c; + } +} +uint32_t CRC32_GetRunTimeCRC32(uint8_t *pBuf ,uint16_t length) +{ + uint32_t retCRCValue = 0xFFFFFFFFU; + for (uint16_t i = 0; i < length; i++){ + retCRCValue=CRC32_Table[(retCRCValue ^ pBuf[i]) & 0xFFU] ^ (retCRCValue >> 8U); + } + return (retCRCValue^0xFFFFFFFFU); +} + +#else + +/*************Hardwarre CRC32**************************/ +void CRC32_Init(void) +{ + CRGA_SFRS->MODULERSTREQ = MODUE_SOFT_RESET_CRC; +} + +uint32_t CRC32_GetRunTimeCRC32(uint8_t *pBuf ,uint16_t length) +{ + uint32_t retCRCValue; + CRC_SFRS->CRCCR.REVIN = 1U; + CRC_SFRS->CRCCR.REVOUT = 1U; + CRC_SFRS->CRCINIT = 0xFFFFFFFFU; + for (uint16_t i = 0; i < length; i++){ + CRC_SFRS->CRCDR.CRCDATA0 = pBuf[i]; + } + retCRCValue = CRC_SFRS->CRCDR.WORD; + return (retCRCValue^0xFFFFFFFFU); +} + +#endif + + diff --git a/87400/usr/common/crc32.h b/87400/usr/common/crc32.h new file mode 100644 index 0000000..10e3d15 --- /dev/null +++ b/87400/usr/common/crc32.h @@ -0,0 +1,26 @@ +#ifndef CRC32_H_ +#define CRC32_H_ + +#include +#include +#include + + +void CRC32_Init(void); +uint32_t CRC32_GetRunTimeCRC32(uint8_t *pBuf ,uint16_t length); + + + + + + + + + + + + + + + +#endif \ No newline at end of file diff --git a/87400/usr/common/isrfuncs.h b/87400/usr/common/isrfuncs.h new file mode 100644 index 0000000..66488c8 --- /dev/null +++ b/87400/usr/common/isrfuncs.h @@ -0,0 +1,83 @@ +#ifndef ISR_FUNCS_H_ +#define ISR_FUNCS_H_ + + + +void NMI_Handler(void); +void HardFault_Handler(void); +void MemManage_Handler(void); +void BusFault_Handler(void); +void UsageFault_Handler(void); +void SVC_Handler(void); +void PendSV_Handler(void); +void SysTick_Handler(void); + +void IOCTRLA_Handler(void); +void OVTEMP_Handler(void); +void GPIO_Handler(void); +void PWM_AUX_Handler(void); +void GT4_5_Handler(void); + +void WUTIMER_Handler(void); +void WatchdogA_Handler(void); +void ADC_Handler(void); +void SPI_Handler(void); +void WULINS_Handler(void); + +void UART0_Handler(void); +void Divider_Handler(void); +void LIN_Handler(void); +void FlashEcc_Handler(void); +void RamEcc_Handler(void); + +void GT1_Handler(void); +void GT2_Handler(void); +void GT3_Handler(void); +void GT4_5_Handler(void); + +void CT2_Handler(void); +void CT3_Handler(void); +void CT4_Handler(void); +void CT5_Handler(void); +void CT6_Handler(void); +void CR_Handler(void); +void PWM_INTOL0_Handler(void); + +void PWM_INTOL1_Handler(void); +void PWM_INTOL2_Handler(void); +void PWM_INTOL3_Handler(void); +void BOR_Handler(void); +void UV_OV_Handler(void); + +void CSA_OCP_Handler(void); +void Lullaby_Handler(void); + +void error(void); + + + + + + + + + + + + + + + + + + + + + + + + + + + +#endif \ No newline at end of file diff --git a/87400/usr/common/linSlaveTask.h b/87400/usr/common/linSlaveTask.h new file mode 100644 index 0000000..cb262c4 --- /dev/null +++ b/87400/usr/common/linSlaveTask.h @@ -0,0 +1,83 @@ +#ifndef _LINS_TASK_H +#define _LINS_TASK_H + +#include +#include + + +/** +* @brief A structure to represent LIN frame information. +*/ + +#define N_AS (1000) +#define N_CR (1000) + +#define LINS_FUNCTION_ID_SNPD_FORCE_SWITCH_ON (0xAA00U) +#define LINS_FUNCTION_ID_SNPD_INIT (0xAA01U) +#define LINS_FUNCTION_ID_SNPD_ASSIGN_NAD (0xAA02U) +#define LINS_FUNCTION_ID_SNPD_STORAGE (0xAA03U) +#define LINS_FUNCTION_ID_SNPD_EXIT (0xAA04U) + +#define LINS_SUPPLIER_ID (0x0123U) +#define LINS_FUNCTION_ID (0x0123U) +#define LINS_VARIANT (0x01U) +#define LINS_SERIAL_NO (0x01234567U) +#define LINS_FW_VERSION (0x0123U) +#define LINS_HW_VERSION (0x0001U) + +#define LIN_SID_APP_DIAG_LED_GET_CONFIG (0xBAU) /* single pdu receive, multi pdu response */ +#define LIN_SID_APP_DIAG_LED_SET_CONFIG (0xBBU) /* multi pdu receive, single pdu response */ +#define LIN_SID_APP_DIAG_SINGLE_PDU_RECV_MULTI_RSP (0x22U) +#define LIN_SID_APP_DIAG_MULTI_PDU_RECV_SINGLE_RSP (0x2EU) +#define LIN_SID_APP_DIAG_MULTI_PDU_RECV_MULTI_RSP (0x2FU) + + +#define LIN_SID_APP_DIAG_BOOT_MODE (0x20U) +#define BOOT_MODE_HANDSHAKE (0x00U) +#define BOOT_MODE_MAGIC_KEY_HANDSHAKE (0x5A5A55AAU) + +/* *****************LIN configuration default value **************************/ +#if LIN_STACK_TYPE == LIN_STACK_TYPE_SAEJ2602 + #define INIT_LINS_NAD_ADDR (0x6FU) /* NAD range is 0x60-0x6D,defalut*/ + #if (INIT_LINS_NAD_ADDR>0x6FU) + #error INIT_LINS_NAD_ADDR must be within 0x60U-0x6FU!!! + #endif + + #define MESSAGE_ID_BLOCK_COUNT (0x08U) /* MESSAGE_ID_BLOCK_COUNT = 2^n n= 2,3,4.. */ + #if (MESSAGE_ID_BLOCK_COUNT != 4U && MESSAGE_ID_BLOCK_COUNT != 8U && MESSAGE_ID_BLOCK_COUNT != 16U) + #error Invalid MESSAGE_ID_BLOCK_COUNT count !!! + #elif ((INIT_LINS_NAD_ADDR == 0x6CU || INIT_LINS_NAD_ADDR == 0x6DU) && MESSAGE_ID_BLOCK_COUNT != 4U) + #error MESSAGE_ID_BLOCK_COUNT must be 4 when NAD is 0x6C or 0x6D!!! + #endif + + /* it's only a reference, the real FID number is based on NAD according to SAEJ2602 */ + #define DEFAULT_LINS_FID0 (0x00U) + #define DEFAULT_LINS_FID1 (0x01U) + #define DEFAULT_LINS_FID2 (0x02U) + #define DEFAULT_LINS_FID3 (0x03U) + #define DEFAULT_LINS_FID4 (0x04U) + #define DEFAULT_LINS_FID5 (0x05U) + #define DEFAULT_LINS_FID6 (0x06U) + #define DEFAULT_LINS_FID7 (0x07U) + +#else + + #define INIT_LINS_NAD_ADDR (0x01U) + #define DEFAULT_LINS_FID_SIZE (0x03U) /* count number defined by user */ + + /* FID number is set by user */ + #define DEFAULT_LINS_FID0 (0x00U) + #define DEFAULT_LINS_FID1 (0x06U) + #define DEFAULT_LINS_FID2 (0x08U) + + + void LINS_EventTriggered_ISR(void); +#endif + + +void LINS_TaskHandler(void); +LIN_Device_Frame_t volatile *LINS_GetUcndFramesTable(uint8_t *tableItemsCount); +void LINS_SendWakeUpSignal_ISR(void); +uint8_t LINS_GetPIDFromFID(uint8_t frameId); +void LINS_SetDeviceUnconfigured(void); +#endif \ No newline at end of file diff --git a/87400/usr/common/linsNodeCfgIdentify.c b/87400/usr/common/linsNodeCfgIdentify.c new file mode 100644 index 0000000..f92ee72 --- /dev/null +++ b/87400/usr/common/linsNodeCfgIdentify.c @@ -0,0 +1,210 @@ +/** + * @copyright 2021 Indie microcontroller. + * + * This file is proprietary to Indie microcontroller. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie microcontroller. + * + * @file linsNodeCfgIdentify.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2021/07/06 + */ + +#include +#include +#include +#include +#include + +#if LIN_STACK_TYPE == LIN_STACK_TYPE_LIN2_2A + +static LINClusterParams_t *linParams = NULL; +static LIN_Device_Frame_t volatile *frameTable = NULL; + + +void LNCI_Init(void) +{ + uint8_t tableItemsCount; + /* get lin information from flash storage */ + linParams = PDS_GetLINParam(); + /* get frame table information */ + frameTable = LINS_GetUcndFramesTable(&tableItemsCount); + + for (uint8_t i = 0U; i < tableItemsCount; i++){ + frameTable[i].frame_id = linParams->frameInfo[i].frameId; + frameTable[i].frameIsValid = linParams->frameInfo[i].frameIsValid; + } +} + +uint8_t LNCI_HandleNodeCfgIdentifyRequest(const DiagSubscribeInfo_t *const diagReq,DiagPublishInfo_t *const diagRsp) +{ + uint8_t response = FALSE; + if (diagReq->sid == LIN_SID_ASSIGN_NAD && diagReq->packLength == sizeof(AssignNAD_t)){/* Assign NAD */ + /* + 4.2.5.1 Assign NAD + Assign NAD is used to resolve conflicting NADs in LIN clusters built using off-theshelves slave nodes or reused slave nodes. + This request uses the initial NAD (or the NAD wildcard); this is to avoid the risk of losing the address of a slave node. The NAD + used for the response shall be the same as in the request, i.e. the initial NAD. + */ + uint8_t nad = ls_read_nad_from_master(); + if (nad == INIT_LINS_NAD_ADDR || nad == LIN_NAD_WILDCARD){ + AssignNAD_t *assignNAD = (AssignNAD_t *)((void *)diagReq->payload); + if ((assignNAD->supplierID == LINS_SUPPLIER_ID || assignNAD->supplierID == LIN_SUPPLIER_ID_WILDCARD)&& + (assignNAD->functionID == LINS_FUNCTION_ID || assignNAD->functionID == LIN_FUNCTION_ID_WILDCARD)){ + /* A response shall only be sent if the NAD, the Supplier ID and the Function ID match. If successful */ + if (assignNAD->newNAD > 0U){ + diagRsp->packLength = 0U; + linParams->nad = assignNAD->newNAD; + ls_set_nad(assignNAD->newNAD); /* set nad to lin stack */ + response = TRUE; + } + } + } + }else if (diagReq->sid == LIN_SID_SAVE_CONFIGURATION && diagReq->packLength == 0x00U){ /* Save Configuration */ + /* + 4.2.5.4 Save Configuration + This service tells the slave node(s) that the slave application shall save the current + configuration. The save configuration request shall be structured as shown in + Table 4.14. This service is used to notify a slave node to store its configuration. + A configuration in the slave node may be valid even without the master node using this + request (i.e. the slave node does not have to wait for this request to have a valid configuration). + */ + diagRsp->packLength = 0U; + response = TRUE; + TM_PostTask(TASK_ID_PDS); /*start persistance data storage (PDS )task */ + }else if (diagReq->sid == LIN_SID_READ_BY_ID && diagReq->packLength == sizeof(ReadByIdReq_t)){ /* Read by Identifier */ + ReadByIdReq_t *readById = (ReadByIdReq_t *)((void*)diagReq->payload); + if ((readById->supplierID == LINS_SUPPLIER_ID || readById->supplierID == LIN_SUPPLIER_ID_WILDCARD)&& + (readById->functionID == LINS_FUNCTION_ID || readById->functionID == LIN_FUNCTION_ID_WILDCARD)){ + /* + 4.2.6.1 Read by identifier + It is possible to read the supplier identity and other properties from a slave node using + the request in Table 4.18. + */ + if (readById->identifier == 0U){ + /* LIN Product Identification */ + ReadByIdProductIdRsp_t *rsp = (ReadByIdProductIdRsp_t *)((void *)diagRsp->payload); + rsp->supplierID = LINS_SUPPLIER_ID; + rsp->functionID = LINS_FUNCTION_ID; + rsp->variant = LINS_VARIANT; + diagRsp->packLength = (uint16_t)sizeof(ReadByIdProductIdRsp_t); + response = TRUE; + }else if (readById->identifier == 1U){ + /* Serial number */ + ReadByIdSerialNoRsp_t *rsp = (ReadByIdSerialNoRsp_t *)((void *)diagRsp->payload); + rsp->serialNo = LINS_SERIAL_NO; + diagRsp->packLength = (uint16_t)sizeof(ReadByIdSerialNoRsp_t); + response = TRUE; + }else{ + /* + If the slave is not supporting this request or could not process the request it will + respond according to Table 4.21. + */ + ReadByIdNakRsp_t *rsp = (ReadByIdNakRsp_t *)((void *)diagRsp->payload); + diagRsp->sid = 0x7FU; + rsp->sid = LIN_SID_READ_BY_ID; + rsp->errorCode = 0x12U; + diagRsp->packLength = (uint16_t)sizeof(ReadByIdNakRsp_t); + response = TRUE; + } + } + }else if (diagReq->sid == LIN_SID_ASSIGN_FRAME_ID_RANGE && diagReq->packLength == sizeof(AssignFrameIDRange_t)){ /* Assign frame identifier range */ + AssignFrameIDRange_t *assignFrameIDRng = (AssignFrameIDRange_t *)((void *)diagReq->payload); + uint8_t pid; + uint8_t invalid = 0U; + /* + 4.2.5.5 Assign frame ID range + It is important to notice that the request provides the protected identifier, i.e. the frame + identifier and its parity. Furthermore, frames with frame identifiers 60 (0x3C) to 63 + (0x3F) can not be changed (diagnostic frames and reserved frames) + */ + for (uint8_t i = 0U; i< 4U;i++){ + if (assignFrameIDRng->pid[i] != LIN_FRAME_ID_DONOTCARE){ + pid = assignFrameIDRng->pid[i] & 0x3FU; + if (pid >= 0x3CU && pid <= 0x3FU){ + /* the request is fail for the FID is invalid*/ + invalid = 1U; + break; + } + } + } + /* PID is not in the range from 0x3C to 0x3D */ + if (invalid == 0U){ + uint8_t tableItemsCount; + LIN_Device_Frame_t volatile *unconditionalTable = LINS_GetUcndFramesTable(&tableItemsCount); + /* startIndex should be less then unconditional Table size */ + if (assignFrameIDRng->startIndex < tableItemsCount){ + /* + 4.2.5.5 Assign frame ID range + Example 2 + A slave node has only two frames {status_frame, response_frame}. To assign PIDs to + these two frames the master application will setup the following request: start index + set to 0 and PID (index 0..3) set to {0xC4, 0x85, 0xFF, 0xFF}. Since the slave node + has only two frames the last two must be set to do not care, otherwise the request will fail. + */ + uint8_t maxConfigurableFrameIndex = assignFrameIDRng->startIndex + 4U; + if (maxConfigurableFrameIndex > tableItemsCount){/* overlap with frame table */ + uint8_t coutOffset = 4U - (maxConfigurableFrameIndex - tableItemsCount); + for (uint8_t i = coutOffset; i < 4U;i++){ + /* configurable out of range PID should be 0xFF */ + if (assignFrameIDRng->pid[i] != LIN_FRAME_ID_DONOTCARE){ + /* the request is fail */ + invalid = 1U; + break; + } + } + if (invalid == 0U){ + /* Configurable out of range PID setting is corrent, copy PID to frame table */ + for (uint8_t i = 0U; i< (tableItemsCount - assignFrameIDRng->startIndex);i++){ + if (assignFrameIDRng->pid[i] == LIN_FRAME_ID_UNASSIGN){ + /* set PID to 0xFF to invalid this frame */ + unconditionalTable[assignFrameIDRng->startIndex + i].frameIsValid = FALSE; + }else{ + if (assignFrameIDRng->pid[i] != LIN_FRAME_ID_DONOTCARE){ + /* + 4.2.5.5 Assign frame ID range: + The slave node will not validate the given PIDs (i.e. validating the parity flags), the + slave node relies on that the master sets the correct PIDs. + copy PID to frame table: + */ + unconditionalTable[assignFrameIDRng->startIndex + i].frame_id = assignFrameIDRng->pid[i] & 0x3FU; + unconditionalTable[assignFrameIDRng->startIndex + i].frameIsValid = TRUE; + } + } + } + diagRsp->packLength = 0U; + response = TRUE; + } + }else{/* no overlap frame table */ + for (uint8_t i = 0U; i < 4U;i++){ + if (assignFrameIDRng->pid[i] == LIN_FRAME_ID_UNASSIGN){ + /* set PID to 0xFF to invalid this frame */ + unconditionalTable[assignFrameIDRng->startIndex + i].frameIsValid = FALSE; + }else{ + if (assignFrameIDRng->pid[i] != LIN_FRAME_ID_DONOTCARE){ + /* + 4.2.5.5 Assign frame ID range: + The slave node will not validate the given PIDs (i.e. validating the parity flags), the + slave node relies on that the master sets the correct PIDs. + copy PID to frame table: + */ + unconditionalTable[assignFrameIDRng->startIndex + i].frame_id = assignFrameIDRng->pid[i] & 0x3FU; + unconditionalTable[assignFrameIDRng->startIndex + i].frameIsValid = TRUE; + } + } + } + for (uint8_t i = 0U; i < tableItemsCount; i++){ + linParams->frameInfo[i].frameId = frameTable[i].frame_id; + linParams->frameInfo[i].frameIsValid = frameTable[i].frameIsValid; + } + diagRsp->packLength = 0U; + response = TRUE; + } + } + } + } + return response; +} +#endif \ No newline at end of file diff --git a/87400/usr/common/linsNodeCfgIdentify.h b/87400/usr/common/linsNodeCfgIdentify.h new file mode 100644 index 0000000..56f536a --- /dev/null +++ b/87400/usr/common/linsNodeCfgIdentify.h @@ -0,0 +1,68 @@ +#ifndef LINS_NODE_CFG_IDENTIFY_H__ +#define LINS_NODE_CFG_IDENTIFY_H__ +#include + +BEGIN_PACK + +typedef struct{ + uint8_t initNAD; + uint8_t pci; + uint8_t sid; +}nodeConfig_t; + +typedef struct{ + uint16_t supplierID; + uint16_t functionID; + uint8_t newNAD; +}AssignNAD_t; + +typedef struct{ + uint16_t supplierID; + uint16_t functionID; + uint8_t newNAD; +}SNPD_t; + +typedef struct{ + uint8_t startIndex; + uint8_t pid[4]; +}AssignFrameIDRange_t; + +typedef struct{ + uint8_t command; + uint32_t magicKey; +}EnterBootloaderFrame_t; + +typedef struct{ + uint8_t identifier; + uint16_t supplierID; + uint16_t functionID; +}ReadByIdReq_t; + +typedef struct{ + uint8_t sid; + uint8_t errorCode; +}ReadByIdNakRsp_t; + +typedef struct{ + uint16_t supplierID; + uint16_t functionID; + uint8_t variant; +}ReadByIdProductIdRsp_t; + +typedef struct{ + uint32_t serialNo; +}ReadByIdSerialNoRsp_t; + +typedef struct{ + uint8_t nad; + uint32_t magicKey; +}SaeJ2602_3C3ECfg_t; + +END_PACK + + + +void LNCI_Init(void); +uint8_t LNCI_HandleNodeCfgIdentifyRequest(const DiagSubscribeInfo_t *const diagReq,DiagPublishInfo_t *const diagRsp); + +#endif \ No newline at end of file diff --git a/87400/usr/common/linsNodeCfgIdentify_J2602.c b/87400/usr/common/linsNodeCfgIdentify_J2602.c new file mode 100644 index 0000000..8ff3e44 --- /dev/null +++ b/87400/usr/common/linsNodeCfgIdentify_J2602.c @@ -0,0 +1,182 @@ +/** + * @copyright 2021 Indie microcontroller. + * + * This file is proprietary to Indie microcontroller. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie microcontroller. + * + * @file linsNodeCfgIdentify.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2021/07/06 + */ + +#include +#include +#include +#include +#include + +#if LIN_STACK_TYPE == LIN_STACK_TYPE_SAEJ2602 + +static LINClusterParams_t *linParams = NULL; +static LIN_Device_Frame_t volatile *frameTable = NULL; + +void HardwareResetTimerExpired(SoftTimer_t *timer); + +static SoftTimer_t hardwareResetTimer = { + .mode = TIMER_ONE_SHOT_MODE, + .interval = 50U, + .handler = HardwareResetTimerExpired +}; + +void HardwareResetTimerExpired(SoftTimer_t *timer) +{ + CRGA_SFRS->RESETCTRL.HARDRSTREQ = 1U; +} + +void LNCI_Init(void) +{ + uint8_t frameIsValid = TRUE; + uint8_t tableItemsCount; + /* get lin information from flash storage */ + linParams = PDS_GetLINParam(); + /* get frame table information */ + frameTable = LINS_GetUcndFramesTable(&tableItemsCount); + + /* + 5.7.2.2 Message ID Assignment + Devices with a DNN of $E or $F will have the protected identifiers marked as + invalid as described in of the LIN Diagnostic and Configuration Specification + */ + if (linParams->nad >= 0x6EU && linParams->nad <= 0x6FU){ + frameIsValid = FALSE; + } + for (uint8_t i = 0U; i < tableItemsCount; i++){ + frameTable[i].frame_id = i + (linParams->nad & 0x0FU)*4U; + frameTable[i].frameIsValid = frameIsValid; + } +} + +uint8_t LNCI_HandleNodeCfgIdentifyRequest(const DiagSubscribeInfo_t *const diagReq,DiagPublishInfo_t *const diagRsp) +{ + uint8_t frameIsValid = TRUE; + uint8_t response = FALSE; + if (diagReq->sid == LIN_SID_J2602_HARDWARE_RST && diagReq->packLength == 0U){ /* 0xB5 is hardware reset command in SAEJ2602 */ + /* LIN Product Identification */ + ReadByIdProductIdRsp_t *rsp = (ReadByIdProductIdRsp_t *)((void *)diagRsp->payload); + rsp->supplierID = LINS_SUPPLIER_ID; + rsp->functionID = LINS_FUNCTION_ID; + rsp->variant = LINS_VARIANT; + diagRsp->packLength = (uint16_t)sizeof(ReadByIdProductIdRsp_t); + + if(linParams->nad == ls_read_nad_from_master()){ + response = TRUE; + } + ls_set_J2602_hardware_reset(TRUE); + LINS_SetDeviceUnconfigured(); + //SoftTimer_Stop(&hardwareResetTimer); + //SoftTimer_Start(&hardwareResetTimer); + }else if (diagReq->sid == LIN_SID_ASSIGN_NAD && diagReq->packLength == sizeof(AssignNAD_t)){/* Assign NAD */ + /* + 4.2.5.1 Assign NAD + Assign NAD is used to resolve conflicting NADs in LIN clusters built using off-theshelves slave nodes or reused slave nodes. + This request uses the initial NAD (or the NAD wildcard); this is to avoid the risk of losing the address of a slave node. The NAD + used for the response shall be the same as in the request, i.e. the initial NAD. + */ + uint8_t nad = ls_read_nad_from_master(); + if (nad == INIT_LINS_NAD_ADDR || nad == LIN_NAD_WILDCARD){ + AssignNAD_t *assignNAD = (AssignNAD_t *)((void *)diagReq->payload); + if ((assignNAD->supplierID == LINS_SUPPLIER_ID || assignNAD->supplierID == LIN_SUPPLIER_ID_WILDCARD)&& + (assignNAD->functionID == LINS_FUNCTION_ID || assignNAD->functionID == LIN_FUNCTION_ID_WILDCARD)){ + /* A response shall only be sent if the NAD, the Supplier ID and the Function ID match. If successful */ + if (assignNAD->newNAD >= 0x60U && assignNAD->newNAD <= 0x6FU){ + if ( (((assignNAD->newNAD & 0x0FU)%(MESSAGE_ID_BLOCK_COUNT/4U) ) == 0U) || (assignNAD->newNAD == 0x6FU) ){ + /* + 5.7.2.2 Message ID Assignment + Devices with a DNN of $E or $F will have the protected identifiers marked as + invalid as described in of the LIN Diagnostic and Configuration Specification + */ +#if MESSAGE_ID_BLOCK_COUNT == 8U + if (assignNAD->newNAD >= 0x6DU && assignNAD->newNAD <= 0x6FU){ + frameIsValid = FALSE; + } +#else + if (assignNAD->newNAD >= 0x6EU && assignNAD->newNAD <= 0x6FU){ + frameIsValid = FALSE; + } +#endif + diagRsp->packLength = 0U; + linParams->nad = assignNAD->newNAD; + ls_set_nad(assignNAD->newNAD); /* set nad to lin stack */ + /* adatper Frame ID according to NAD */ + uint8_t tableItemsCount; + frameTable = LINS_GetUcndFramesTable(&tableItemsCount); + linParams->frameIDSize = tableItemsCount; + + for (uint8_t i = 0U; i < tableItemsCount; i++){ + frameTable[i].frame_id = i + (linParams->nad & 0x0FU)*4U; + frameTable[i].frameIsValid = frameIsValid; + linParams->frameInfo[i].frameId = frameTable[i].frame_id; + linParams->frameInfo[i].frameIsValid = frameIsValid; + } + response = TRUE; + /*TM_PostTask(TASK_ID_PDS); start persistance data storage (PDS )task */ + } + } + } + } + }else if (diagReq->sid == LIN_SID_SAVE_CONFIGURATION && diagReq->packLength == 0x00U){ /* Save Configuration */ + /* + 4.2.5.4 Save Configuration + This service tells the slave node(s) that the slave application shall save the current + configuration. The save configuration request shall be structured as shown in + Table 4.14. This service is used to notify a slave node to store its configuration. + A configuration in the slave node may be valid even without the master node using this + request (i.e. the slave node does not have to wait for this request to have a valid configuration). + */ + diagRsp->packLength = 0U; + response = TRUE; + TM_PostTask(TASK_ID_PDS); /*start persistance data storage (PDS )task */ + }else if (diagReq->sid == LIN_SID_READ_BY_ID && diagReq->packLength == sizeof(ReadByIdReq_t)){ /* Read by Identifier */ + ReadByIdReq_t *readById = (ReadByIdReq_t *)((void*)diagReq->payload); + if ((readById->supplierID == LINS_SUPPLIER_ID || readById->supplierID == LIN_SUPPLIER_ID_WILDCARD)&& + (readById->functionID == LINS_FUNCTION_ID || readById->functionID == LIN_FUNCTION_ID_WILDCARD)){ + /* + 4.2.6.1 Read by identifier + It is possible to read the supplier identity and other properties from a slave node using + the request in Table 4.18. + */ + if (readById->identifier == 0U){ + /* LIN Product Identification */ + ReadByIdProductIdRsp_t *rsp = (ReadByIdProductIdRsp_t *)((void *)diagRsp->payload); + rsp->supplierID = LINS_SUPPLIER_ID; + rsp->functionID = LINS_FUNCTION_ID; + rsp->variant = LINS_VARIANT; + diagRsp->packLength = (uint16_t)sizeof(ReadByIdProductIdRsp_t); + response = TRUE; + }else if (readById->identifier == 1U){ + /* Serial number */ + ReadByIdSerialNoRsp_t *rsp = (ReadByIdSerialNoRsp_t *)((void *)diagRsp->payload); + rsp->serialNo = LINS_SERIAL_NO; + diagRsp->packLength = (uint16_t)sizeof(ReadByIdSerialNoRsp_t); + response = TRUE; + }else{ + /* + If the slave is not supporting this request or could not process the request it will + respond according to Table 4.21. + */ + ReadByIdNakRsp_t *rsp = (ReadByIdNakRsp_t *)((void *)diagRsp->payload); + diagRsp->sid = 0x7FU; + rsp->sid = LIN_SID_READ_BY_ID; + rsp->errorCode = 0x12U; + diagRsp->packLength = (uint16_t)sizeof(ReadByIdNakRsp_t); + response = TRUE; + } + } + } + return response; +} + +#endif \ No newline at end of file diff --git a/87400/usr/common/linslaveTask.c b/87400/usr/common/linslaveTask.c new file mode 100644 index 0000000..7b29231 --- /dev/null +++ b/87400/usr/common/linslaveTask.c @@ -0,0 +1,328 @@ +/** + * @copyright 2021 Indie microcontroller. + * + * This file is proprietary to Indie microcontroller. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie microcontroller. + * + * @file linSlaveTask.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2021/07/06 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if LIN_STACK_TYPE == LIN_STACK_TYPE_LIN2_2A + +#define FID_LED_CTRL DEFAULT_LINS_FID0 +#define FID_TFJR DEFAULT_LINS_FID1 +#define FID_KEY DEFAULT_LINS_FID2 + +#define DIAG_RECV_DATA_BUFF_SIZE (128U) +#define DIAG_SEND_DATA_BUFF_SIZE (128U) + +#define FID_TABLE_INDEX_0 (0) +#define FID_TABLE_INDEX_1 (1) +#define FID_TABLE_INDEX_2 (2) + +#define FID_LED_CTRL_INDEX (0) +#define FID_TFJR_INDEX (1) +#define FID_KEY_INDEX (2) + +/* ******************internal function declarations****************************/ +void DiagnosticSubscribedCmdsHandleISR(const DiagSubscribeInfo_t * const frameInfo); +void UnconditionalSubscribedCmdsHandle(LIN_Device_Frame_t const *frame); +void UnconditionalPublishedCmdsISR(LIN_Device_Frame_t *const frame); +void UnconditionalPublishedCmdsTxFinishedISR(uint8_t fid, uint8_t resvd); +void DiagnosticSleepRequestHandle(SleepRequestType_t type); +void BusWakeUpRequestHandle(BusWakeUpRequestResult_t result); + + +/* *******************global variants declarations*****************************/ +static TaskState_t linsTaskState = TASK_STATE_INIT; +static uint8_t diagDataRspBuff[DIAG_SEND_DATA_BUFF_SIZE]; +static uint8_t diagDataRecvBuff[DIAG_RECV_DATA_BUFF_SIZE]; + +static DiagMultiPduInfo_t diagMultiPduInfo = { + .buffLength = sizeof(diagDataRecvBuff)/sizeof(diagDataRecvBuff[0]), + .buff = diagDataRecvBuff, +}; + +static uint8_t busWakeupRetryCount = 0U; + +void busWakeupRetryTimerExpired(SoftTimer_t *timer); + +static SoftTimer_t busWakeupRetryTimer = { + .mode = TIMER_ONE_SHOT_MODE, + .interval = 2250U, + .handler = busWakeupRetryTimerExpired +}; + +static uint8_t eventTriggeredLedOn = FALSE; + +/* LIN command handle callbacks declarations */ +static ls_LinsFramesCallback_t linsFramesCallback ={ + UnconditionalSubscribedCmdsHandle, /* received data from master */ + UnconditionalPublishedCmdsISR, /* send data to master, it's an interrupt function, please fill the data as fast as possible */ + UnconditionalPublishedCmdsTxFinishedISR, /* send data to master finished, it's an interrupt function, please fill the data as fast as possible */ + DiagnosticSubscribedCmdsHandleISR, /* Diagnostic sigle PDU and MultiPDU received data from master,it's an interrupt function, please fill the data as fast as possible */ + NULL, /* special functional NAD (0x7E) handler*/ + DiagnosticSleepRequestHandle, /* Diagnostic sleep request from master */ + BusWakeUpRequestHandle, /* Get the bus wake up result this would take effects after call API: ls_send_wake_up_bus_signal()*/ + NULL, /* SAE J2602 -1 Configuration Messages */ + NULL, /* 5.7.2.5 DNN Based Broadcast Messages */ +}; + +/* **FID table declarations****/ +static LIN_Device_Frame_t UnconditionalCmdsTable[DEFAULT_LINS_FID_SIZE] = { + [FID_LED_CTRL_INDEX] = { + .frame_id = FID_LED_CTRL, + .msg_type = LIN_MSG_TYPE_RX, + .checksum = LIN_CHECKSUM_ENHANCED, + .length = 2, + .frameIsValid = TRUE, + }, + [FID_TFJR_INDEX] = { + .frame_id = FID_TFJR, /* status management frame */ + .msg_type = LIN_MSG_TYPE_TX, + .checksum = LIN_CHECKSUM_ENHANCED, + .length = 2, + .frameIsValid = TRUE, + }, + [FID_KEY_INDEX] = { + .frame_id = FID_KEY, /* user data report */ + .msg_type = LIN_MSG_TYPE_TX, + .checksum = LIN_CHECKSUM_ENHANCED, + .length = 8, + .frameIsValid = TRUE, + }, +}; + +extern uint8_t fan_state,heat_state; + +/* please don't do any changes for it would be used by lin stack */ +LIN_Device_Frame_t volatile *LINS_GetUcndFramesTable(uint8_t *tableItemsCount) +{ + *tableItemsCount = (uint8_t)(sizeof(UnconditionalCmdsTable)/sizeof(LIN_Device_Frame_t)); + return UnconditionalCmdsTable; +} + +/* + Diagnostic subscribed frame received from LIN master +*/ +void DiagnosticSubscribedCmdsHandleISR(const DiagSubscribeInfo_t *const diagReq) +{ + DiagPublishInfo_t diagRsp={ + .sid = diagReq->sid, + .type = diagReq->type, + .payload = diagDataRspBuff, + }; + if (diagReq->type == PDU_TYPE_SINGLE_PDU){ + if (diagReq->sid >= LIN_SID_ASSIGN_NAD && diagReq->sid <= LIN_SID_ASSIGN_FRAME_ID_RANGE){ + /* handle Node configuration and Identification commands*/ + diagRsp.type = PDU_TYPE_SINGLE_PDU; + if (LNCI_HandleNodeCfgIdentifyRequest(diagReq,&diagRsp)== TRUE){ + ls_handle_diagnostic_response(&diagRsp); + } + }else{ + if (diagReq->sid == LIN_SID_APP_DIAG_LED_GET_CONFIG){ + /* prepare diagnostic single pdu, user defined diagnostic frame, here is for LED param configuration*/ + for (uint16_t i = 0; i < diagReq->packLength; i++){ + diagDataRecvBuff[i] = diagReq->payload[i]; + } + if(APPL_PrepareLedParamRequest(diagReq->sid,diagDataRecvBuff,&diagRsp) == TRUE){ + ls_handle_diagnostic_response(&diagRsp); + } + }else if (diagReq->sid == LIN_SID_APP_DIAG_SINGLE_PDU_RECV_MULTI_RSP){ + /* handle diagnostic single pdu, multi response, user defined diagnostic frame here for example: */ + for (uint16_t i = 0U; i < 15U; i++){ + diagDataRspBuff[i] = (uint8_t)i; + } + diagRsp.sid = diagReq->sid; + diagRsp.packLength = 15U; + diagRsp.type = (diagRsp.packLength > SF_MAX_DATA_LENGTH)? PDU_TYPE_MULTI_PDU:PDU_TYPE_SINGLE_PDU; + ls_handle_diagnostic_response(&diagRsp); + } +#ifdef BOOTLOADER_EN + else if (diagReq->sid == LIN_SID_APP_DIAG_BOOT_MODE && diagReq->packLength == sizeof(EnterBootloaderFrame_t)){ + EnterBootloaderFrame_t *boot = (EnterBootloaderFrame_t *)((void*)diagReq->payload); + if ( boot->command == BOOT_MODE_HANDSHAKE && boot->magicKey == BOOT_MODE_MAGIC_KEY_HANDSHAKE){ + /* Reset Chip */ + TRIMHV_SFRS->RETAIN.RETAIN0 = 0x05U; + CRGA_SFRS->RESETCTRL.HARDRSTREQ = 1U; + } + } +#endif + } + }else{ + /* handle diagnostic multi pdu received sigle pdu response, user defined diagnostic frame here */ + if (diagReq->sid == LIN_SID_APP_DIAG_MULTI_PDU_RECV_SINGLE_RSP){ + /* handle diagnostic multi pdu received single pdu response, user defined diagnostic frame here */ + /* handle response data here */ + diagRsp.sid = diagReq->sid; + diagRsp.packLength = 5U;/* Valid data length not includes sid*/ + diagRsp.type = (diagRsp.packLength > SF_MAX_DATA_LENGTH)? PDU_TYPE_MULTI_PDU:PDU_TYPE_SINGLE_PDU; + ls_handle_diagnostic_response(&diagRsp); + }else if (diagReq->sid == LIN_SID_APP_DIAG_MULTI_PDU_RECV_MULTI_RSP){ + /* handle diagnostic multi pdu received multi pdu response, user defined diagnostic frame here */ + /* Package received finished */ + diagRsp.sid = diagReq->sid; + diagRsp.packLength = 15U; /* Valid data length not includes sid*/ + diagRsp.type = (diagRsp.packLength > SF_MAX_DATA_LENGTH)? PDU_TYPE_MULTI_PDU:PDU_TYPE_SINGLE_PDU; + ls_handle_diagnostic_response(&diagRsp); + }else{ + /* intent to empty */ + } + } +} + +/* + Received sleep command from lin master or bus idle timeout occurs +*/ +void DiagnosticSleepRequestHandle(SleepRequestType_t type) +{ + (void)ls_clr_go_to_sleep_flag(); + /* Set system to hibranate mode*/ + //PMU_EnterDeepSleepMode(); +} + +void busWakeupRetryTimerExpired(SoftTimer_t *timer) +{ + ls_send_wake_up_bus_signal(); +} + +/* Called timeout after bus wake up 3 tries, or called when bus recovery */ +void BusWakeUpRequestHandle(BusWakeUpRequestResult_t result) +{ + if (result == BUS_WAKEUP_REQ_RESULT_REQ_TIMEOUT){ + if (busWakeupRetryCount == 1U){ + busWakeupRetryCount++; + SoftTimer_Start(&busWakeupRetryTimer); + }else{ + busWakeupRetryCount = 0U; + } + }else{ + busWakeupRetryCount = 0U; + SoftTimer_Stop(&busWakeupRetryTimer); + } +} + + +void UnconditionalPublishedCmdsTxFinishedISR(uint8_t fid, uint8_t resvd) +{ + if ( fid == UnconditionalCmdsTable[FID_TFJR_INDEX].frame_id){ + (void)ls_ifc_clear_error_status(); + (void)ls_clr_error_code_log(); + (void)ls_clr_overrun_flag(); + } +} +/* + User defined published frame callback function which from LINS ISR + please fill frame data[0-7] only, please don't do any changes on the left info except data[x]!!!! +*///TODO +extern uint8_t g_rxbuf[8]; +extern uint8_t g_txbuf1[8]; +extern uint8_t g_txbuf2[8]; +void UnconditionalPublishedCmdsISR(LIN_Device_Frame_t *const frame) +{ + /* feed buffer to frame */ + uint8_t i; + if (frame->frame_id == UnconditionalCmdsTable[FID_TFJR_INDEX].frame_id){ + /* status management frame */ + for (i = 0; i < 8; i++) + { + frame->data[i] = g_txbuf2[i]; + } + + }else if (frame->frame_id == UnconditionalCmdsTable[FID_KEY_INDEX].frame_id){ + /* user defined data report */ + for (i = 0U; i < LIN_BUFF_SIZE; i++){ + frame->data[i] = g_txbuf1[i]; + } + }else{ + /* intent to empty */ + } +} + + +void LINS_EventTriggered_ISR(void) +{ + if (eventTriggeredLedOn == TRUE){ + eventTriggeredLedOn = FALSE; + }else{ + eventTriggeredLedOn = TRUE; + } + //UnconditionalCmdsTable[EVENT_TRIGGERED_INDEX].eventTriggered = TRUE; +} + +uint8_t LINS_GetPIDFromFID(uint8_t frameId) +{ + uint8_t id = frameId; + uint8_t P0,P1; + P0 = (uint8_t)(((id >> 0)&0x01U)^((id >> 1)&0x01U)^((id >> 2)&0x01U) ^ ((id>> 4)&0x01U)); + P1 = (uint8_t)(~(((id >> 1)&0x01U)^((id >> 3)&0x01U)^((id >> 4)&0x01U) ^ ((id>> 5)&0x01U))) & 0x01U; + id = frameId | (P0 << 6) | (P1 << 7); + return id; +} + + +void LINS_SendWakeUpSignal_ISR(void) +{ + if (busWakeupRetryCount == 0U){ + busWakeupRetryCount++; + ls_send_wake_up_bus_signal(); + } +} + +/* + User defined subscribed frame received from LIN master +*/ + +void UnconditionalSubscribedCmdsHandle(LIN_Device_Frame_t const *frame) +{ + + if (frame->frame_id == UnconditionalCmdsTable[FID_LED_CTRL_INDEX].frame_id){ + for (uint8_t i = 0; i < 2; i++) + { + g_rxbuf[i] = frame->data[i]; + } + + } + //fan_state = 0x03; +} + +void LINS_TaskHandler(void) +{ + switch(linsTaskState){ + case TASK_STATE_ACTIVE: + break; + case TASK_STATE_INIT: + ls_register_services(LIN_PROTOCOL_LIN2_2A,UnconditionalCmdsTable, (l_u8)(sizeof(UnconditionalCmdsTable)/sizeof(LIN_Device_Frame_t)),diagMultiPduInfo,&linsFramesCallback); + NVIC_SetPriority(LIN_IRQn,ISR_PRIORITY_LOW); + (void)ls_set_tp_timeout(N_AS, N_CR); + /* Note that please don't change the following glitch configuration!!!!*/ + (void)ls_set_lins_rx_glitch_filter_1st(0x00U,0x08U); + (void)ls_set_lins_rx_glitch_filter_2nd(0x0AU,0x10U); + (void)ls_set_lins_rx_glitch_filter_3rd(0x30U,0x30U); + (void)ls_diag_error_in_all_diag_frames(TRUE); + (void)l_sys_init(); + (void)ls_disable_lin_auto_sleep(TRUE); + linsTaskState = TASK_STATE_ACTIVE; + break; + default: + break; + } +} + +#endif \ No newline at end of file diff --git a/87400/usr/common/linslaveTask_J2602.c b/87400/usr/common/linslaveTask_J2602.c new file mode 100644 index 0000000..e7e5a49 --- /dev/null +++ b/87400/usr/common/linslaveTask_J2602.c @@ -0,0 +1,467 @@ +/** + * @copyright 2021 Indie microcontroller. + * + * This file is proprietary to Indie microcontroller. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie microcontroller. + * + * @file linSlaveTask.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2021/07/06 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if LIN_STACK_TYPE == LIN_STACK_TYPE_SAEJ2602 + + +BEGIN_PACK + +typedef struct{ + uint8_t reserved; + uint32_t calibPartNumber; + uint8_t dateLength; + uint8_t smallCalibCfgIndex; +}SmallCalibCfgParam_t; + +END_PACK + +static SmallCalibCfgParam_t smallCalibCfg = {0U,0x00000000U,16U,0U}; + +#define SLAVE_PN_REPORT_STRING_NUM (15U) +#define SLAVE_PN_REPORT_PACK_NUM (SLAVE_PN_REPORT_STRING_NUM/6U + 1U) +static const uint8_t slavePartNumberReporting[SLAVE_PN_REPORT_STRING_NUM] = {'I','N','D','8','3','2','0','9',' ','F','W',':','2','.','0'}; +static uint8_t slavePartNumberReportingIndex = 0U; + +#define LARGE_CALIB_RECV_NUM (14U) +static uint8_t largeCalibDataRecvBuff[LARGE_CALIB_RECV_NUM]; +static uint8_t largeCalibIsRunning = FALSE; + +#define FID_LED_CTRL DEFAULT_LINS_FID0 +#define FID_LED_REPORT DEFAULT_LINS_FID1 +#define FID_SMALL_CAL DEFAULT_LINS_FID2 +#define FID_CAL_PN_REPORT DEFAULT_LINS_FID3 +#define FID_LARGE_CAL DEFAULT_LINS_FID4 +#define FID_SLAVE_PN_REPORT DEFAULT_LINS_FID5 + +#define FID_RESVD0 DEFAULT_LINS_FID6 +#define FID_RESVD1 DEFAULT_LINS_FID7 + +#define DIAG_RECV_DATA_BUFF_SIZE (128U) +#define DIAG_SEND_DATA_BUFF_SIZE (128U) + +#define FID_LED_CTRL_INDEX (0) +#define FID_LED_REPORT_INDEX (1) +#define FID_SMALL_CAL_INDEX (2) +#define FID_CAL_PN_REPORT_INDEX (3) +#define FID_LARGE_CAL_INDEX (4) +#define FID_SLAVE_PN_REPORT_INDEX (5) + +/* ******************internal function declarations****************************/ +void DiagnosticSubscribedCmdsHandleISR(const DiagSubscribeInfo_t * const frameInfo); +void UnconditionalSubscribedCmdsHandle(LIN_Device_Frame_t const *frame); +void PublishedCmdsTxFinishedISR(uint8_t frameID,uint8_t j2602CfgRsp); +void UnconditionalPublishedCmdsISR(LIN_Device_Frame_t *const frame); +void DiagnosticSleepRequestHandle(SleepRequestType_t type); +void BusWakeUpRequestHandle(BusWakeUpRequestResult_t result); +void SAEJ2602CfgSubscribedCmdsHandle(uint8_t fid,uint8_t const *payload, uint8_t length); +void SAEJ2602DNNBroadcastSubscribedCmdsHandle(uint8_t fid,uint8_t const *payload, uint8_t length); + +/* *******************global variants declarations*****************************/ +static TaskState_t linsTaskState = TASK_STATE_INIT; +static uint8_t diagDataRspBuff[DIAG_SEND_DATA_BUFF_SIZE]; +static uint8_t diagDataRecvBuff[DIAG_RECV_DATA_BUFF_SIZE]; + +static DiagMultiPduInfo_t diagMultiPduInfo = { + .buffLength = DIAG_RECV_DATA_BUFF_SIZE, + .buff = diagDataRecvBuff, +}; +static uint8_t busWakeupRetryCount = 0U; + +static J2602StatusByte_t j2602StatusByte = { + .appInfo0 = 0U, + .appInfo1 = 0U, + .appInfo2 = 0U, + .appInfo3 = 1U, + .appInfo4 = 1U, + .err = 0U, + +}; + +void busWakeupRetryTimerExpired(SoftTimer_t *timer); + +static SoftTimer_t busWakeupRetryTimer = { + .mode = TIMER_ONE_SHOT_MODE, + .interval = 2250U, + .handler = busWakeupRetryTimerExpired +}; + + +/* LIN command handle callbacks declarations */ +static ls_LinsFramesCallback_t linsFramesCallback ={ + UnconditionalSubscribedCmdsHandle, /* received data from master */ + UnconditionalPublishedCmdsISR, /* send data to master, it's an interrupt function, please fill the data as fast as possible */ + PublishedCmdsTxFinishedISR, /* send data to master finished, it's an interrupt function, please fill the data as fast as possible */ + DiagnosticSubscribedCmdsHandleISR, /* Diagnostic sigle PDU and MultiPDU received data from master,it's an interrupt function, please fill the data as fast as possible */ + NULL, /* special functional NAD (0x7E) handler*/ + DiagnosticSleepRequestHandle, /* Diagnostic sleep request from master */ + BusWakeUpRequestHandle, /* Get the bus wake up result this would take effects after call API: ls_send_wake_up_bus_signal()*/ + SAEJ2602CfgSubscribedCmdsHandle, /* SAE J2602 -1 Configuration Messages */ + SAEJ2602DNNBroadcastSubscribedCmdsHandle, /* 5.7.2.5 DNN Based Broadcast Messages */ +}; + +/* **FID table declarations****/ +static LIN_Device_Frame_t UnconditionalCmdsTable[] = { + [FID_LED_CTRL_INDEX] = { /* frame_id: LED Control */ + .frame_id = FID_LED_CTRL, + .msg_type = LIN_MSG_TYPE_RX, + .checksum = LIN_CHECKSUM_ENHANCED, + .length = LIN_BUFF_SIZE, + .frameIsValid = TRUE, + }, + [FID_LED_REPORT_INDEX] = { + .frame_id = FID_LED_REPORT, /* frame_id: LED state report */ + .msg_type = LIN_MSG_TYPE_TX, + .checksum = LIN_CHECKSUM_ENHANCED, + .length = LIN_BUFF_SIZE, + .frameIsValid = TRUE, + }, + [FID_SMALL_CAL_INDEX] = { + .frame_id = FID_SMALL_CAL, /* frame_id: Small Calibration/Configuration */ + .msg_type = LIN_MSG_TYPE_RX, + .checksum = LIN_CHECKSUM_ENHANCED, + .length = LIN_BUFF_SIZE, + .frameIsValid = TRUE, + }, + [FID_CAL_PN_REPORT_INDEX] = { + .frame_id = FID_CAL_PN_REPORT, /* frame_id: Slave Application Calibration Part Number */ + .msg_type = LIN_MSG_TYPE_TX, + .checksum = LIN_CHECKSUM_ENHANCED, + .length = LIN_BUFF_SIZE, + .frameIsValid = TRUE, + }, + [FID_LARGE_CAL_INDEX] = { + .frame_id = FID_LARGE_CAL, /* frame_id: Large Calibration/Configuration */ + .msg_type = LIN_MSG_TYPE_RX, + .checksum = LIN_CHECKSUM_ENHANCED, + .length = LIN_BUFF_SIZE, + .frameIsValid = TRUE, + }, + [FID_SLAVE_PN_REPORT_INDEX] = { + .frame_id = FID_SLAVE_PN_REPORT, /* frame_id: Slave Part Number Reporting */ + .msg_type = LIN_MSG_TYPE_TX, + .checksum = LIN_CHECKSUM_ENHANCED, + .length = LIN_BUFF_SIZE, + .frameIsValid = TRUE, + }, +}; + + +/* please don't do any changes for it would be used by lin stack */ +LIN_Device_Frame_t volatile *LINS_GetUcndFramesTable(uint8_t *tableItemsCount) +{ + *tableItemsCount = (uint8_t)(sizeof(UnconditionalCmdsTable)/sizeof(LIN_Device_Frame_t)); + return UnconditionalCmdsTable; +} + +/* + Diagnostic subscribed frame received from LIN master +*/ +void DiagnosticSubscribedCmdsHandleISR(const DiagSubscribeInfo_t *const diagReq) +{ + DiagPublishInfo_t diagRsp={ + .sid = diagReq->sid, + .type = diagReq->type, + .payload = diagDataRspBuff, + }; + if (diagReq->type == PDU_TYPE_SINGLE_PDU){ + if (diagReq->sid >= LIN_SID_ASSIGN_NAD && diagReq->sid <= LIN_SID_ASSIGN_FRAME_ID_RANGE){ + /* handle Node configuration and Identification commands*/ + diagRsp.type = PDU_TYPE_SINGLE_PDU; + if (LNCI_HandleNodeCfgIdentifyRequest(diagReq,&diagRsp)== TRUE){ + ls_handle_diagnostic_response(&diagRsp); + } + }else{ + if (diagReq->sid == LIN_SID_APP_DIAG_SINGLE_PDU_RECV_MULTI_RSP){ + /* handle diagnostic single pdu, multi response, user defined diagnostic frame here for example: */ + for (uint16_t i = 0U; i < 15U; i++){ + diagDataRspBuff[i] = (uint8_t)i; + } + diagRsp.sid = diagReq->sid; + diagRsp.packLength = 15U; + diagRsp.type = (diagRsp.packLength > SF_MAX_DATA_LENGTH)? PDU_TYPE_MULTI_PDU:PDU_TYPE_SINGLE_PDU; + ls_handle_diagnostic_response(&diagRsp); + } +#ifdef BOOTLOADER_EN + else if (diagReq->sid == LIN_SID_APP_DIAG_BOOT_MODE && diagReq->packLength == sizeof(EnterBootloaderFrame_t)){ + EnterBootloaderFrame_t *boot = (EnterBootloaderFrame_t *)((void*)diagReq->payload); + if ( boot->command == BOOT_MODE_HANDSHAKE && boot->magicKey == BOOT_MODE_MAGIC_KEY_HANDSHAKE){ + /* Reset Chip */ + TRIMHV_SFRS->RETAIN.RETAIN0 = 0x05U; + CRGA_SFRS->RESETCTRL.HARDRSTREQ = 1U; + } + } +#endif + } + }else{ + /* handle diagnostic multi pdu received sigle pdu response, user defined diagnostic frame here */ + if (diagReq->sid == LIN_SID_APP_DIAG_MULTI_PDU_RECV_SINGLE_RSP){ + /* handle diagnostic multi pdu received single pdu response, user defined diagnostic frame here */ + /* handle response data here */ + diagRsp.sid = diagReq->sid; + diagRsp.packLength = 5U;/* Valid data length not includes sid*/ + diagRsp.type = (diagRsp.packLength > SF_MAX_DATA_LENGTH)? PDU_TYPE_MULTI_PDU:PDU_TYPE_SINGLE_PDU; + ls_handle_diagnostic_response(&diagRsp); + }else if (diagReq->sid == LIN_SID_APP_DIAG_MULTI_PDU_RECV_MULTI_RSP){ + /* handle diagnostic multi pdu received multi pdu response, user defined diagnostic frame here */ + /* Package received finished */ + diagRsp.sid = diagReq->sid; + diagRsp.packLength = 15U; /* Valid data length not includes sid*/ + diagRsp.type = (diagRsp.packLength > SF_MAX_DATA_LENGTH)? PDU_TYPE_MULTI_PDU:PDU_TYPE_SINGLE_PDU; + ls_handle_diagnostic_response(&diagRsp); + }else{ + /* intent to empty */ + } + } +} + +/* + Received sleep command from lin master or bus idle timeout occurs +*/ +void DiagnosticSleepRequestHandle(SleepRequestType_t type) +{ + /* Set lin to sleep mode */ + /* LINS_SetSlaveModuleToSleep(); */ + /* Set system to hibranate mode */ + PMU_EnterDeepSleepMode(); +} + + +void PublishedCmdsTxFinishedISR(uint8_t frameID,uint8_t j2602CfgRsp) +{ + if ( (frameID != LIN_FRAME_ID_DIAG_SLAVER_RSP) || (frameID == LIN_FRAME_ID_DIAG_SLAVER_RSP && j2602CfgRsp == TRUE)){ + ls_reset_J2602_error_code((J2602ErrCode_t)j2602StatusByte.err); /* clear error when response successfully */ + } +} + +void LINS_SetDeviceUnconfigured(void) +{ + j2602StatusByte.appInfo4 = 1U; + j2602StatusByte.appInfo3 = 1U; + smallCalibCfg.calibPartNumber = 0U; +} + +/* + User defined published frame callback function which from LINS ISR + please fill frame data[0-7] only, please don't do any changes on the left info except data[x]!!!! +*/ +void UnconditionalPublishedCmdsISR(LIN_Device_Frame_t *const frame) +{ + j2602StatusByte.err = (uint8_t)ls_read_J2602_error_code(); /* read error but not clear automatically */ + /* feed buffer to frame */ + if (frame->frame_id == UnconditionalCmdsTable[FID_LED_REPORT_INDEX].frame_id){ + /* LED status report */ + frame->data[0] = j2602StatusByte.payload; + frame->data[1] = APPL_GetLEDState(); + frame->data[2] = 0xFFU; + frame->data[3] = ((uint8_t)SAFM_GetBatteryState() << 2) | ((uint8_t)SAFM_GetChipTemperatureState() << 4); + for (uint8_t i = 4U; i < LIN_BUFF_SIZE; i++){ + frame->data[i] = 0xFFU; + } + }else if (frame->frame_id == UnconditionalCmdsTable[FID_CAL_PN_REPORT_INDEX].frame_id){ + /* Calibration Part Number report*/ + frame->data[0] = j2602StatusByte.payload; + ((SmallCalibCfgParam_t *)frame->data)->calibPartNumber = smallCalibCfg.calibPartNumber; + for (uint8_t i = 5U; i < LIN_BUFF_SIZE; i++){ + frame->data[i] = 0xFFU; + } + smallCalibCfg.smallCalibCfgIndex = 0U; + }else if (frame->frame_id == UnconditionalCmdsTable[FID_SLAVE_PN_REPORT_INDEX].frame_id){ + j2602StatusByte.appInfo4 = 1U; /* I'm not configured */ + frame->data[0] = j2602StatusByte.payload; + frame->data[1] = slavePartNumberReportingIndex; + for (uint8_t i = 0U; i < LIN_BUFF_SIZE -2U; i++){ + if ( (slavePartNumberReportingIndex*6U + i)>= SLAVE_PN_REPORT_STRING_NUM){ + frame->data[i+2U] = 0x00U; + }else{ + frame->data[i+2U] = slavePartNumberReporting[slavePartNumberReportingIndex*6U + i]; + } + } + if (++slavePartNumberReportingIndex >= SLAVE_PN_REPORT_PACK_NUM){ + slavePartNumberReportingIndex = 0U; + } + }else{ + /* intent to empty */ + } +} + + +void SAEJ2602CfgSubscribedCmdsHandle(uint8_t fid,uint8_t const *payload, uint8_t length) +{ + uint8_t databuff[7]={0xFFU,0xFFU,0xFFU,0xFFU,0xFFU,0xFFU,0xFFU}; + SaeJ2602_3C3ECfg_t const *cfg = (SaeJ2602_3C3ECfg_t const*)((void const*)payload); + j2602StatusByte.err = (uint8_t)ls_read_J2602_error_code(); + if (fid == 0x3CU){/* 0x3C */ + if ( cfg->magicKey == 0x55555555U){ + databuff[0] = (cfg->nad & 0x70U) >> 4U; + ls_handle_SAEJ2602Cfg_response(j2602StatusByte.payload, databuff); + } + }else{/* 0x3E */ + if ( cfg->magicKey == 0xAAAAAAAAU){ + databuff[0] = (cfg->nad & 0xF0U) >> 4U; + ls_handle_SAEJ2602Cfg_response(j2602StatusByte.payload, databuff); + } + } +} + +/* SAEJ2602 -1 :5.7.2.5 DNN Based Broadcast Messages: 0x38,0x39,0x3A,0x3B based on MESSAGE_ID_BLOCK_COUNT and NAD*/ +void SAEJ2602DNNBroadcastSubscribedCmdsHandle(uint8_t fid,uint8_t const *payload, uint8_t length) +{ +#if MESSAGE_ID_BLOCK_COUNT == 4U || MESSAGE_ID_BLOCK_COUNT == 8U || MESSAGE_ID_BLOCK_COUNT == 16U + uint32_t broadcaseContent = 0U; + uint8_t dnn = (ls_read_nad()&0x0FU); + + if (fid == 0x38U || fid == 0x3AU){ + for (uint8_t i = 0U; i < (MESSAGE_ID_BLOCK_COUNT/4U); i++){ + broadcaseContent += (uint32_t)payload[dnn+i] << (8U*i); + } + }else{ + for (uint8_t i = 0U; i < (MESSAGE_ID_BLOCK_COUNT/4U); i++){ + broadcaseContent += (uint32_t)payload[dnn + i - 8U] << (8U*i); + } + } +#else + #error invalid MESSAGE_ID_BLOCK_COUNT !! +#endif + +} + +/* + User defined subscribed frame received from LIN master +*/ +void UnconditionalSubscribedCmdsHandle(LIN_Device_Frame_t const *frame) +{ + if (frame->frame_id == UnconditionalCmdsTable[FID_LED_CTRL_INDEX].frame_id){ + APPL_HandleControlCommands(frame); + }else if (frame->frame_id == UnconditionalCmdsTable[FID_SMALL_CAL_INDEX].frame_id){ + smallCalibCfg.calibPartNumber = 0U; + j2602StatusByte.appInfo3 = 1U; + for (uint8_t i = 0U; i < LIN_BUFF_SIZE; i++){ + diagDataRecvBuff[smallCalibCfg.smallCalibCfgIndex*LIN_BUFF_SIZE + i] = frame->data[i]; + } + smallCalibCfg.smallCalibCfgIndex++; + if ( (smallCalibCfg.smallCalibCfgIndex*LIN_BUFF_SIZE) >= smallCalibCfg.dateLength ){ + /* do checksum calculating */ + uint8_t checksum = 0U; + for (uint8_t i = 0U; i < smallCalibCfg.dateLength; i++){ + checksum += diagDataRecvBuff[i]; + } + if (checksum == 0xFFU){ + smallCalibCfg.calibPartNumber = ((SmallCalibCfgParam_t*)diagDataRecvBuff)->calibPartNumber; + j2602StatusByte.appInfo3 = 0U; + } + smallCalibCfg.smallCalibCfgIndex = 0U; + } + }else if (frame->frame_id == UnconditionalCmdsTable[FID_LARGE_CAL_INDEX].frame_id){ + + if (largeCalibIsRunning == TRUE && frame->data[0] == 0U){ /* Calibration/Configuration Mode has finished */ + largeCalibIsRunning = FALSE; + j2602StatusByte.appInfo4 = 0U; + }else if (largeCalibIsRunning == FALSE && frame->data[0] == 0U){/* Calibration/Configuration Mode has started */ + largeCalibIsRunning = TRUE; + j2602StatusByte.appInfo4 = 1U; + for (uint8_t i = 0; i < 7U; i++){ + largeCalibDataRecvBuff[i] = frame->data[1U+ i]; + } + }else{ + for (uint8_t i = 0; i < 7U; i++){ + if ((frame->data[0]*7U+i) < LARGE_CALIB_RECV_NUM){ + largeCalibDataRecvBuff[frame->data[0]*7U+i] = frame->data[1U+ i]; + } + } + } + } +} + + +void busWakeupRetryTimerExpired(SoftTimer_t *timer) +{ + ls_send_wake_up_bus_signal(); +} + +/* Called timeout after bus wake up 3 tries, or called when bus recovery */ +void BusWakeUpRequestHandle(BusWakeUpRequestResult_t result) +{ + if (result == BUS_WAKEUP_REQ_RESULT_REQ_TIMEOUT){ + if (busWakeupRetryCount == 1U){ + busWakeupRetryCount++; + SoftTimer_Start(&busWakeupRetryTimer); + }else{ + busWakeupRetryCount = 0U; + } + }else{ + busWakeupRetryCount = 0U; + SoftTimer_Stop(&busWakeupRetryTimer); + } +} + + +uint8_t LINS_GetPIDFromFID(uint8_t frameId) +{ + uint8_t id = frameId; + uint8_t P0,P1; + P0 = (uint8_t)(((id >> 0)&0x01U)^((id >> 1)&0x01U)^((id >> 2)&0x01U) ^ ((id>> 4)&0x01U)); + P1 = (uint8_t)(~(((id >> 1)&0x01U)^((id >> 3)&0x01U)^((id >> 4)&0x01U) ^ ((id>> 5)&0x01U))) & 0x01U; + id = frameId | (P0 << 6) | (P1 << 7); + return id; +} + + +void LINS_SendWakeUpSignal_ISR(void) +{ + if (busWakeupRetryCount == 0U){ + busWakeupRetryCount++; + ls_send_wake_up_bus_signal(); + } +} + +void LINS_TaskHandler(void) +{ + switch(linsTaskState){ + case TASK_STATE_ACTIVE: + break; + case TASK_STATE_INIT: + ls_register_services(LIN_PROTOCOL_LIN2_2A,UnconditionalCmdsTable, (l_u8)(sizeof(UnconditionalCmdsTable)/sizeof(LIN_Device_Frame_t)),diagMultiPduInfo,&linsFramesCallback); + NVIC_SetPriority(LIN_IRQn,ISR_PRIORITY_LOW); + (void)ls_set_tp_timeout(N_AS, N_CR); + /* Note that please don't change the following glitch configuration!!!!*/ + (void)ls_set_lins_rx_glitch_filter_1st(0x00U,0x08U); + (void)ls_set_lins_rx_glitch_filter_2nd(0x0AU,0x10U); + (void)ls_set_lins_rx_glitch_filter_3rd(0x30U,0x30U); + (void)ls_diag_error_in_all_diag_frames(TRUE); + (void)l_sys_init(); + ls_set_J2602_hardware_reset(TRUE);/* It's a hardreset init */ +// if(GPIO_SFRS->GPIO_CFG[(uint8_t)GPIO_PORT_2].ACTDET != 0U){ +// GPIO_SFRS->GPIO_CFG[(uint8_t)GPIO_PORT_2].CLR = 1U; +// LINS_SendWakeUpSignal_ISR(); +// } +// GPIO_RegisterIRQ(GPIO_PORT_2, GPIO_EDGE_FALLING, LINS_SendWakeUpSignal_ISR); + linsTaskState = TASK_STATE_ACTIVE; + break; + default: + break; + } +} + +#endif \ No newline at end of file diff --git a/87400/usr/common/linslaveTask_Private.c b/87400/usr/common/linslaveTask_Private.c new file mode 100644 index 0000000..6041be5 --- /dev/null +++ b/87400/usr/common/linslaveTask_Private.c @@ -0,0 +1,220 @@ +/** + * @copyright 2021 Indie microcontroller. + * + * This file is proprietary to Indie microcontroller. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie microcontroller. + * + * @file linSlaveTask.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2021/07/06 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if LIN_STACK_TYPE == LIN_STACK_TYPE_PRIVATE + +BEGIN_PACK + +typedef struct{ + uint8_t nad; + uint8_t pci; + uint8_t sid; + uint8_t command; + uint32_t magicKey; +}bootloaderHandshake_t; + +END_PACK + + + +#define FID_MOTOR_CTRL DEFAULT_LINS_FID0 +#define FID_STATUS_FRAME DEFAULT_LINS_FID1 +#define DIAG_SEND_FRAME_3C (0x3CU) +#define DIAG_REQ_FRAME_3D (0x3DU) + + +#define FID_MOTOR_CTRL_INDEX (0) +#define FID_STATUS_FRAME_INDEX (1) +#define FID_DIAG_SEND_3C_INDEX (2) +#define FID_DIAG_REQ_3D_INDEX (3) + +/* ******************internal function declarations****************************/ +void SubscribedCmdsHandleISR(LIN_Device_Frame_t const *frame); +void PublishedCmdsISR(LIN_Device_Frame_t *const frame); +void SleepRequestHandle(void); +void DiagCmdsHandle(LIN_Device_Frame_t const *frame); +static LIN_Device_Frame_t receivedFrame; + +/* *******************global variants declarations*****************************/ +static TaskState_t linsTaskState = TASK_STATE_INIT; + +/* LIN command handle callbacks declarations */ +static ls_LinsPrivateFramesCallback_t linsFramesCallback ={ + SubscribedCmdsHandleISR, /* received data from master,it's an interrupt function, please fill the data as fast as possible*/ + PublishedCmdsISR, /* send data to master, it's an interrupt function, please fill the data as fast as possible */ + SleepRequestHandle, /* sleep request*/ +}; + +/* **FID table declarations****/ +static LIN_Device_Frame_t CmdsTable[DEFAULT_LINS_FID_SIZE] = { + [FID_MOTOR_CTRL_INDEX] = { + .frame_id = FID_MOTOR_CTRL, + .msg_type = LIN_MSG_TYPE_RX, + .checksum = LIN_CHECKSUM_ENHANCED, + .length = LIN_BUFF_SIZE, + .frameIsValid = TRUE, + }, + [FID_STATUS_FRAME_INDEX] = { + .frame_id = FID_STATUS_FRAME, /* status management frame */ + .msg_type = LIN_MSG_TYPE_TX, + .checksum = LIN_CHECKSUM_ENHANCED, + .length = LIN_BUFF_SIZE, + .frameIsValid = TRUE, + }, + [FID_DIAG_SEND_3C_INDEX] = { + .frame_id = DIAG_SEND_FRAME_3C, /* 0x3C */ + .msg_type = LIN_MSG_TYPE_RX, + .checksum = LIN_CHECKSUM_CLASSIC, + .length = LIN_BUFF_SIZE, + .frameIsValid = TRUE, + }, + [FID_DIAG_REQ_3D_INDEX] = { + .frame_id = DIAG_REQ_FRAME_3D, /* 0x3D */ + .msg_type = LIN_MSG_TYPE_TX, + .checksum = LIN_CHECKSUM_CLASSIC, + .length = LIN_BUFF_SIZE, + .frameIsValid = TRUE, + }, +}; + +/* + Received sleep command from lin master or bus idle timeout occurs +*/ +void SleepRequestHandle(void) +{ + /* Set lin to sleep mode */ +/* LINS_SetSlaveModuleToSleep();*/ + /* Set system to hibranate mode*/ + //PMU_EnterDeepSleepMode(); +} + +/* + User defined published frame callback function which from LINS ISR + please fill frame data[0-7] only, please don't do any changes on the left info except data[x]!!!! +*/ +void PublishedCmdsISR(LIN_Device_Frame_t *const frame) +{ + /* feed buffer to frame */ + if (frame->frame_id == CmdsTable[FID_STATUS_FRAME_INDEX].frame_id){ + /* status management frame */ + uint16_t status = ls_read_sys_status(); + frame->data[0] = (uint8_t)status; + frame->data[1] = LINS_GetPIDFromFID((uint8_t)(status >> 8)); + frame->data[2] = ls_read_error_code(); + frame->data[3] = 0;// ((uint8_t)SAFM_GetBatteryState() << 2) | ((uint8_t)SAFM_GetChipTemperatureState() << 4); + /* MUST BE 4 bytes Aligned */ + + } +} + + +/* + User defined subscribed frame received from LIN master +*/ +void SubscribedCmdsHandleISR(LIN_Device_Frame_t const *frame) +{ + receivedFrame = *frame; + TM_PostTask(TASK_ID_LINS); + +} + +void DiagCmdsHandle(LIN_Device_Frame_t const *frame) +{ +#ifdef BOOTLOADER_EN + bootloaderHandshake_t *hand = (bootloaderHandshake_t*)((void*)(frame->data)); + if ( hand->nad == INIT_LINS_NAD_ADDR && hand->pci == 0x06U && hand->sid == LIN_SID_APP_DIAG_BOOT_MODE && hand->command == BOOT_MODE_HANDSHAKE && hand->magicKey == BOOT_MODE_MAGIC_KEY_HANDSHAKE){ + /* Reset Chip */ + TRIMHV_SFRS->RETAIN.RETAIN0 = 0x05U; + CRGA_SFRS->RESETCTRL.HARDRSTREQ = 1U; + } +#endif + +} + +void LINS_TaskHandler(void) +{ + switch(linsTaskState){ + case TASK_STATE_ACTIVE: + if (receivedFrame.frame_id == CmdsTable[FID_MOTOR_CTRL_INDEX].frame_id){ + APPL_HandleControlCommands(&receivedFrame); + }else if (receivedFrame.frame_id == CmdsTable[FID_DIAG_SEND_3C_INDEX].frame_id){ + DiagCmdsHandle(&receivedFrame); + }else{ + + } + break; + case TASK_STATE_INIT: + LINS_Init(); + LINS_RegisterPrivateServices(CmdsTable, (l_u8)(sizeof(CmdsTable)/sizeof(LIN_Device_Frame_t)), &linsFramesCallback); + /* Note that please don't change the following glitch configuration!!!!*/ + (void)ls_set_lins_rx_glitch_filter_1st(0x00U,0x08U); + (void)ls_set_lins_rx_glitch_filter_2nd(0x0AU,0x10U); + (void)ls_set_lins_rx_glitch_filter_3rd(0x30U,0x30U); + linsTaskState = TASK_STATE_ACTIVE; + break; + default: + break; + } +} + + +uint8_t LINS_GetPIDFromFID(uint8_t frameId) +{ + uint8_t id = frameId; + uint8_t P0,P1; + P0 = (uint8_t)(((id >> 0)&0x01U)^((id >> 1)&0x01U)^((id >> 2)&0x01U) ^ ((id>> 4)&0x01U)); + P1 = (uint8_t)(~(((id >> 1)&0x01U)^((id >> 3)&0x01U)^((id >> 4)&0x01U) ^ ((id>> 5)&0x01U))) & 0x01U; + id = frameId | (P0 << 6) | (P1 << 7); + return id; +} + + +/* please don't do any changes for it would be used by lin stack */ +LIN_Device_Frame_t volatile *LINS_GetUcndFramesTable(uint8_t *tableItemsCount) +{ + *tableItemsCount = (uint8_t)(sizeof(CmdsTable)/sizeof(LIN_Device_Frame_t)); + return CmdsTable; +} + + +static LINClusterParams_t *linParams = NULL; +static LIN_Device_Frame_t volatile *frameTable = NULL; + +void LNCI_Init(void) +{ + uint8_t tableItemsCount; + /* get lin information from flash storage */ + linParams = PDS_GetLINParam(); + /* get frame table information */ + frameTable = LINS_GetUcndFramesTable(&tableItemsCount); + + for (uint8_t i = 0U; i < tableItemsCount; i++){ + frameTable[i].frame_id = linParams->frameInfo[i].frameId; + frameTable[i].frameIsValid = linParams->frameInfo[i].frameIsValid; + } +} + +#endif \ No newline at end of file diff --git a/87400/usr/common/measureTask.c b/87400/usr/common/measureTask.c new file mode 100644 index 0000000..e2f961d --- /dev/null +++ b/87400/usr/common/measureTask.c @@ -0,0 +1,93 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file measureTask.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ +#include +#include + +static TaskState_t adcTaskState = TASK_STATE_INIT; +static volatile uint32_t measStart = 0U; +void measureDoneISR(ADCMeasureParam_t item, uint16_t *const result); +void measureParamInit(void); + +void updateTimerExpired(SoftTimer_t *timer); + +static volatile uint32_t adcConvertDone = 0U; + +static SoftTimer_t updateTimer = { + .mode = TIMER_PERIODIC_MODE, + .interval = 50U, + .handler = updateTimerExpired +}; + + + + +void updateTimerExpired(SoftTimer_t *timer) +{ + + TM_PostTask(TASK_ID_ADC_MEASURE); +} + +extern uint16_t g_AdVal[3]; +void measureDoneISR(ADCMeasureParam_t param, uint16_t *const result) +{ + measStart = 1U; + TM_PostTask(TASK_ID_ADC_MEASURE); + g_AdVal[0] = result[3]; + g_AdVal[1] = result[2]; +} + + + + + + +void MES_TaskHandler(void) +{ + switch(adcTaskState){ + case TASK_STATE_INIT: + measureParamInit(); + ADC_GeneralInit();/* init ADC */ + ADC_RegisterIRQ(measureDoneISR); + /* start updating timer */ + SoftTimer_Start(&updateTimer); + adcTaskState = TASK_STATE_ACTIVE; + break; + case TASK_STATE_ACTIVE: + + break; + default: + break; + } +} + + +void measureParamInit(void) +{ + +} + + + + + + + + + + + + + + + diff --git a/87400/usr/common/measureTask.h b/87400/usr/common/measureTask.h new file mode 100644 index 0000000..261e19c --- /dev/null +++ b/87400/usr/common/measureTask.h @@ -0,0 +1,40 @@ +#ifndef _ADC_MEASUREMENT_TASK_H +#define _ADC_MEASUREMENT_TASK_H + +#include +#include +#include "systick_device.h" +#include +#include +#include "hwcfg.h" + +#define INVALID_PARAM (0x7FFFU) +#define INVALID_VOLT (0x7FFFU) +#define INVALID_TEMP (-127) + +/* + * Get battery voltage in mV + * @param [out] battVolt: 0-32678 + * @return 0: get voltage success, other : failed + */ +int8_t MES_GetBatteryVolt(uint16_t *battVolt); + +/* + * Get chip temperature in 1C + * @param [out] chipTemperature: -127-127C + * @return 0: get voltage success, other : failed + */ +int16_t MES_GetChipTemperature(int16_t *chipTemperature); + +/* + * measurement Task handle + * @return none + */ +void MES_TaskHandler(void); + + + + + + +#endif \ No newline at end of file diff --git a/87400/usr/common/motorControlTask.c b/87400/usr/common/motorControlTask.c new file mode 100644 index 0000000..7ab765f --- /dev/null +++ b/87400/usr/common/motorControlTask.c @@ -0,0 +1,22 @@ +#include + +static TaskState_t motorState = TASK_STATE_INIT; + + + + +void MotorCtrl_TaskHandler(void) +{ + switch(motorState){ + case TASK_STATE_INIT: + /* Motor control initialization */ + + /* End of Motor control initialization */ + motorState = TASK_STATE_ACTIVE; + break; + case TASK_STATE_ACTIVE: + break; + default: + break; + } +} \ No newline at end of file diff --git a/87400/usr/common/motorControlTask.h b/87400/usr/common/motorControlTask.h new file mode 100644 index 0000000..f090f32 --- /dev/null +++ b/87400/usr/common/motorControlTask.h @@ -0,0 +1,37 @@ +#ifndef MOTOR_CONTROL_TASK_H__ +#define MOTOR_CONTROL_TASK_H__ + +#include +#include +#include +#include + + + +void MotorCtrl_TaskHandler(void); + + + + + + + + + + + + + + + + + + + + + + + + + +#endif \ No newline at end of file diff --git a/87400/usr/common/pdsTask.c b/87400/usr/common/pdsTask.c new file mode 100644 index 0000000..0dbfbe8 --- /dev/null +++ b/87400/usr/common/pdsTask.c @@ -0,0 +1,162 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file pdsTask.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +uint8_t pds_store(uint8_t index); + +static SystemParams_t systemParam; +static TaskState_t pdsState = TASK_STATE_INIT; +static PdsStatus_t pdsStatus = PDS_STATUS_USING_NORMAL; + +#define PDS_ACTIVE_DATA_INDEX (0U) +#define PDS_ACTIVE_DATA_BACKUP_INDEX (1U) + +void PDS_Init(void) +{ + CRC32_Init(); + + SystemParams_t *param = (SystemParams_t *)FLASH_START_ADDRESS_SYSTEM_DATA; + uint32_t crcValue = CRC32_GetRunTimeCRC32((uint8_t *)(void *)¶m->info ,(uint16_t)sizeof(param->info)); + + if (crcValue == param->head.crc32){ + systemParam = *param; + pdsStatus = PDS_STATUS_USING_NORMAL; + }else{ + param = (SystemParams_t *)FLASH_START_ADDRESS_SYSTEM_DATA_BACK_UP; + crcValue = CRC32_GetRunTimeCRC32((uint8_t *)¶m->info ,(uint16_t)sizeof(param->info)); + if (crcValue == param->head.crc32){ + systemParam = *param; + pdsStatus = PDS_STATUS_USING_BACKUP; + }else{ + pdsStatus = PDS_STATUS_USING_DEFAULT; + } + } + + if (pdsStatus == PDS_STATUS_USING_DEFAULT){ +/* **********************fix LIN configuration default value ************************************/ + systemParam.head.index = 0U; + systemParam.info.linParams.nad = INIT_LINS_NAD_ADDR; + systemParam.info.linParams.supplierID = LINS_SUPPLIER_ID; + systemParam.info.linParams.functionID = LINS_FUNCTION_ID; + systemParam.info.linParams.variant = LINS_VARIANT; + systemParam.info.linParams.serialNo = LINS_SERIAL_NO; + systemParam.info.linParams.fwVersion = LINS_FW_VERSION; + systemParam.info.linParams.hwVersion = LINS_HW_VERSION; + + LIN_Device_Frame_t volatile *frame = LINS_GetUcndFramesTable(&systemParam.info.linParams.frameIDSize); + for (uint8_t i = 0; i < systemParam.info.linParams.frameIDSize; i++){ + systemParam.info.linParams.frameInfo[i].frameId = frame[i].frame_id; + systemParam.info.linParams.frameInfo[i].frameIsValid = TRUE; + } + } + ls_set_initialNad(INIT_LINS_NAD_ADDR); + ls_set_nad(INIT_LINS_NAD_ADDR); + /* must be call here for init LIN param */ + LNCI_Init(); +} + + +uint8_t pds_store(uint8_t index) +{ +/****************************************************************************************************************/ + uint16_t wordLength; + uint32_t *pWord = (uint32_t *)((void *)&systemParam); + uint32_t crcValue = CRC32_GetRunTimeCRC32((uint8_t *)(&systemParam.info) ,(uint16_t)sizeof(systemParam.info)); + systemParam.head.crc32 = crcValue; + systemParam.head.index ++; + + /* sizeof(SystemParams_t) is the timers of word */ + wordLength = ((uint16_t)sizeof(SystemParams_t) >> 2U); + + pdsStatus = PDS_STATUS_USING_NORMAL; + + if (index == PDS_ACTIVE_DATA_INDEX){ + /*write sys data normal*/ + f_FLASH_EraseSector(FLASH_START_ADDRESS_SYSTEM_DATA); + for (uint16_t i = 0U; i < wordLength; i+=2U){ + if ((i+1U) < wordLength){ + f_FLASH_Write2WordsWithECC(FLASH_START_ADDRESS_SYSTEM_DATA +(uint32_t)i*4U, pWord[i],pWord[i+1U]); + } + } + }else{ + /*write sys data back up*/ + f_FLASH_EraseSector(FLASH_START_ADDRESS_SYSTEM_DATA_BACK_UP); + for (uint16_t i = 0U; i < wordLength; i+=2U){ + if ((i+1U) < wordLength){ + f_FLASH_Write2WordsWithECC(FLASH_START_ADDRESS_SYSTEM_DATA_BACK_UP +(uint32_t)i*4U, pWord[i],pWord[i+1U]); + } + } + } + return 0U; +} + + + +LINClusterParams_t *PDS_GetLINParam(void) +{ + return &systemParam.info.linParams; +} + +PdsStatus_t PDS_GetPdsStatus(void) +{ + return pdsStatus; +} + + +void PDS_TaskHandler(void) +{ + switch(pdsState){ + case TASK_STATE_INIT: + pdsState = TASK_STATE_ACTIVE; + break; + case TASK_STATE_ACTIVE: + /* storage system parameters */ + (void)pds_store(PDS_ACTIVE_DATA_INDEX); + pdsState = TASK_STATE_PROCESSING; + TM_PostTask(TASK_ID_PDS); + break; + case TASK_STATE_PROCESSING: + /* storage system parameters backup*/ + (void)pds_store(PDS_ACTIVE_DATA_BACKUP_INDEX); + /* set save parameters flag for lin stack*/ + (void)ls_save_configuration(); + pdsState = TASK_STATE_ACTIVE; + break; + default: + break; + } +} + + + + + + + + + + + + + + + diff --git a/87400/usr/common/pdsTask.h b/87400/usr/common/pdsTask.h new file mode 100644 index 0000000..f65d68b --- /dev/null +++ b/87400/usr/common/pdsTask.h @@ -0,0 +1,56 @@ +#ifndef PDS_H__ +#define PDS_H__ + +#include +#include +#include + +/**************************************************************************************************/ + +typedef struct{ + uint8_t frameId; + uint8_t frameIsValid; +}FrameID_t; + +/**************************************************************************************************/ +/* lin parameters */ +typedef union{ + /* 16 + 32*2 = 80 */ + struct{ + uint16_t fwVersion; /* Reserved should be LINS_FW_VERSION */ + uint16_t hwVersion; /* Reserved should be LINS_HW_VERSION */ + uint32_t serialNo; /* Reserved should be LINS_SERIAL_NO */ + uint16_t supplierID; /* Reserved should be LINS_SUPPLIER_ID */ + uint16_t functionID; /* Reserved should be LINS_FUNCTION_ID */ + uint8_t variant; /* Reserved should be LINS_VARIANT */ + uint8_t nad; + uint8_t frameIDSize; + FrameID_t frameInfo[32]; + }; + uint8_t payload[96U]; +}LINClusterParams_t; +/**************************************************************************************************/ + +typedef enum{ + PDS_STATUS_USING_NORMAL, + PDS_STATUS_USING_BACKUP, + PDS_STATUS_USING_DEFAULT, +}PdsStatus_t; + + +typedef struct{ + struct{ + uint32_t crc32; + uint32_t index; + }head; /* size = 8 bytes */ + struct{ + LINClusterParams_t linParams; /* size = 96 bytes */ + }info; +}SystemParams_t; + +LINClusterParams_t *PDS_GetLINParam(void); +PdsStatus_t PDS_GetPdsStatus(void); +void PDS_Init(void); +void PDS_TaskHandler(void); + +#endif \ No newline at end of file diff --git a/87400/usr/common/safetyMonitorTask.c b/87400/usr/common/safetyMonitorTask.c new file mode 100644 index 0000000..bef8cf7 --- /dev/null +++ b/87400/usr/common/safetyMonitorTask.c @@ -0,0 +1,126 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file safetyMonitorTask.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ + +#include + +#define OVER_TEMPERATURE_HIGH (130) /*celsius degree */ +#define OVER_TEMPERATURE_RELEASE (OVER_TEMPERATURE_HIGH - 10U) /*celsius degree */ + + +#define LED_PN_SHORT_VOLT (500U) /* mV */ +#define LED_PN_SHORT_OPEN (4000U) /* mV */ + +#define INTENSITY_RATIO_TYPICAL (1024U) /* 100% of max intensity */ +#define INTENSITY_RATIO_HIGH_TEMPERATURE (INTENSITY_RATIO_TYPICAL*4U/5U) /* 80% of max intensity */ +#define INTENSITY_RATIO_BATT_ISSUE (0U) /* 0% of max intensity */ + + +static TaskState_t safeMonitorState = TASK_STATE_INIT; +static BatteryState_t battState = BATT_STATE_NORMAL; +static BatteryState_t battLastState = BATT_STATE_NORMAL; +static ChipTemperatureState_t chipTemperatureState = CHIP_TEMPERATURE_STATE_NORMAL; +static ChipTemperatureState_t chipTemperatureLastState = CHIP_TEMPERATURE_STATE_NORMAL; + +static void UnderVoltageProtection_ISR(void); +static void OverVoltageProtection_ISR(void); +static void safetyHandle(void); +static void safetyInit(void); +static void safeMonitorTimerExpired(SoftTimer_t *timer); + +static SoftTimer_t safeMonitorTimer = { + .mode = TIMER_PERIODIC_MODE, + .interval = 200U, + .handler = safeMonitorTimerExpired +}; + + +static void safeMonitorTimerExpired(SoftTimer_t *timer) +{ + TM_PostTask(TASK_ID_SAFETY_MONITOR); + NVIC_EnableIRQ(UV_OV_IRQn); + NVIC_EnableIRQ(OVTEMP_IRQn); + CRGA_SFRS->RESETCTRL.OVTEMPFLAGCLR = 1U; +} + +void SAFM_TaskHandler(void) +{ + switch(safeMonitorState){ + case TASK_STATE_INIT: + safetyInit(); + SoftTimer_Start(&safeMonitorTimer); + safeMonitorState = TASK_STATE_ACTIVE; + break; + case TASK_STATE_ACTIVE: + safetyHandle(); + break; + default: + break; + } +} + + +static void safetyHandle(void) +{ + /* Battery Voltage Protection Handling */ + battState = (BatteryState_t)HW_PROT_GetBattVoltState(); + if ((chipTemperatureLastState != chipTemperatureState) || (battLastState != battState)){ + chipTemperatureLastState = chipTemperatureState; + battLastState = battState; + if (battState == BATT_STATE_LOW){ + + }else{ + /* Restart OV UV ISR */ + PMUA_SFRS->PMUIRQ.CLEAR.OV_CLR = 1U; + PMUA_SFRS->PMUIRQ.CLEAR.UV_CLR = 1U; + NVIC_ClearPendingIRQ(UV_OV_IRQn); + NVIC_EnableIRQ(UV_OV_IRQn); + } + } + +} + + +static void UnderVoltageProtection_ISR(void) +{ + TM_PostTask(TASK_ID_SAFETY_MONITOR); +} + +static void OverVoltageProtection_ISR(void) +{ + TM_PostTask(TASK_ID_SAFETY_MONITOR); +} + + +static void safetyInit(void) +{ + HW_PROT_SetUnderVoltage(UV_VOLT_5_1V,UNDER_VOLT_HYS_830mV, VOLT_DEBOUNCE_TIME_10ms, VOLT_DEBOUNCE_TIME_10ms); + HW_PROT_RegisterUnderVoltageIRQ(UnderVoltageProtection_ISR); + + HW_PROT_SetOverVoltage(OV_VOLT_20_0V, OV_VOLT_HYS_1440mV, VOLT_DEBOUNCE_TIME_10ms, VOLT_DEBOUNCE_TIME_10ms); + HW_PROT_RegisterOverVoltageIRQ(OverVoltageProtection_ISR); + +} + + +BatteryState_t SAFM_GetBatteryState(void) +{ + return battState; +} + + +ChipTemperatureState_t SAFM_GetChipTemperatureState(void) +{ + return chipTemperatureState; +} + diff --git a/87400/usr/common/safetyMonitorTask.h b/87400/usr/common/safetyMonitorTask.h new file mode 100644 index 0000000..d5797ac --- /dev/null +++ b/87400/usr/common/safetyMonitorTask.h @@ -0,0 +1,33 @@ +#ifndef SAFETY_MONITOR_TASK_H +#define SAFETY_MONITOR_TASK_H + +#include +#include +#include +#include +#include +#include +#include + + +typedef enum { + BATT_STATE_NORMAL = 0U, + BATT_STATE_LOW, + BATT_STATE_HIGH, + BATT_STATE_RESVD, +}BatteryState_t; + +typedef enum { + CHIP_TEMPERATURE_STATE_NORMAL = 0U, + CHIP_TEMPERATURE_STATE_LOW, + CHIP_TEMPERATURE_STATE_HIGH, +}ChipTemperatureState_t; + + +BatteryState_t SAFM_GetBatteryState(void); +ChipTemperatureState_t SAFM_GetChipTemperatureState(void); + +void SAFM_TaskHandler(void); + + +#endif \ No newline at end of file diff --git a/87400/usr/common/systemInit.c b/87400/usr/common/systemInit.c new file mode 100644 index 0000000..046fc94 --- /dev/null +++ b/87400/usr/common/systemInit.c @@ -0,0 +1,82 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file systemInit.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ + +#include +#include +#include +#include +#include + +#include "PINdef.h" +void gpios_init(void); +void pmu_init(void); + + + +void gpios_init(void) +{ + GPIO_Init(IO_KEY3,GPIO_DIR_INPUT,GPIO_PULL_NONE); + GPIO_Init(IO_KEY4,GPIO_DIR_INPUT,GPIO_PULL_NONE); + GPIO_Init(IO_KEY5,GPIO_DIR_INPUT,GPIO_PULL_NONE); + GPIO_Init(IO_KEY6,GPIO_DIR_INPUT,GPIO_PULL_NONE); + GPIO_Init(IO_KEY7,GPIO_DIR_INPUT,GPIO_PULL_NONE); + GPIO_Init(IO_KEY8,GPIO_DIR_INPUT,GPIO_PULL_NONE); + + GPIO_Init(IO_LED1,GPIO_DIR_OUTPUT,GPIO_PULL_NONE); + GPIO_Init(IO_LED2,GPIO_DIR_OUTPUT,GPIO_PULL_NONE); + GPIO_Init(IO_LED3,GPIO_DIR_OUTPUT,GPIO_PULL_NONE); + GPIO_Init(IO_LED4,GPIO_DIR_OUTPUT,GPIO_PULL_NONE); + GPIO_Init(IO_LED5,GPIO_DIR_OUTPUT,GPIO_PULL_NONE); + GPIO_Init(IO_LED6,GPIO_DIR_OUTPUT,GPIO_PULL_NONE); +} + +void pmu_init(void) +{ + SYSCTRLA_SFRS->PMU_ACCESS_KEY.PMU_ACCESS_KEY = 0x0A; + /* Init set BOR voltage level for cpu low voltage safety*/ + PMU_BORInit((Bor1V5Thres_t)HWCFG_Get1P5VBOR_Code(), (Bor3V3Thres_t)HWCFG_Get3P3VBOR_Code()); + /* Disable wake up timer */ + PMU_WakeTimerInit(WAKEUP_TIMEER_DISABLE, WAKEUP_TIMEER_INTERVAL_32768ms); +} + + +void SYS_Init(void) +{ + /* Enable trim revise access enable*/ + HWCFG_TrimAccessUnlock(); + CRGA_SFRS->MODULERSTREQ = 0xFFU; + /* Init system clock */ + Clock_SystemMainClockInit(SYS_MAIN_CLOCK_DIV); + pmu_init(); + /* Init global timer engine for driving soft timer */ + SysTick_Init(SOFT_TIMER_INTERVAL *1000U * MAIN_CPU_CLOCK, SoftTimer_ExpireCallback); +#if WATCH_DOG_EN == 1U + WDTA_Enable(WDTA_INTERVAL_18432MS); /* 8s */ +#endif + /* Init gpios settings */ + gpios_init(); + /*HWCFG_TrimAccessLockUntilReset();*/ + + /* tasks init must be called before use. */ + TM_PostTask(TASK_ID_SOFT_TIMER); + TM_PostTask(TASK_ID_SAFETY_MONITOR); + TM_PostTask(TASK_ID_MOTOR); + TM_PostTask(TASK_ID_LINS); + TM_PostTask(TASK_ID_PDS); + TM_PostTask(TASK_ID_ADC_MEASURE); + TM_PostTask(TASK_ID_APPL); +} + + + diff --git a/87400/usr/common/systemInit.h b/87400/usr/common/systemInit.h new file mode 100644 index 0000000..46e4911 --- /dev/null +++ b/87400/usr/common/systemInit.h @@ -0,0 +1,35 @@ +#ifndef _SYSTEM_INIT_H + +#include +#include "systick_device.h" +#include +#include "flash_device.h" + +#include +#include +#include +#include + +void SYS_Init(void); + + + + + + + + + + + + + + + + + + + + + +#endif \ No newline at end of file diff --git a/87400/usr/common/taskManager.c b/87400/usr/common/taskManager.c new file mode 100644 index 0000000..4bb609d --- /dev/null +++ b/87400/usr/common/taskManager.c @@ -0,0 +1,115 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file taskManager.c + * @Author: Jack.Pan + * @E-mail:jack.pan@indiemicro.com + * @Date: 2020/09/10 + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static volatile uint16_t taskFlags = 0U; +static uint16_t tasksMask = 0xFFFFU; +void IdleTask(void); + +typedef void (*taskHandler_t)(void); + +static taskHandler_t taskHandlers[] = { + [TASK_ID_SOFT_TIMER] = SoftTimer_TaskHandler, /* Global Timer task */ + [TASK_ID_MOTOR] = MotorCtrl_TaskHandler, /* Motor Control task */ + [TASK_ID_LIN_STACK] = LinStack_TaskHandler, /* LIN stack task */ + [TASK_ID_LINS] = LINS_TaskHandler, /* LIN Slave task */ + [TASK_ID_PDS] = PDS_TaskHandler, /*!< Task ID of persistance data storage*/ + [TASK_ID_ADC_MEASURE] = MES_TaskHandler, /* ADC measurement, chip temperature, Led PN volt, Battery Volt etc. */ + [TASK_ID_SAFETY_MONITOR] = SAFM_TaskHandler, /* safe monitor task */ + [TASK_ID_APPL] = APPL_TaskHandler, /* design for debug and demo */ +}; + +void IdleTask(void) +{ + + +} + +void TM_RunTasks(void) +{ + uint8_t taskId; + for (taskId = 0U; taskId < (uint8_t)(sizeof(taskHandlers) / sizeof(taskHandlers[0])); taskId++){ + if ( (((uint16_t)1UL << taskId) & (taskFlags & tasksMask)) != 0U ){ + __atomic_enter() + taskFlags &= ~((uint16_t)1UL << taskId); + __atomic_exit() + if (taskHandlers[taskId] != NULL){ + taskHandlers[taskId](); + } + break; + } + } + +#if WATCH_DOG_EN == 1U + WDTA_Clear(); /* Feeding Watch dog */ +#endif + + if (taskFlags == 0U){ + IdleTask(); + } +} + +/* + * Disables specified task. + * @param [in] taskId - task to be disabled. + * @return none + */ +void TM_DisableTask(TM_TaskId_t taskId) +{ + tasksMask &= ~(uint16_t)(1UL << taskId); +} + +/* + * brief Enables specified task. + * @param [in] taskId - task to be enabled. + * @return none + */ +void TM_EnableTask(TM_TaskId_t taskId) +{ + tasksMask |= (uint16_t)(1UL << taskId); +} + +/* + * brief runs specified task. + * @param [in] taskId - task to be run. + * @return none + */ +void TM_PostTask(TM_TaskId_t taskId) +{ + __atomic_enter() + taskFlags |= (uint16_t)(1UL << taskId); + __atomic_exit() +} + +uint8_t TM_TaskIsPending(TM_TaskId_t taskId) +{ + uint16_t flags = taskFlags; + uint16_t tasks = (uint16_t)1U << taskId; + if ( (tasks & flags)!= 0U ){ + return 1U; + }else{ + return 0U; + } +} \ No newline at end of file diff --git a/87400/usr/common/taskManager.h b/87400/usr/common/taskManager.h new file mode 100644 index 0000000..5bc3f28 --- /dev/null +++ b/87400/usr/common/taskManager.h @@ -0,0 +1,74 @@ +#ifndef TASK_MANAGER_H__ +#define TASK_MANAGER_H__ + +#include +#include +#include +#include + + + +/*! The list of task IDs. The IDs are sorted according to descending +priority. For each task ID there is the corresponding task handler function. */ +typedef enum +{ + TASK_ID_SOFT_TIMER = 0U, /*!< Task ID of Global timer*/ + TASK_ID_MOTOR, /*!< Task ID of Motor Control Task*/ + TASK_ID_LIN_STACK, /*!< Task ID of LIN stack*/ + TASK_ID_LINS, /*!< Task ID of LIN slave*/ + TASK_ID_PDS, /*!< Task ID of persistance data storage*/ + TASK_ID_ADC_MEASURE, /*!< Task ID of ADC measurement*/ + TASK_ID_SAFETY_MONITOR, /*!< Task ID of Safety protection*/ + TASK_ID_APPL, /*!< Task ID of APPlication purpose for debug and demo*/ +} TM_TaskId_t; + +typedef enum{ + TASK_STATE_INIT = 0U, + TASK_STATE_ACTIVE, + TASK_STATE_PROCESSING, + TASK_STATE_IDLE, +}TaskState_t; + + +/* + * brief runs specified task. + * @param [in] taskId - task to be run. + * @return none + */ +void TM_PostTask(TM_TaskId_t taskId); + +/* + * brief Enables specified task. + * @param [in] taskId - task to be enabled. + * @return none + */ +void TM_EnableTask(TM_TaskId_t taskId); + +/* + * Disables specified task. + * @param [in] taskId - task to be disabled. + * @return none + */ +void TM_DisableTask(TM_TaskId_t taskId); + +/* + * get the state of specified task. + * @param [in] taskId - task to be disabled. + * @return 0: task is not pending, other: task is pending to be handle + */ +uint8_t TM_TaskIsPending(TM_TaskId_t taskId); + +/* + * brief task manager. + * @return none + */ +void TM_RunTasks(void); + + + + + + + + +#endif \ No newline at end of file diff --git a/87400/usr/common/validation.c b/87400/usr/common/validation.c new file mode 100644 index 0000000..ff087f6 --- /dev/null +++ b/87400/usr/common/validation.c @@ -0,0 +1,99 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 + +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + + +void validation_main(void) +{ +// HWCFG_VERIFY_REGLoadVerify(); +// HWCFG_VERIFY_AddressVerify(); +// HWCFG_VERIFY_ContentVerify(); +// HWCFG_VERIFY_CRCVerify(); +// HWCFG_VERIFY_ContentRangeVerify(); + +// HDF_VERIFY_CrgaAddressVerify(); +// HDF_VERIFY_GtimerAddressVerify(); +// HDF_VERIFY_AUXPWMAddressVerify(); +// HDF_VERIFY_LINSAddressVerify(); +// HDF_VERIFY_SARAddressVerify(); +// HDF_VERIFY_GPIOAddressVerify(); +// HDF_VERIFY_IOCTRLAddressVerify(); + + + Clock_SystemMainClockInit(CLOCK_DIV_1); + + //delay(100); + //delay(100); + + + SYSCTRLA_SFRS->DEBUG_ACCESS_KEY.DEBUG_ACCESS_KEY = 0x05; + while(SYSCTRLA_SFRS->DEBUG_ACCESS_ENABLED == 0); + + SYSCTRLA_SFRS->TRIM_ACCESS_KEY.TRIM_ACCESS_KEY = 0x0E; + while(SYSCTRLA_SFRS->TRIM_ACCESS_ENABLED == 0); + + + SYSCTRLA_SFRS->PMU_ACCESS_KEY.PMU_ACCESS_KEY = 0x0A; + while(SYSCTRLA_SFRS->PMU_ACCESS_ENABLED == 0); + + + + +// validate_lins(); +// validate_wdta(); +// validate_uart(); +// validate_tempsensor(); +// validate_system(); +// validate_pwmaux(); +// validate_pwm(); +// validate_mux(); +// validate_flash(); + validate_clock(); +// validate_adc(); +// validate_pmu(); +// validate_spi(); +// validate_gpio(); + + + while(1) + { + + } + +} + + + + +#endif diff --git a/87400/usr/common/validation.h b/87400/usr/common/validation.h new file mode 100644 index 0000000..f0efc66 --- /dev/null +++ b/87400/usr/common/validation.h @@ -0,0 +1,8 @@ +#ifndef VALIDATION_H_ +#define VALIDATION_H_ + +void validation_main(void); + + + +#endif \ No newline at end of file diff --git a/87400/usr/fcode/PINdef.h b/87400/usr/fcode/PINdef.h new file mode 100644 index 0000000..e0850f4 --- /dev/null +++ b/87400/usr/fcode/PINdef.h @@ -0,0 +1,45 @@ +#ifndef __PINDEF_H__ +#define __PINDEF_H__ +#include "gpio_device.h" + + +#define SIGID_KEY1 1 +#define SIGID_KEY2 2 +#define SIGID_KEY3 3 +#define SIGID_KEY4 4 +#define SIGID_KEY5 5 +#define SIGID_KEY6 6 +#define SIGID_KEY7 7 +#define SIGID_KEY8 8 +#define SIGID_KEY9 9 +#define SIGID_KEY10 10 +#define SIGID_KEY11 11 +#define SIGID_KEY12 12 +#define SIGID_KEY13 13 +#define KEY_NUM 13 + + + + +#define ADCH_KEYAD1 1 +#define ADCH_KEYAD2 0 + +#define IO_KEY3 GROUP_GPIOB,GPIO_PORT_0 +#define IO_KEY4 GROUP_GPIOB,GPIO_PORT_1 +#define IO_KEY5 GROUP_GPIOB,GPIO_PORT_5 +#define IO_KEY6 GROUP_GPIOB,GPIO_PORT_4 +#define IO_KEY7 GROUP_GPIOB,GPIO_PORT_2 +#define IO_KEY8 GROUP_GPIOB,GPIO_PORT_3 + +#define IO_LED1 GROUP_GPIOC,GPIO_PORT_4 +#define IO_LED2 GROUP_GPIOC,GPIO_PORT_3 +#define IO_LED3 GROUP_GPIOA,GPIO_PORT_6 +#define IO_LED4 GROUP_GPIOA,GPIO_PORT_5 +#define IO_LED5 GROUP_GPIOA,GPIO_PORT_4 +#define IO_LED6 GROUP_GPIOA,GPIO_PORT_3 + + + + +#endif + diff --git a/87400/usr/fcode/hwCtrl.c b/87400/usr/fcode/hwCtrl.c new file mode 100644 index 0000000..cbee611 --- /dev/null +++ b/87400/usr/fcode/hwCtrl.c @@ -0,0 +1,152 @@ + +#include "hwCtrl.h" +#include "PINdef.h" + + +#define IO_INPUT 0x01 +#define IO_OUTPUT 0x00 + +void IO_Init(void) +{ + +} + +void Output_Ctrl(uint8_t state) +{ + +} + +#define KEY_AD_TH 60 +uint8_t isKeyMatchAd(uint16_t val,uint16_t match) +{ + if ( val >= (match - KEY_AD_TH) && val <= (match + KEY_AD_TH)) + { + return 1; + } + return 0; +} + +#define KEY_AD_V0 60 +#define KEY_AD_V1 492 +#define KEY_AD_V2 882 +#define KEY_AD_V3 1277 +#define KEY_AD_V4 1733 + +#define KEY_AD_V5 992 +#define KEY_AD_V6 1350 + +uint16_t g_AdVal[3]; + +uint8_t GetKeyState(uint8_t keyno) +{ + switch (keyno) + { + case SIGID_KEY1: + return isKeyMatchAd(g_AdVal[ADCH_KEYAD1],KEY_AD_V5); + case SIGID_KEY2: + return isKeyMatchAd(g_AdVal[ADCH_KEYAD1],KEY_AD_V6); + case SIGID_KEY3: + return GPIO_Read(IO_KEY3)?1:0; + case SIGID_KEY4: + return GPIO_Read(IO_KEY4)?1:0; + case SIGID_KEY5: + return GPIO_Read(IO_KEY5)?1:0; + case SIGID_KEY6: + return GPIO_Read(IO_KEY6)?1:0; + case SIGID_KEY7: + return GPIO_Read(IO_KEY7)?1:0; + case SIGID_KEY8: + return GPIO_Read(IO_KEY8)?1:0; + case SIGID_KEY9: + return isKeyMatchAd(g_AdVal[ADCH_KEYAD2],KEY_AD_V0); + case SIGID_KEY10: + return isKeyMatchAd(g_AdVal[ADCH_KEYAD2],KEY_AD_V1); + case SIGID_KEY13: + return isKeyMatchAd(g_AdVal[ADCH_KEYAD2],KEY_AD_V2); + case SIGID_KEY11: + return isKeyMatchAd(g_AdVal[ADCH_KEYAD2],KEY_AD_V3); + case SIGID_KEY12: + return isKeyMatchAd(g_AdVal[ADCH_KEYAD2],KEY_AD_V4); + default: + return 0; + } +} + + +#define LED_OFF GPIO_LOW +#define LED_ON GPIO_HIGH + +#if BOARDCFG == LEFT_BOARD +#define LEDF1 IO_LED4 +#define LEDF2 IO_LED5 +#define LEDF3 IO_LED6 + +#define LEDH1 IO_LED1 +#define LEDH2 IO_LED2 +#define LEDH3 IO_LED3 +#else +#define LEDF1 IO_LED1 +#define LEDF2 IO_LED2 +#define LEDF3 IO_LED3 + +#define LEDH1 IO_LED4 +#define LEDH2 IO_LED5 +#define LEDH3 IO_LED6 +#endif + +void FanLED_Ctrl(uint8_t state) +{ + switch (state) + { + case 0: + GPIO_Set(LEDF1,LED_OFF); + GPIO_Set(LEDF2,LED_OFF); + GPIO_Set(LEDF3,LED_OFF); + break; + case 1: + GPIO_Set(LEDF1,LED_ON); + GPIO_Set(LEDF2,LED_OFF); + GPIO_Set(LEDF3,LED_OFF); + break; + case 2: + GPIO_Set(LEDF1,LED_ON); + GPIO_Set(LEDF2,LED_ON); + GPIO_Set(LEDF3,LED_OFF); + break; + case 3: + GPIO_Set(LEDF1,LED_ON); + GPIO_Set(LEDF2,LED_ON); + GPIO_Set(LEDF3,LED_ON); + break; + default: + break; + } +} +void HeatLED_Ctrl(uint8_t state) +{ + switch (state) + { + case 0: + GPIO_Set(LEDH1,LED_OFF); + GPIO_Set(LEDH2,LED_OFF); + GPIO_Set(LEDH3,LED_OFF); + break; + case 1: + GPIO_Set(LEDH1,LED_ON); + GPIO_Set(LEDH2,LED_OFF); + GPIO_Set(LEDH3,LED_OFF); + break; + case 2: + GPIO_Set(LEDH1,LED_ON); + GPIO_Set(LEDH2,LED_ON); + GPIO_Set(LEDH3,LED_OFF); + break; + case 3: + GPIO_Set(LEDH1,LED_ON); + GPIO_Set(LEDH2,LED_ON); + GPIO_Set(LEDH3,LED_ON); + break; + default: + break; + } +} diff --git a/87400/usr/fcode/hwCtrl.h b/87400/usr/fcode/hwCtrl.h new file mode 100644 index 0000000..66c9ed5 --- /dev/null +++ b/87400/usr/fcode/hwCtrl.h @@ -0,0 +1,16 @@ + +#ifndef __HWCTRL_H__ +#define __HWCTRL_H__ +#include "gpio_device.h" + +#define OUTPUT_ON 1 +#define OUTPUT_OFF 0 + + +uint8_t GetKeyState(uint8_t keyno); +void Output_Ctrl(uint8_t state); +void IO_Init(void); +void FanLED_Ctrl(uint8_t state); +void HeatLED_Ctrl(uint8_t state); + +#endif diff --git a/87400/usr/fcode/prjconfig.h b/87400/usr/fcode/prjconfig.h new file mode 100644 index 0000000..a98e339 --- /dev/null +++ b/87400/usr/fcode/prjconfig.h @@ -0,0 +1,10 @@ +#ifndef __PRJCONFIG_H__ +#define __PRJCONFIG_H__ + +#define LEFT_BOARD 1 +#define RIGHT_BOARD 2 + +#define BOARDCFG LEFT_BOARD + +#endif + diff --git a/87400/usr/library/LinStackTask_metaLite.a b/87400/usr/library/LinStackTask_metaLite.a new file mode 100644 index 0000000000000000000000000000000000000000..4b78bde59c234a74393c001a99070184994139ef GIT binary patch literal 112620 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 aupQJc+{Zg8{~GLOAY*?xxm;j>@qYmq$Ox$b literal 0 HcmV?d00001 diff --git a/87400/usr/library/linStackTask.h b/87400/usr/library/linStackTask.h new file mode 100644 index 0000000..ae9d080 --- /dev/null +++ b/87400/usr/library/linStackTask.h @@ -0,0 +1,533 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file lin_stack.h + */ + +#ifndef LIN_STACK_H__ +#define LIN_STACK_H__ + +#include +#include +#include + +/** + * @brief The definitions and enumerations used in the API function in LIN stack. + */ +typedef uint8_t l_bool; +typedef uint8_t l_ioctl_op; +typedef uint8_t l_irqmask; +typedef uint8_t l_u8; +typedef uint16_t l_u16; +typedef uint32_t l_u32; + +typedef uint8_t l_signal_handle; +typedef uint8_t l_flag_handle; +typedef uint8_t l_ifc_handle; +typedef uint8_t l_schedule_handle; + +typedef enum{ + LIN_PCI_SF = 0U, + LIN_PCI_FF, + LIN_PCI_CF +}PCI_Types_t; + +typedef enum{ + PDU_TYPE_SINGLE_PDU = 0U, + PDU_TYPE_MULTI_PDU, +}PDU_Types_t; + +typedef enum{ + TX_IDLE = 0U, + TX_SENDING, + TX_FINISHED, + TX_FAILED +}TxStatus_t; + +typedef enum{ + LIN_PROTOCOL_LIN2_2A = 0U, + LIN_PROTOCOL_SAE_J2602, +}LinProtocolType_t; + +typedef enum{ + J2602_ERROR_NO_DETECTED_FAULT = 0, + J2602_ERROR_RESET, + J2602_ERROR_RESERVED0, + J2602_ERROR_RESERVED1, + J2602_ERROR_DATA_ERROR, + J2602_ERROR_CHECKSUM_ERROR, + J2602_ERROR_BYTE_FIELD_FRAMING_ERROR, + J2602_ERROR_ID_PARITY_ERROR, +}J2602ErrCode_t; + + +#define SF_MAX_DATA_LENGTH (5U) + +#define LIN_NAD_FUNCTION (0x7EU) +#define LIN_NAD_WILDCARD (0x7FU) +#define LIN_SUPPLIER_ID_WILDCARD (0x7FFFU) +#define LIN_FUNCTION_ID_WILDCARD (0xFFFFU) +#define LIN_SERIALNO_WILDCARD (0x01234567U) + +/** + * @brief The enumerations of frame identifiers. + */ +#define LIN_FRAME_ID_J2602_DNN_BROADCAST_START (0x38U) +#define LIN_FRAME_ID_J2602_DNN_BROADCAST_END (0x3BU) + + +#define LIN_FRAME_ID_J2602_DNN_BROADCAST_38 (0x38U) +#define LIN_FRAME_ID_J2602_DNN_BROADCAST_39 (0x39U) +#define LIN_FRAME_ID_J2602_DNN_BROADCAST_3A (0x3AU) +#define LIN_FRAME_ID_J2602_DNN_BROADCAST_3B (0x3BU) + + +#define LIN_FRAME_ID_DIAG_MASTER_REQ (0x3CU) +#define LIN_FRAME_ID_DIAG_SLAVER_RSP (0x3DU) +#define LIN_FRAME_ID_DIAG_MASTER_REQ_3E (0x3EU) + +#define LIN_FRAME_ID_FUNCTIONAL (0x7EU) +#define LIN_FRAME_ID_UNASSIGN (0x00U) +#define LIN_FRAME_ID_DONOTCARE (0xFFU) + +/** + * @brief The enumerations of service IDs. + */ +#define LIN_SID_ASSIGN_NAD (0xB0U) +#define LIN_SID_ASSIGN_FRAME_ID (0xB1U) +#define LIN_SID_READ_BY_ID (0xB2U) +#define LIN_SID_CONDITIONAL_CHANGE_NAD (0xB3U) +#define LIN_SID_DATA_DUMP (0xB4U) +#define LIN_SID_RESERVED (0xB5U) +#define LIN_SID_SAVE_CONFIGURATION (0xB6U) +#define LIN_SID_ASSIGN_FRAME_ID_RANGE (0xB7U) + +#define LIN_SID_SNPD LIN_SID_RESERVED +#define LIN_SID_J2602_HARDWARE_RST LIN_SID_RESERVED + +typedef union{ + struct{ + uint8_t appInfo0 :1; + uint8_t appInfo1 :1; + uint8_t appInfo2 :1; + uint8_t appInfo3 :1; + uint8_t appInfo4 :1; + uint8_t err :3; + }; + uint8_t payload; +}J2602StatusByte_t; + +typedef union{ + struct{ + uint8_t nad; + union{ + uint8_t pci; + struct{ + uint8_t pci_extInfo :4; + uint8_t pci_type :4; + }; + }; + union{ + uint8_t sid; + uint8_t length; + uint8_t rsid; + struct{ + uint8_t length_ff; + uint8_t sid_rsid_ff; + }; + uint8_t payload[6]; + }; + }; + uint8_t data[8]; + uint64_t data64; +}NodeStruct_t; + +typedef struct{ + PDU_Types_t type; /* pdu type single or multi pdu */ + uint8_t sid; /* sid */ + uint16_t packLength; /* the complete valid data buffer length except the length of sid */ + uint8_t *payload; /* data in received buffer */ +}DiagSubscribeInfo_t; + + +typedef struct{ + PDU_Types_t type; /* pdu type single or multi pdu */ + uint8_t sid; /* sid */ + uint16_t packLength; /* the complete valid data buffer length except the length of SID */ + uint8_t *payload; /* data buffer to be sent except SID*/ +}DiagPublishInfo_t; + + +typedef struct{ + uint16_t buffLength; /* the complete valid data buffer length except the length of SID */ + uint8_t *buff; /* data buffer to be sent except SID*/ +}DiagMultiPduInfo_t; + + +typedef enum{ + SLEEP_REQ_TYPE_NONE = 0U, /* none of sleep request */ + SLEEP_REQ_TYPE_MASTER_REQ, /* sleep request with filled with 0xFF in buff[1-7] */ + SLEEP_REQ_TYPE_MASTER_REQ_INFORMAL, /* sleep request without filled with 0xFF in buff[1-7] */ + SLEEP_REQ_TYPE_BUS_IDLE_TIMEROUT, +}SleepRequestType_t; + +typedef enum{ + BUS_WAKEUP_REQ_RESULT_MASTER_ACTIVE = 0, /* wakeup bus successfully, master send frame ID after wake up */ + BUS_WAKEUP_REQ_RESULT_REQ_TIMEOUT, /* wakeup bus failed after 3 tries */ +}BusWakeUpRequestResult_t; + +typedef void (*ls_UnconditionalReqCallback_t)(LIN_Device_Frame_t const *frame); +typedef void (*ls_UnconditionalRspCallback_t)(LIN_Device_Frame_t *const frame); +typedef void (*ls_PublisherTxFinishedCallback_t)(uint8_t fid, uint8_t j2602CfgRsp); +typedef void (*ls_DiagReqCallback_t)(const DiagSubscribeInfo_t * const frameInfo); +typedef void (*ls_DiagFunctionalNADCallback_t)(const NodeStruct_t * const frame); +typedef void (*ls_DiagSleepReqCallback_t)(SleepRequestType_t type); +typedef void (*ls_BusWakeUpRequestCallback_t)(BusWakeUpRequestResult_t result); + +typedef void (*ls_DiagReqLogCallback_t)(const LIN_Device_Frame_t * const frame); +typedef void (*ls_FrameIdLogCallback_t)(uint8_t frameId); + +typedef void (*ls_SAEJ2602CfgReqCallback_t)(uint8_t fid,uint8_t const *payload, uint8_t length); +typedef void (*ls_SAEJ2602DNNBroadcastReqCallback_t)(uint8_t fid,uint8_t const *payload, uint8_t length); + +typedef struct{ + ls_UnconditionalReqCallback_t unconditionalSubscribedCallback; /* received data from master */ + ls_UnconditionalRspCallback_t unconditionalPublishedCallback; /* send data to master */ + ls_PublisherTxFinishedCallback_t publisherTxFinishedCallback; /* send data to master finished */ + ls_DiagReqCallback_t diagnosticSubscribedCallback; /* Diagnostic and MultiPDU received data from master */ + ls_DiagFunctionalNADCallback_t diagFunctionalNADCallback; /* special functional NAD (0x7E) handler*/ + ls_DiagSleepReqCallback_t diagnosticSleepRequestCallback; /* Diagnostic sleep request from master */ + ls_BusWakeUpRequestCallback_t busWakeUpRequestCallback; /* got the bus state after slave sending wake up signal.*/ + ls_SAEJ2602CfgReqCallback_t SAEJ2602CfgReqCallback; /* refers to SAEJ2602-1 5.7.2.3 Configuration Messages */ + ls_SAEJ2602DNNBroadcastReqCallback_t SAEJ2602DNNBroadcastReqCallback; /* DNN Based Broadcast Messages */ +}ls_LinsFramesCallback_t; + +typedef struct{ + l_u8 device; /* 1: means realplum(IND83205) , 2: rugby(IND83204) 3: realplumPro(IND82209),4: rugbyPro(IND83211),5: realplumLite(IND83212)*/ + l_u8 protocol; /* 0:with LIN stack V2.2A ,1: with LIN stack SAE_J2602, 2: with LIN stack V2.2A_SAE_J2602 */ + l_u16 version; /* 0x0101 means V1.01 */ +}lin_stack_version_t; + +/** +* @brief A structure to represent LIN status information. +*/ +typedef union { + struct{ + l_u8 error_in_resp :1; + l_u8 success_in_transfer :1; + l_u8 overrun :1; + l_u8 goto_sleep :1; + l_u8 bus_activity :1; + l_u8 event_trig_frame_collision :1; + l_u8 save_config :1; + l_u8 parity_error :1; /* FID parity error bit */ + l_u8 pid; + }; + l_u16 payload; +}lin_status_t; + + +typedef enum{ + LD_SET_OK = 0, + LD_LENGTH_NOT_CORRECT, + LD_DATA_ERROR +}ld_set_status_t; + +typedef enum{ + LD_READ_OK = 0, + LD_LENGTH_TOO_SHORT, +}ld_read_status_t; + +/* + * Lin stack main task which was called by task manager, please don't use for other purpose!!!: + * @param [in] none + * @return none + */ +void LinStack_TaskHandler(void); + +/* + * Get current Lin stack version: + * @param [in] none + * @return lin_stack_version: majorVer: main version; subVer: branch version + */ +lin_stack_version_t ls_get_lin_version(void); + +/* + * Lin stack initialization: + * @param [in] none + * @return 0 + */ +l_bool l_sys_init(void); + +/* + * Set Lin transport layer timeout parameters: + * @param [in] n_as: N_As, refer to LIN spec 2.2A + * @param [in] n_cr: N_Cr, refer to LIN spec 2.2A + * @return 0 + */ +l_u8 ls_set_tp_timeout(uint16_t n_as, uint16_t n_cr); + +/* + * Set Lin lin tx bit monitor: + * @param [in] enable: TRUE: enable bit monitor; FALSE: disable bit monitor + * @return 0 + */ +l_u8 ls_set_tx_bit_monitor(l_u8 enable); + +/* + * Disable LIN auto sleep when LIN timeout: + * @param [in] TRUE: disable auto sleep; FALSE: enable auto sleep + * @return 0 + */ +l_u8 ls_disable_lin_auto_sleep(l_u8 disable); + +/* + * Set Lin phy 1st rx glitch signal filter timing : + * @param [in] risingTime: level 0 -> level1 delay time; range 0-127 unit: 62.5us + * @param [in] fallingTime:level 0 -> level 1 delay time, range 0-127 unit: 62.5us + * @return 0, successfully , others: failed + */ +l_u8 ls_set_lins_rx_glitch_filter_1st(l_u8 risingTime,l_u8 fallingTime); + +/* + * Set Lin phy 2nd rx glitch signal filter timing : + * @param [in] risingTime: level 0 -> level1 delay time; range 0-127 unit: 62.5us + * @param [in] fallingTime:level 0 -> level 1 delay time, range 0-127 unit: 62.5us + * @return 0, successfully , others: failed + */ +l_u8 ls_set_lins_rx_glitch_filter_2nd(l_u8 risingTime,l_u8 fallingTime); + +/* + * Set Lin phy 3rd rx glitch signal filter timing : + * @param [in] risingTime: level 0 -> level1 delay time; range 0-127 unit: 62.5us + * @param [in] fallingTime:level 0 -> level 1 delay time, range 0-127 unit: 62.5us + * @return 0, successfully , others: failed + */ +l_u8 ls_set_lins_rx_glitch_filter_3rd(l_u8 risingTime,l_u8 fallingTime); + + +/* + * Reqister supported unconditional frame table + * @param [in] protocol: LIN protocol type 0: LIN_PROTOCOL_LIN2_2A, 1: LIN_PROTOCOL_SAE_J2602. + * @param [in] frameTable: frame table location + * @param [in] tableSize: frame table size + * @param [in] diagPDUSubscriberBuffLength: diagnostic multi pdu max supported data length, this value should be within 7-4095 + * @param [in] pFunCallback: callback fucntions for diagnostic frame and unconditional frames. + * @return none + */ +void ls_register_services(LinProtocolType_t protocol,LIN_Device_Frame_t *frameTable, l_u8 tableSize, DiagMultiPduInfo_t multiPduInfo,const ls_LinsFramesCallback_t *pFunCallback); + +/* + * Diagnostic frame response function which is used to send back data to LIN master. + * @param [in] rsp: refer to description of structure DiagPublishInfo_t definition. + * @return none + */ +void ls_handle_diagnostic_response(DiagPublishInfo_t *rsp); + +/* + * SAEJ2602 CFG 0x3C or 0x3E frame response function which is used to send back data to LIN master. + * @param [in] rsp: refer to SAEJ2602-1 5.7.2.4 Response Message to Options 2 and 3 in 5.7.2.3. + * @param [in] statusByte:J2602-1 Status Byte(defined in 5.8.6) + * @param [in] payload: databuff 0-6 the paylad length should be 7 by default. + * @return none + */ +void ls_handle_SAEJ2602Cfg_response(l_u8 statusByte, l_u8 *payload); + +/* + *!!!!!!!!!!!!!!!!!!!Note that obsolete not recommended for future use!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * frame response send status. + * @return TxStatus_t. + */ +TxStatus_t ls_tx_status(void); + +/* + * Set device initial NAD to LIN stack for assigning NAD command. + * @param [in] nad: initial NAD of device. + * @return none + */ +void ls_set_initialNad(l_u8 nad); +/* + * Set device NAD to LIN stack. + * @param [in] nad: current NAD of device. + * @return none + */ +void ls_set_nad(l_u8 nad); + +/* + * Red NAD of LIN stack. + * @param [in] none. + * @return current NAD of LIN stack. + */ +l_u8 ls_read_nad(void); + +/* + * Red NAD of current diagnostic frame sent from LIN master, there are only probably 2 values: current NAD or 0x7FU(NAD wildcard). + * @param [in] none. + * @return NAD of current diagnostic frame. + */ +l_u8 ls_read_nad_from_master(void); + + +/* + * any invalid diag frame would be handled ignore the frame is or is not for current node when set to 1U. + * @param [in] value 0U: ignore the diag frame error when it is not for current node, 1U: any invalid diag frame would be handled ignore the frame is or is not for current node when set to 1U. + * @return TRUE. + */ +l_u8 ls_diag_error_in_all_diag_frames(uint8_t value); + +/* + * Save current LIN Stack parameters such as NAD, PIDs etc. refer to pdsTask for more information. + * @param [in] none. + * @return 0. + */ +l_u8 ls_save_configuration(void); + +/* + * clear save_configuration flag. + * @param [in] none. + * @return 0. + */ +l_u8 ls_clr_save_configuration_flag(void); + +/* + * !!!!!!!!!!!!!!!!!!!Note that obsolete not recommended for future use!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * replace with function ls_ifc_read_status() and ls_ifc_read_status() + * Read current error flag and system information, refer to struture lin_status_t for more information. + * @param [in] none. + * @return: + l_u8 error_in_resp :1; + l_u8 success_in_transfer :1; + l_u8 overrun :1; + l_u8 goto_sleep :1; + l_u8 bus_activity :1; + l_u8 event_trig_frame_collision :1; + l_u8 save_config :1; + l_u8 parity_error :1; + l_u8 pid; + */ +l_u16 ls_read_sys_status(void); + +/* + * !!!!!!!!!!!!!!!!!!!Note that obsolete not recommended for future use!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * replace with function ls_ifc_read_status() and ls_ifc_read_status() + * Read current error flag and system information, simulate with ls_read_sys_status + * @return: + l_u8 error_in_resp :1; + l_u8 success_in_transfer :1; + l_u8 overrun :1; + l_u8 goto_sleep :1; + l_u8 bus_activity :1; + l_u8 event_trig_frame_collision :1; + l_u8 save_config :1; + l_u8 parity_error :1; + l_u8 pid; +*/ +lin_status_t ls_read_sys_status_ext(void); + +/* + * Read current error flag and system information, simulate with ls_read_sys_status not don't clear the status + * @return: + l_u8 error_in_resp :1; + l_u8 success_in_transfer :1; + l_u8 overrun :1; + l_u8 goto_sleep :1; + l_u8 bus_activity :1; + l_u8 event_trig_frame_collision :1; + l_u8 save_config :1; + l_u8 parity_error :1; + l_u8 pid; +*/ +lin_status_t ls_ifc_read_status(void); + +/* + * reset lin error status. + * @param [in] errCode. + * @return: 0U; + */ +l_u8 ls_ifc_clear_error_status(void); + +/* + * !!!!!!!!!!!!!!!!!!!Note that obsolete not recommended for future use!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * replace with function : ls_read_error_code_log() and ls_clr_error_code_log() + * Read current lin stack communication error reasons, this is only for internal use. + * @param [in] none. + * @return: ((1U << ERROR_BITERR_POS) | (1U << ERROR_CHK_POS) | (1U << ERROR_BITMON_POS) | (1U << ERROR_FRAMEERR_POS)) refer to LINS->ERROR register + */ +l_u8 ls_read_error_code(void); + +/* + * Read current lin stack communication error reasons, this is only for internal use and don't clear the error log + * @param [in] none. + * @return: ((1U << ERROR_BITERR_POS) | (1U << ERROR_CHK_POS) | (1 << ERROR_PARITY_POS) | (1U << ERROR_BITMON_POS) | (1U << ERROR_FRAMEERR_POS))refer to LINS->ERROR register + */ +l_u8 ls_read_error_code_log(void); + +/* + * clear the erroe code log. + * @param [in] none. + * @return: 0; + */ +l_u8 ls_clr_error_code_log(void); + +/* + * Read SAEJ2602 communication error state. + * @param [in] none. + * @return: J2602ErrCode_t + */ +J2602ErrCode_t ls_read_J2602_error_code(void); + +/* + * reset SAEJ2602 communication error state when response successfully. + * @param [in] errCode. + * @return: none + */ +void ls_reset_J2602_error_code(J2602ErrCode_t errCode); + +/* + * Notice lin stack it's a hardware reset operation. + * @param [in] 0: hardware reset is false, 1: hardware reset is true. + * @return: none + */ +void ls_set_J2602_hardware_reset(uint8_t hardwareReset); + + +/* + * read go_to_sleep flag + * @param [in] none. + * @return: state: 1: got go_to_sleep command, 0: not got go_to_sleep command + */ +l_u8 ls_read_go_to_sleep_flag(void); +/* + * Clear go_to_sleep flag + * @param [in] none. + * @return: 0U + */ +l_u8 ls_clr_go_to_sleep_flag(void); + +/* + * Clear overrun flag + * @param [in] none. + * @return: 0U + */ +l_u8 ls_clr_overrun_flag(void); + +/* + * Read current LIN BUS Status. + * @param [in] none. + * @return: 1: active, 0: IDLE;, refer to "bus_activity" in function:ls_ifc_read_status(); + */ +l_u32 ls_linbus_activity(void); + +/* + * Slave trigger to send wake up signal on LIN bus for 3 times if there is no LIN frame on the LIN bus after wake up signal. + * @param [in] none. + * @return: none; + */ +void ls_send_wake_up_bus_signal(void); + +#endif /* __LIN_STACK_H__ */ \ No newline at end of file diff --git a/87400/usr/library/softTimerTask.h b/87400/usr/library/softTimerTask.h new file mode 100644 index 0000000..9e174e5 --- /dev/null +++ b/87400/usr/library/softTimerTask.h @@ -0,0 +1,78 @@ +#ifndef GLOBAL_TIMER_H +#define GLOBAL_TIMER_H + +#include +#include +#include + +#define SOFT_TIMER_INTERVAL_POS 3U +#define SOFT_TIMER_INTERVAL (1UL << SOFT_TIMER_INTERVAL_POS) /* ms, must be 2^SOFT_TIMER_INTERVAL_POS*/ + +/*- Types ------------------------------------------------------------------*/ +typedef enum{ + TIMER_ONE_SHOT_MODE, /*this a one time timer, when timming expired, timer would be killed automatically*/ + TIMER_PERIODIC_MODE, /*this a period timer, timer would keep running unitl execute SoftTimer_Stop(), or change the mode by manual.*/ +}SoftTimerMode_t; + + +/* Note that: the SoftTimer_t entity MUST be global/static variable!! */ +typedef struct SoftTimer { + struct SoftTimer *next; /* Internal data don't use!! */ + uint32_t timeout; /* Internal data don't use!! */ + + uint32_t interval; /* Timer parameters unit : ms*/ + SoftTimerMode_t mode; + uint32_t param; /* variables for user use*/ + void (*handler)(struct SoftTimer *timer); +}SoftTimer_t; + +/* + * Start running target timer + * @param [in] timer: target defined global/ static timer + * @return none + */ +void SoftTimer_Start(SoftTimer_t *timer); +/* + * Stop target timer + * @param [in] timer: target defined global/ static timer + * @return none + */ +void SoftTimer_Stop(SoftTimer_t *timer); +/* + * query whether target timer has been started + * @param [in] timer: target defined global/ static timer + * @return 0: not start, other: statred. + */ +uint8_t SoftTimer_Started(SoftTimer_t *timer); + + +/* Soft time handle task only for internal use*/ +void SoftTimer_TaskHandler(void); +/* Soft time base callback function only for internal use*/ +void SoftTimer_ExpireCallback(void); + + + + + + + + + + + + + + + + + + + + + + + + + +#endif \ No newline at end of file diff --git a/87400/usr/main.c b/87400/usr/main.c new file mode 100644 index 0000000..842983b --- /dev/null +++ b/87400/usr/main.c @@ -0,0 +1,20 @@ +#include +#include +#include +#include +#include + +void main(void) +{ +#if ENABLE_FUNCTION_VALIDATION == 1 + validation_main(); +#endif + /* !!!!!!!MUST BE called firstly here for initializing system parameters !!!!*/ + PDS_Init(); + /* System init for hardwre init */ + SYS_Init(); + /* system main infinite loop */ + for(;;){ + TM_RunTasks(); + } +} diff --git a/87400/usr/validation/inc/hdfVerify.h b/87400/usr/validation/inc/hdfVerify.h new file mode 100644 index 0000000..98d93f8 --- /dev/null +++ b/87400/usr/validation/inc/hdfVerify.h @@ -0,0 +1,21 @@ +#ifndef HDF_VERIFY_H__ +#define HDF_VERIFY_H__ + +#include + +void HDF_VERIFY_CrgaAddressVerify(void); +void HDF_VERIFY_GtimerAddressVerify(void); +void HDF_VERIFY_AUXPWMAddressVerify(void); +void HDF_VERIFY_LINSAddressVerify(void); +void HDF_VERIFY_SARAddressVerify(void); +void HDF_VERIFY_GPIOAddressVerify(void); +void HDF_VERIFY_IOCTRLAddressVerify(void); + + + + + + + + +#endif diff --git a/87400/usr/validation/inc/hwCfgVerify.h b/87400/usr/validation/inc/hwCfgVerify.h new file mode 100644 index 0000000..337b08c --- /dev/null +++ b/87400/usr/validation/inc/hwCfgVerify.h @@ -0,0 +1,21 @@ +#ifndef HWCFG_VERIFY_H__ +#define HWCFG_VERIFY_H__ + +#include +#include + + + + +uint32_t HWCFG_VERIFY_AddressVerify(void); +uint32_t HWCFG_VERIFY_ContentVerify(void); +uint32_t HWCFG_VERIFY_CRCVerify(void); +uint32_t HWCFG_VERIFY_ContentRangeVerify(void); +uint32_t HWCFG_VERIFY_REGLoadVerify(void); + + + + + + +#endif diff --git a/87400/usr/validation/inc/val_adc.h b/87400/usr/validation/inc/val_adc.h new file mode 100644 index 0000000..12658ba --- /dev/null +++ b/87400/usr/validation/inc/val_adc.h @@ -0,0 +1,72 @@ +#ifndef VAL_ADC_H__ +#define VAL_ADC_H__ + +#include + + +void validate_adc(void); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#endif diff --git a/87400/usr/validation/inc/val_clock.h b/87400/usr/validation/inc/val_clock.h new file mode 100644 index 0000000..d77e1db --- /dev/null +++ b/87400/usr/validation/inc/val_clock.h @@ -0,0 +1,13 @@ +#ifndef VAL_CLOCK_H__ +#define VAL_CLOCK_H__ + + + +void validate_clock(void); + + + + + +#endif + diff --git a/87400/usr/validation/inc/val_cttimer.h b/87400/usr/validation/inc/val_cttimer.h new file mode 100644 index 0000000..7ca3360 --- /dev/null +++ b/87400/usr/validation/inc/val_cttimer.h @@ -0,0 +1,12 @@ +#ifndef VAL_CTTIMER_H__ +#define VAL_CTTIMER_H__ + + + +void validate_cttimer(void); + + + + + +#endif diff --git a/87400/usr/validation/inc/val_delay.h b/87400/usr/validation/inc/val_delay.h new file mode 100644 index 0000000..852c288 --- /dev/null +++ b/87400/usr/validation/inc/val_delay.h @@ -0,0 +1,12 @@ +#ifndef VAL_DELAY_H__ +#define VAL_DELAY_H__ + + + +void delay(uint32_t delay); + + + + +#endif + diff --git a/87400/usr/validation/inc/val_flash.h b/87400/usr/validation/inc/val_flash.h new file mode 100644 index 0000000..2a47d71 --- /dev/null +++ b/87400/usr/validation/inc/val_flash.h @@ -0,0 +1,12 @@ +#ifndef VAL_FLASH_H__ +#define VAL_FLASH_H__ + + + +void validate_flash(void); + + + + + +#endif diff --git a/87400/usr/validation/inc/val_gpio.h b/87400/usr/validation/inc/val_gpio.h new file mode 100644 index 0000000..ff990aa --- /dev/null +++ b/87400/usr/validation/inc/val_gpio.h @@ -0,0 +1,13 @@ +#ifndef VAL_GPIO_H__ +#define VAL_GPIO_H__ + + + +void validate_gpio(void); + + + + + +#endif + diff --git a/87400/usr/validation/inc/val_gtimer.h b/87400/usr/validation/inc/val_gtimer.h new file mode 100644 index 0000000..69b27c2 --- /dev/null +++ b/87400/usr/validation/inc/val_gtimer.h @@ -0,0 +1,12 @@ +#ifndef VAL_GTIMER_H__ +#define VAL_GTIMER_H__ + + + +void validate_gtimer(void); + + + + + +#endif diff --git a/87400/usr/validation/inc/val_lins.h b/87400/usr/validation/inc/val_lins.h new file mode 100644 index 0000000..d918416 --- /dev/null +++ b/87400/usr/validation/inc/val_lins.h @@ -0,0 +1,11 @@ +#ifndef VAL_LINS_H__ +#define VAL_LINS_H__ + + + + + + + +#endif + diff --git a/87400/usr/validation/inc/val_m0.h b/87400/usr/validation/inc/val_m0.h new file mode 100644 index 0000000..9dbac82 --- /dev/null +++ b/87400/usr/validation/inc/val_m0.h @@ -0,0 +1,12 @@ +#ifndef VAL_M0_H__ +#define VAL_M0_H__ + + + +void validate_m0(void); + + + + + +#endif diff --git a/87400/usr/validation/inc/val_mux.h b/87400/usr/validation/inc/val_mux.h new file mode 100644 index 0000000..5680957 --- /dev/null +++ b/87400/usr/validation/inc/val_mux.h @@ -0,0 +1,72 @@ +#ifndef VAL_MUX_H__ +#define VAL_MUX_H__ + + +typedef enum{ + TEST_MUX0_PC3 = 0U, + TEST_MUX1_PB1, + TEST_MUX2_PB4, + TEST_MUX3_PB7, +}Test_Mux_Port_t; + + +typedef enum{ + TEST_MUX_LINSPHY_RXD = 6U, + TEST_MUX_LINSPHY_TXD = 7U, + TEST_MUX_LFRC = 8U, + TEST_MUX_HFRC = 9U, + TEST_MUX_SYSCLOCK = 12U, + TEST_MUX_ADCCLOCK = 18U, + TEST_MUX_LINSCORE_RXD = 34U, + TEST_MUX_LINSCORE_TXD = 35U, + +}Test_Mux_Select_t; + + + + +typedef enum{ + ANA_MUX_PA2 = 0x0001U, + ANA_MUX_PA3 = 0x0002U, + ANA_MUX_PA4 = 0x0004U, + ANA_MUX_PA5 = 0x0008U, + ANA_MUX_PA6 = 0x0010U, + ANA_MUX_PC3 = 0x0020U, + ANA_MUX_PC4 = 0x0040U, + ANA_MUX_PB0 = 0x0080U, + ANA_MUX_PB1 = 0x0100U, + ANA_MUX_PB2 = 0x0200U, + ANA_MUX_PB3 = 0x0400U, + ANA_MUX_PB4 = 0x0800U, + ANA_MUX_PB5 = 0x1000U, + ANA_MUX_PB6 = 0x2000U, + ANA_MUX_PB7 = 0x4000U, +}AnalogTest_Mux_Port_t; + +typedef enum{ + TEST_MUX_PB4_VDD3V3_1_2 = 0x0001U, + TEST_MUX_PB4_VDD1V5_1_1 = 0x0002U, + TEST_MUX_PB4_PRE5V_1_4 = 0x0004U, + TEST_MUX_PB4_EXT3V3_1_2 = 0x0008U, + TEST_MUX_PB5_VBG_1P2 = 0x0010U, + TEST_MUX_PB5_VBG_BUF = 0x0020U, + TEST_MUX_PB5_VBG_1P1 = 0x0040U, + TEST_MUX_PB5_TEMPSENSOR = 0x0080U, + TEST_MUX_PB5_ADCREFERENCE = 0x0100U, + TEST_MUX_PB5_BORREFERENCE = 0x0200U, + TEST_MUX_PB7_CSA_FILTEROUT = 0x0400U, + TEST_MUX_PB7_CSA_OUT = 0x0800U, + TEST_MUX_PB7_DAC_OUT = 0x1000U, + +}AnalogTest_Mux_Select_t; + + + + + + +void DigitalTestMux_OutputSelect(Test_Mux_Port_t port, Test_Mux_Select_t mode); +void validate_mux(void); + +#endif + diff --git a/87400/usr/validation/inc/val_pmu.h b/87400/usr/validation/inc/val_pmu.h new file mode 100644 index 0000000..eeb62e7 --- /dev/null +++ b/87400/usr/validation/inc/val_pmu.h @@ -0,0 +1,13 @@ +#ifndef VAL_PMU_H__ +#define VAL_PMU_H__ + + + +void validate_pmu(void); + + + + + +#endif + diff --git a/87400/usr/validation/inc/val_power.h b/87400/usr/validation/inc/val_power.h new file mode 100644 index 0000000..f7c37fe --- /dev/null +++ b/87400/usr/validation/inc/val_power.h @@ -0,0 +1,12 @@ +#ifndef VAL_POWER_H__ +#define VAL_POWER_H__ + + + +void validate_power(void); + + + + + +#endif diff --git a/87400/usr/validation/inc/val_pwm.h b/87400/usr/validation/inc/val_pwm.h new file mode 100644 index 0000000..382765a --- /dev/null +++ b/87400/usr/validation/inc/val_pwm.h @@ -0,0 +1,13 @@ +#ifndef VAL_PWM_H__ +#define VAL_PWM_H__ + + + +void validate_pwm(void); + + + + + +#endif + diff --git a/87400/usr/validation/inc/val_pwmaux.h b/87400/usr/validation/inc/val_pwmaux.h new file mode 100644 index 0000000..58905dc --- /dev/null +++ b/87400/usr/validation/inc/val_pwmaux.h @@ -0,0 +1,13 @@ +#ifndef VAL_PWMAUX_H__ +#define VAL_PWMAUX_H__ + + + +void validate_pwmaux(void); + + + + + +#endif + diff --git a/87400/usr/validation/inc/val_spi.h b/87400/usr/validation/inc/val_spi.h new file mode 100644 index 0000000..e8a25ac --- /dev/null +++ b/87400/usr/validation/inc/val_spi.h @@ -0,0 +1,13 @@ +#ifndef VAL_SPI_H__ +#define VAL_SPI_H__ + + + +void validate_spi(void); + + + + + +#endif + diff --git a/87400/usr/validation/inc/val_system.h b/87400/usr/validation/inc/val_system.h new file mode 100644 index 0000000..f26d55a --- /dev/null +++ b/87400/usr/validation/inc/val_system.h @@ -0,0 +1,13 @@ +#ifndef VAL_SYSTEM_H__ +#define VAL_SYSTEM_H__ + +void Check_SystemStartUpStatus(void); + +void validate_system(void); + + + + + +#endif + diff --git a/87400/usr/validation/inc/val_tempsensor.h b/87400/usr/validation/inc/val_tempsensor.h new file mode 100644 index 0000000..3b1c2fe --- /dev/null +++ b/87400/usr/validation/inc/val_tempsensor.h @@ -0,0 +1,13 @@ +#ifndef VAL_TEMPSENSOR_H__ +#define VAL_TEMPSENSOR_H__ + + + +void validate_tempsensor(void); + + + + + +#endif + diff --git a/87400/usr/validation/inc/val_uart.h b/87400/usr/validation/inc/val_uart.h new file mode 100644 index 0000000..26a1ca8 --- /dev/null +++ b/87400/usr/validation/inc/val_uart.h @@ -0,0 +1,11 @@ +#ifndef VAL_UART_H__ +#define VAL_UART_H__ + + + +void validate_uart(void); + + + +#endif + diff --git a/87400/usr/validation/inc/val_wdta.h b/87400/usr/validation/inc/val_wdta.h new file mode 100644 index 0000000..0ed95f6 --- /dev/null +++ b/87400/usr/validation/inc/val_wdta.h @@ -0,0 +1,11 @@ +#ifndef VAL_WDTA_H__ +#define VAL_WDTA_H__ + + + +void validate_wdta(void); + + + +#endif + diff --git a/87400/usr/validation/inc/validation.h b/87400/usr/validation/inc/validation.h new file mode 100644 index 0000000..f0efc66 --- /dev/null +++ b/87400/usr/validation/inc/validation.h @@ -0,0 +1,8 @@ +#ifndef VALIDATION_H_ +#define VALIDATION_H_ + +void validation_main(void); + + + +#endif \ No newline at end of file diff --git a/87400/usr/validation/src/hdfVerfify.c b/87400/usr/validation/src/hdfVerfify.c new file mode 100644 index 0000000..3eabf18 --- /dev/null +++ b/87400/usr/validation/src/hdfVerfify.c @@ -0,0 +1,298 @@ +#include +#include + +void HDF_VERIFY_CrgaAddressVerify(void) +{ + uint32_t test_addr = 0; + + test_addr = (uint32_t)(&CRGA_SFRS->LFCLKCTRL.WORD); + DEBUG_OUT("0x%08X\tCRGA_SFRS->LFCLKCTRL\t0x%08X\r\n",test_addr,CRGA_SFRS->LFCLKCTRL.WORD); + + + test_addr = (uint32_t)(&CRGA_SFRS->SYSCLKCTRL.WORD); + DEBUG_OUT("0x%08X\tCRGA_SFRS->SYSCLKCTRL\t0x%08X\r\n",test_addr,CRGA_SFRS->SYSCLKCTRL.WORD); + + + test_addr = (uint32_t)(&CRGA_SFRS->RESETCTRL.WORD); + DEBUG_OUT("0x%08X\tCRGA_SFRS->RESETCTRL\t0x%08X\r\n",test_addr,CRGA_SFRS->RESETCTRL.WORD); + + test_addr = (uint32_t)(&CRGA_SFRS->MODUCLKSTOP.WORD); + DEBUG_OUT("0x%08X\tCRGA_SFRS->MODUCLKSTOP\t0x%08X\r\n",test_addr,CRGA_SFRS->MODUCLKSTOP.WORD); + + test_addr = (uint32_t)(&CRGA_SFRS->MODUSLEEPEN.WORD); + DEBUG_OUT("0x%08X\tCRGA_SFRS->MODUSLEEPEN\t0x%08X\r\n",test_addr,CRGA_SFRS->MODUSLEEPEN.WORD); + + test_addr = (uint32_t)(&CRGA_SFRS->MODUDEEPSLEEPEN.WORD); + DEBUG_OUT("0x%08X\tCRGA_SFRS->MODUDEEPSLEEPEN\t0x%08X\r\n",test_addr,CRGA_SFRS->MODUDEEPSLEEPEN.WORD); + + test_addr = (uint32_t)(&CRGA_SFRS->MODULERSTREQ); + DEBUG_OUT("0x%08X\tCRGA_SFRS->MODULERSTREQ\t0x%08X\r\n",test_addr,CRGA_SFRS->MODULERSTREQ); + + test_addr = (uint32_t)(&CRGA_SFRS->WDTACTION.WORD); + DEBUG_OUT("0x%08X\tCRGA_SFRS->WDTACTION\t0x%08X\r\n",test_addr,CRGA_SFRS->WDTACTION.WORD); + + test_addr = (uint32_t)(&CRGA_SFRS->LFCLKKILL.WORD); + DEBUG_OUT("0x%08X\tCRGA_SFRS->LFCLKKILL\t0x%08X\r\n",test_addr,CRGA_SFRS->LFCLKKILL.WORD); + + test_addr = (uint32_t)(&CRGA_SFRS->OVTEMPACTION.WORD); + DEBUG_OUT("0x%08X\tCRGA_SFRS->OVTEMPACTION\t0x%08X\r\n",test_addr,CRGA_SFRS->OVTEMPACTION.WORD); + + test_addr = (uint32_t)(&CRGA_SFRS->OVUVACTION.WORD); + DEBUG_OUT("0x%08X\tCRGA_SFRS->OVUVACTION\t0x%08X\r\n",test_addr,CRGA_SFRS->OVUVACTION.WORD); + + test_addr = (uint32_t)(&CRGA_SFRS->SWDCTRL.WORD); + DEBUG_OUT("0x%08X\tCRGA_SFRS->SWDCTRL\t0x%08X\r\n",test_addr,CRGA_SFRS->SWDCTRL.WORD); + +} + + + +void HDF_VERIFY_GtimerAddressVerify(void) +{ + uint32_t test_addr = 0; + + for(uint8_t i=0;i<5;i++){ + + test_addr = (uint32_t)(>IMER_SFRS->TIMER[i].GTCTRLR.WORD); + DEBUG_OUT("0x%08X\tGTIMER_SFRS->TIMER[%d].GTCTRLR\t0x%08X\r\n",test_addr,i,GTIMER_SFRS->TIMER[i].GTCTRLR.WORD); + + test_addr = (uint32_t)(>IMER_SFRS->TIMER[i].GTINTCTRLR.WORD); + DEBUG_OUT("0x%08X\tGTIMER_SFRS->TIMER[%d].GTINTCTRLR\t0x%08X\r\n",test_addr,i,GTIMER_SFRS->TIMER[i].GTINTCTRLR.WORD); + + test_addr = (uint32_t)(>IMER_SFRS->TIMER[i].GTRCV); + DEBUG_OUT("0x%08X\tGTIMER_SFRS->TIMER[%d].GTRCV\t0x%08X\r\n",test_addr,i,GTIMER_SFRS->TIMER[i].GTRCV); + + test_addr = (uint32_t)(>IMER_SFRS->TIMER[i].GTCV); + DEBUG_OUT("0x%08X\tGTIMER_SFRS->TIMER[%d].GTCV\t0x%08X\r\n",test_addr,i,GTIMER_SFRS->TIMER[i].GTCV); + + } + +} + + +void HDF_VERIFY_AUXPWMAddressVerify(void) +{ + uint32_t test_addr = 0; + + for(uint8_t i=0;i<2;i++){ + + test_addr = (uint32_t)(&PWM_AUX_SFRS->PWM_AUX[i].BASE); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->PWM_AUX[%d].BASE\t0x%08X\r\n",test_addr,i,PWM_AUX_SFRS->PWM_AUX[i].BASE); + + test_addr = (uint32_t)(&PWM_AUX_SFRS->PWM_AUX[i].PWMCNT); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->PWM_AUX[%d].PWMCNT\t0x%08X\r\n",test_addr,i,PWM_AUX_SFRS->PWM_AUX[i].PWMCNT); + + } + + test_addr = (uint32_t)(&PWM_AUX_SFRS->BASE_SEL); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->BASE_SEL\t0x%08X\r\n",test_addr,PWM_AUX_SFRS->BASE_SEL); + + test_addr = (uint32_t)(&PWM_AUX_SFRS->ENAREQ.WORD); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->ENAREQ\t0x%08X\r\n",test_addr,PWM_AUX_SFRS->ENAREQ.WORD); + + test_addr = (uint32_t)(&PWM_AUX_SFRS->ENASTS); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->ENASTS\t0x%08X\r\n",test_addr,PWM_AUX_SFRS->ENASTS); + + test_addr = (uint32_t)(&PWM_AUX_SFRS->INIT); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->INIT\t0x%08X\r\n",test_addr,PWM_AUX_SFRS->INIT); + + test_addr = (uint32_t)(&PWM_AUX_SFRS->INVERT); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->INVERT\t0x%08X\r\n",test_addr,PWM_AUX_SFRS->INVERT); + + test_addr = (uint32_t)(&PWM_AUX_SFRS->UPDATE); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->UPDATE\t0x%08X\r\n",test_addr,PWM_AUX_SFRS->UPDATE); + + for(uint8_t i=0;i<6;i++){ + + test_addr = (uint32_t)(&PWM_AUX_SFRS->PULSE[i].WORD); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->PULSE[%d]\t0x%08X\r\n",test_addr,i,PWM_AUX_SFRS->PULSE[i].WORD); + } + + test_addr = (uint32_t)(&PWM_AUX_SFRS->INTPOSEDGENA); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->INTPOSEDGENA\t0x%08X\r\n",test_addr,PWM_AUX_SFRS->INTPOSEDGENA); + + test_addr = (uint32_t)(&PWM_AUX_SFRS->INTNEGEDGENA); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->INTNEGEDGENA\t0x%08X\r\n",test_addr,PWM_AUX_SFRS->INTNEGEDGENA); + + test_addr = (uint32_t)(&PWM_AUX_SFRS->INTPOSEDGCLR); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->INTPOSEDGCLR\t0x%08X\r\n",test_addr,PWM_AUX_SFRS->INTPOSEDGCLR); + + test_addr = (uint32_t)(&PWM_AUX_SFRS->INTNEGEDGCLR); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->INTNEGEDGCLR\t0x%08X\r\n",test_addr,PWM_AUX_SFRS->INTNEGEDGCLR); + + test_addr = (uint32_t)(&PWM_AUX_SFRS->INTPOSEDGSTS); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->INTPOSEDGSTS\t0x%08X\r\n",test_addr,PWM_AUX_SFRS->INTPOSEDGSTS); + + test_addr = (uint32_t)(&PWM_AUX_SFRS->INTNEGEDGSTS); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->INTNEGEDGSTS\t0x%08X\r\n",test_addr,PWM_AUX_SFRS->INTNEGEDGSTS); + + test_addr = (uint32_t)(&PWM_AUX_SFRS->INTPOSEDGIRQ); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->INTPOSEDGIRQ\t0x%08X\r\n",test_addr,PWM_AUX_SFRS->INTPOSEDGIRQ); + + test_addr = (uint32_t)(&PWM_AUX_SFRS->INTNEGEDGIRQ); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->INTNEGEDGIRQ\t0x%08X\r\n",test_addr,PWM_AUX_SFRS->INTNEGEDGIRQ); + + test_addr = (uint32_t)(&PWM_AUX_SFRS->INTPERIOD.WORD); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->INTPERIOD\t0x%08X\r\n",test_addr,PWM_AUX_SFRS->INTPERIOD.WORD); + + test_addr = (uint32_t)(&PWM_AUX_SFRS->INTUPDATED.WORD); + DEBUG_OUT("0x%08X\tPWM_AUX_SFRS->INTUPDATED\t0x%08X\r\n",test_addr,PWM_AUX_SFRS->INTUPDATED.WORD); + + +} + + +void HDF_VERIFY_LINSAddressVerify(void) +{ + uint32_t test_addr = 0; + + for(uint8_t i=0;i<8;i++){ + + test_addr = (uint32_t)(&LINS_SFRS->DATABUFF[i].WORD); + DEBUG_OUT("0x%08X\tLINS_SFRS->DATABUFF[%d]\t0x%08X\r\n",test_addr,i,LINS_SFRS->DATABUFF[i].WORD); + } + + test_addr = (uint32_t)(&LINS_SFRS->CTRL.WORD); + DEBUG_OUT("0x%08X\tLINS_SFRS->CTRL\t0x%08X\r\n",test_addr,LINS_SFRS->CTRL.WORD); + + test_addr = (uint32_t)(&LINS_SFRS->STATUS.WORD); + DEBUG_OUT("0x%08X\tLINS_SFRS->STATUS\t0x%08X\r\n",test_addr,LINS_SFRS->STATUS.WORD); + + +} + + +void HDF_VERIFY_SARAddressVerify(void) +{ + + uint32_t test_addr = 0; + + for(uint8_t i=0;i<10;i++){ + + test_addr = (uint32_t)(&SAR_CTRL_SFRS->DATA[i]); + DEBUG_OUT("0x%08X\tSAR_CTRL_SFRS->DATA[%d]\t0x%08X\r\n",test_addr,i,SAR_CTRL_SFRS->DATA[i]); + } + + test_addr = (uint32_t)(&SAR_CTRL_SFRS->SARCFG.WORD); + DEBUG_OUT("0x%08X\tSAR_CTRL_SFRS->SARCFG\t0x%08X\r\n",test_addr,SAR_CTRL_SFRS->SARCFG.WORD); + + test_addr = (uint32_t)(&SAR_CTRL_SFRS->AFECTRL.WORD); + DEBUG_OUT("0x%08X\tSAR_CTRL_SFRS->AFECTRL\t0x%08X\r\n",test_addr,SAR_CTRL_SFRS->AFECTRL.WORD); + + test_addr = (uint32_t)(&SAR_CTRL_SFRS->SARCTRL.WORD); + DEBUG_OUT("0x%08X\tSAR_CTRL_SFRS->SARCTRL\t0x%08X\r\n",test_addr,SAR_CTRL_SFRS->SARCTRL.WORD); + + + test_addr = (uint32_t)(&SAR_CTRL_SFRS->ADCCHCONF.WORD); + DEBUG_OUT("0x%08X\tSAR_CTRL_SFRS->ADCCHCONF\t0x%08X\r\n",test_addr,SAR_CTRL_SFRS->ADCCHCONF.WORD); + + test_addr = (uint32_t)(&SAR_CTRL_SFRS->ADCCHSELR.WORD); + DEBUG_OUT("0x%08X\tSAR_CTRL_SFRS->ADCCHSELR\t0x%08X\r\n",test_addr,SAR_CTRL_SFRS->ADCCHSELR.WORD); + + test_addr = (uint32_t)(&SAR_CTRL_SFRS->ADCCHCTRL0R.WORD); + DEBUG_OUT("0x%08X\tSAR_CTRL_SFRS->ADCCHCTRL0R\t0x%08X\r\n",test_addr,SAR_CTRL_SFRS->ADCCHCTRL0R.WORD); + + + test_addr = (uint32_t)(&SAR_CTRL_SFRS->ADCCHCTRL1R.WORD); + DEBUG_OUT("0x%08X\tSAR_CTRL_SFRS->ADCCHCTRL1R\t0x%08X\r\n",test_addr,SAR_CTRL_SFRS->ADCCHCTRL1R.WORD); + + test_addr = (uint32_t)(&SAR_CTRL_SFRS->ADCCHCTRL2R.WORD); + DEBUG_OUT("0x%08X\tSAR_CTRL_SFRS->ADCCHCTRL2R\t0x%08X\r\n",test_addr,SAR_CTRL_SFRS->ADCCHCTRL2R.WORD); + + test_addr = (uint32_t)(&SAR_CTRL_SFRS->SARINT.WORD); + DEBUG_OUT("0x%08X\tSAR_CTRL_SFRS->SARINT\t0x%08X\r\n",test_addr,SAR_CTRL_SFRS->SARINT.WORD); + + test_addr = (uint32_t)(&SAR_CTRL_SFRS->SARCLKDIV); + DEBUG_OUT("0x%08X\tSAR_CTRL_SFRS->SARCLKDIV\t0x%08X\r\n",test_addr,SAR_CTRL_SFRS->SARCLKDIV); + +} + + +void HDF_VERIFY_GPIOAddressVerify(void) +{ + uint32_t test_addr = 0; + + for(uint8_t i=0;i<3;i++){ + + test_addr = (uint32_t)(&GPIO_SFRS->GPIO_SET[i]); + DEBUG_OUT("0x%08X\tGPIO_SFRS->GPIO_SET[%d]\t0x%08X\r\n",test_addr,i,GPIO_SFRS->GPIO_SET[i]); + } + + test_addr = (uint32_t)(&GPIO_SFRS->GPIOA[0]); + DEBUG_OUT("0x%08X\tGPIO_SFRS->GPIOA[0]\t0x%08X\r\n",test_addr,GPIO_SFRS->GPIOA[0]); + test_addr = (uint32_t)(&GPIO_SFRS->GPIOA[4]); + DEBUG_OUT("0x%08X\tGPIO_SFRS->GPIOA[4]\t0x%08X\r\n",test_addr,GPIO_SFRS->GPIOA[4]); + + test_addr = (uint32_t)(&GPIO_SFRS->GPIOB[0]); + DEBUG_OUT("0x%08X\tGPIO_SFRS->GPIOB[0]\t0x%08X\r\n",test_addr,GPIO_SFRS->GPIOB[0]); + test_addr = (uint32_t)(&GPIO_SFRS->GPIOB[4]); + DEBUG_OUT("0x%08X\tGPIO_SFRS->GPIOB[4]\t0x%08X\r\n",test_addr,GPIO_SFRS->GPIOB[4]); + + test_addr = (uint32_t)(&GPIO_SFRS->GPIOC[0]); + DEBUG_OUT("0x%08X\tGPIO_SFRS->GPIOC[0]\t0x%08X\r\n",test_addr,GPIO_SFRS->GPIOC[0]); + test_addr = (uint32_t)(&GPIO_SFRS->GPIOC[4]); + DEBUG_OUT("0x%08X\tGPIO_SFRS->GPIOC[4]\t0x%08X\r\n",test_addr,GPIO_SFRS->GPIOC[4]); + + test_addr = (uint32_t)(&GPIO_SFRS->GPENA.WORD); + DEBUG_OUT("0x%08X\tGPIO_SFRS->GPENA\t0x%08X\r\n",test_addr,GPIO_SFRS->GPENA.WORD); + + +} + +void HDF_VERIFY_IOCTRLAddressVerify(void) +{ + + uint32_t test_addr = 0; + + for(uint8_t i=0;i<3;i++){ + test_addr = (uint32_t)(&IOCTRLA_SFRS->PORT_GROUP_MUX[i]); + DEBUG_OUT("0x%08X\tIOCTRLA_SFRS->PORT_GROUP_MUX[%d]\t0x%08X\r\n",test_addr,i,IOCTRLA_SFRS->PORT_GROUP_MUX[i]); + } + for(uint8_t i=0;i<3;i++){ + test_addr = (uint32_t)(&IOCTRLA_SFRS->CTRL_MODE[i]); + DEBUG_OUT("0x%08X\tIOCTRLA_SFRS->CTRL_MODE[%d]\t0x%08X\r\n",test_addr,i,IOCTRLA_SFRS->CTRL_MODE[i]); + } + + test_addr = (uint32_t)(&IOCTRLA_SFRS->TESTMUX.WORD); + DEBUG_OUT("0x%08X\tIOCTRLA_SFRS->TESTMUX\t0x%08X\r\n",test_addr,IOCTRLA_SFRS->TESTMUX.WORD); + + test_addr = (uint32_t)(&IOCTRLA_SFRS->LINSGFCONF.WORD); + DEBUG_OUT("0x%08X\tIOCTRLA_SFRS->LINSGFCONF\t0x%08X\r\n",test_addr,IOCTRLA_SFRS->LINSGFCONF.WORD); + + test_addr = (uint32_t)(&IOCTRLA_SFRS->LINSGFCONF1.WORD); + DEBUG_OUT("0x%08X\tIOCTRLA_SFRS->LINSGFCONF1\t0x%08X\r\n",test_addr,IOCTRLA_SFRS->LINSGFCONF1.WORD); + + test_addr = (uint32_t)(&IOCTRLA_SFRS->FILT_ACCESS.WORD); + DEBUG_OUT("0x%08X\tIOCTRLA_SFRS->FILT_ACCESS\t0x%08X\r\n",test_addr,IOCTRLA_SFRS->FILT_ACCESS.WORD); + + test_addr = (uint32_t)(&IOCTRLA_SFRS->LINTXDMONITOR.WORD); + DEBUG_OUT("0x%08X\tIOCTRLA_SFRS->LINTXDMONITOR\t0x%08X\r\n",test_addr,IOCTRLA_SFRS->LINTXDMONITOR.WORD); + + test_addr = (uint32_t)(&IOCTRLA_SFRS->IRQ.WORD); + DEBUG_OUT("0x%08X\tIOCTRLA_SFRS->IRQ\t0x%08X\r\n",test_addr,IOCTRLA_SFRS->IRQ.WORD); + + + test_addr = (uint32_t)(&IOCTRLA_SFRS->ANALOGTESTMUXOVERRIDE.WORD); + DEBUG_OUT("0x%08X\tIOCTRLA_SFRS->ANALOGTESTMUXOVERRIDE\t0x%08X\r\n",test_addr,IOCTRLA_SFRS->ANALOGTESTMUXOVERRIDE.WORD); + + + test_addr = (uint32_t)(&IOCTRLA_SFRS->IODBNC.WORD); + DEBUG_OUT("0x%08X\tIOCTRLA_SFRS->IODBNC\t0x%08X\r\n",test_addr,IOCTRLA_SFRS->IODBNC.WORD); + + test_addr = (uint32_t)(&IOCTRLA_SFRS->IOGFCONF0.WORD); + DEBUG_OUT("0x%08X\tIOCTRLA_SFRS->IOGFCONF0\t0x%08X\r\n",test_addr,IOCTRLA_SFRS->IOGFCONF0.WORD); + + test_addr = (uint32_t)(&IOCTRLA_SFRS->IOGFCONF1.WORD); + DEBUG_OUT("0x%08X\tIOCTRLA_SFRS->IOGFCONF1\t0x%08X\r\n",test_addr,IOCTRLA_SFRS->IOGFCONF1.WORD); + + test_addr = (uint32_t)(&IOCTRLA_SFRS->IODBNCGRPS0.WORD); + DEBUG_OUT("0x%08X\tIOCTRLA_SFRS->IODBNCGRPS0\t0x%08X\r\n",test_addr,IOCTRLA_SFRS->IODBNCGRPS0.WORD); + + test_addr = (uint32_t)(&IOCTRLA_SFRS->IODBNCGRPS1.WORD); + DEBUG_OUT("0x%08X\tIOCTRLA_SFRS->IODBNCGRPS1\t0x%08X\r\n",test_addr,IOCTRLA_SFRS->IODBNCGRPS1.WORD); + +} + + + + diff --git a/87400/usr/validation/src/hwCfgVerify.c b/87400/usr/validation/src/hwCfgVerify.c new file mode 100644 index 0000000..5ca71e4 --- /dev/null +++ b/87400/usr/validation/src/hwCfgVerify.c @@ -0,0 +1,1150 @@ +#include +#include +#include + +uint32_t HWCFG_VERIFY_AddressVerify(void) +{ + uint32_t test_addr = 0; + + test_addr = (uint32_t)(&HWCFG_SFRS->OSC_TRIM); + DEBUG_OUT("0x%05X\tOSC_TRIM\r\n",test_addr); + if (test_addr != 0x20000){ + return 0x20000; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->OSC_TRIM_RESVD); + DEBUG_OUT("0x%05X\tOSC_TRIM_RESVD\r\n",test_addr); + if (test_addr != 0x20004){ + return 0x20004; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->VDD3V3_LDO_TRIM); + DEBUG_OUT("0x%05X\tVDD3V3_LDO_TRIM\r\n",test_addr); + if (test_addr != 0x20008){ + return 0x20008; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->OCP_CTRL_3V3); + DEBUG_OUT("0x%05X\tOCP_CTRL_3V3\r\n",test_addr); + if (test_addr != 0x2000A){ + return 0x2000A; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->VDD3V3EXT_LDO_TRIM); + DEBUG_OUT("0x%05X\tVDD3V3EXT_LDO_TRIM\r\n",test_addr); + if (test_addr != 0x2000C){ + return 0x2000C; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->OCP_CTRL_3V3_EXT); + DEBUG_OUT("0x%05X\tOCP_CTRL_3V3_EXT\r\n",test_addr); + if (test_addr != 0x2000E){ + return 0x2000E; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->VDD1V5_LDO_TRIM); + DEBUG_OUT("0x%05X\tVDD1V5_LDO_TRIM\r\n",test_addr); + if (test_addr != 0x20010){ + return 0x20010; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->OCP_CTRL_1V5); + DEBUG_OUT("0x%05X\tOCP_CTRL_1V5\r\n",test_addr); + if (test_addr != 0x20012){ + return 0x20012; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_BG); + DEBUG_OUT("0x%05X\tTRIM_BG\r\n",test_addr); + if (test_addr != 0x20014){ + return 0x20014; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_VREF_BUF); + DEBUG_OUT("0x%05X\tTRIM_VREF_BUF\r\n",test_addr); + if (test_addr != 0x20016){ + return 0x20016; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_LF_RC); + DEBUG_OUT("0x%05X\tTRIM_LF_RC\r\n",test_addr); + if (test_addr != 0x20018){ + return 0x20018; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_HF_RC); + DEBUG_OUT("0x%05X\tTRIM_HF_RC\r\n",test_addr); + if (test_addr != 0x2001A){ + return 0x2001A; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_UHF_RC); + DEBUG_OUT("0x%05X\tTRIM_UHF_RC\r\n",test_addr); + if (test_addr != 0x2001C){ + return 0x2001C; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->LINS_TX_DUTY); + DEBUG_OUT("0x%05X\tLINS_TX_DUTY\r\n",test_addr); + if (test_addr != 0x2001E){ + return 0x2001E; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->LINS_TX_SLOPE); + DEBUG_OUT("0x%05X\tLINS_TX_SLOPE\r\n",test_addr); + if (test_addr != 0x20020){ + return 0x20020; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->LINS_TX_BIAS_BOOST); + DEBUG_OUT("0x%05X\tLINS_TX_BIAS_BOOST\r\n",test_addr); + if (test_addr != 0x20022){ + return 0x20022; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->S_BOR_1P5V); + DEBUG_OUT("0x%05X\tS_BOR_1P5V\r\n",test_addr); + if (test_addr != 0x20024){ + return 0x20024; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->S_BOR_3P3V); + DEBUG_OUT("0x%05X\tS_BOR_3P3V\r\n",test_addr); + if (test_addr != 0x20026){ + return 0x20026; + } + test_addr = (uint32_t)(&HWCFG_SFRS->RESVD0); + DEBUG_OUT("0x%05X\tRESVD0\r\n",test_addr); + if (test_addr != 0x20028){ + return 0x20028; + } + DEBUG_OUT("\r\n"); + + test_addr = (uint32_t)(&HWCFG_SFRS->BANDGAP_2TIMES_VOLT_mV); + DEBUG_OUT("0x%05X\tBANDGAP_2TIMES_VOLT_mV\r\n",test_addr); + if (test_addr != 0x20080){ + return 0x20080; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->ADC_CODE_2P0V); + DEBUG_OUT("0x%05X\tADC_CODE_2P0V\r\n",test_addr); + if (test_addr != 0x20082){ + return 0x20082; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->ADC_CODE_1P0V); + DEBUG_OUT("0x%05X\tADC_CODE_1P0V\r\n",test_addr); + if (test_addr != 0x20084){ + return 0x20084; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->ADC_CODE_0P5V); + DEBUG_OUT("0x%05X\tADC_CODE_0P5V\r\n",test_addr); + if (test_addr != 0x20086){ + return 0x20086; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->ADC_CODE_VBAT_13P5V); + DEBUG_OUT("0x%05X\tADC_CODE_VBAT_13P5V\r\n",test_addr); + if (test_addr != 0x20088){ + return 0x20088; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->ADC_CODE_VBAT_8P0V); + DEBUG_OUT("0x%05X\tADC_CODE_VBAT_8P0V\r\n",test_addr); + if (test_addr != 0x2008A){ + return 0x2008A; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->ADC_CODE_TEMPSENSOR_25C); + DEBUG_OUT("0x%05X\tADC_CODE_TEMPSENSOR_25C\r\n",test_addr); + if (test_addr != 0x2008C){ + return 0x2008C; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->VOLTAGE_TEMPSENSOR_25C); + DEBUG_OUT("0x%05X\tVOLTAGE_TEMPSENSOR_25C\r\n",test_addr); + if (test_addr != 0x2008E){ + return 0x2008E; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[0].V1_mV); + DEBUG_OUT("0x%05X\tCSA_GAIN[0].V1_mV\r\n",test_addr); + if (test_addr != 0x20090){ + return 0x20090; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[0].V2_mV); + DEBUG_OUT("0x%05X\tCSA_GAIN[0].V2_mV\r\n",test_addr); + if (test_addr != 0x20092){ + return 0x20092; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[0].V1_CODE); + DEBUG_OUT("0x%05X\tCSA_GAIN[0].V1_COD\r\n",test_addr); + if (test_addr != 0x20094){ + return 0x20094; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[0].V2_CODE); + DEBUG_OUT("0x%05X\tCSA_GAIN[0].V2_CODE\r\n",test_addr); + if (test_addr != 0x20096){ + return 0x20096; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[0].GAIN); + DEBUG_OUT("0x%05X\tCSA_GAIN[0].GAIN\r\n",test_addr); + if (test_addr != 0x20098){ + return 0x20098; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[0].RESVD); + DEBUG_OUT("0x%05X\tCSA_GAIN[0].RESV\r\n",test_addr); + if (test_addr != 0x2009A){ + return 0x2009A; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[1].V1_mV); + DEBUG_OUT("0x%05X\tCSA_GAIN[1].V1_mV\r\n",test_addr); + if (test_addr != 0x2009C){ + return 0x2009C; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[1].V2_mV); + DEBUG_OUT("0x%05X\tCSA_GAIN[1].V2_mV\r\n",test_addr); + if (test_addr != 0x2009E){ + return 0x2009E; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[1].V1_CODE); + DEBUG_OUT("0x%05X\tCSA_GAIN[1].V1_CODE\r\n",test_addr); + if (test_addr != 0x200A0){ + return 0x200A0; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[1].V2_CODE); + DEBUG_OUT("0x%05X\tCSA_GAIN[1].V2_CODE\r\n",test_addr); + if (test_addr != 0x200A2){ + return 0x200A2; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[1].GAIN); + DEBUG_OUT("0x%05X\tCSA_GAIN[1].GAIN\r\n",test_addr); + if (test_addr != 0x200A4){ + return 0x200A4; + } + + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[1].RESVD); + DEBUG_OUT("0x%05X\tCSA_GAIN[1].RESVD\r\n",test_addr); + if (test_addr != 0x200A6){ + return 0x200A6; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[2].V1_mV); + DEBUG_OUT("0x%05X\tCSA_GAIN[2].V1_mV\r\n",test_addr); + if (test_addr != 0x200A8){ + return 0x200A8; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[2].V2_mV); + DEBUG_OUT("0x%05X\tCSA_GAIN[2].V2_mV\r\n",test_addr); + if (test_addr != 0x200AA){ + return 0x200AA; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[2].V1_CODE); + DEBUG_OUT("0x%05X\tCSA_GAIN[2].V1_CODE\r\n",test_addr); + if (test_addr != 0x200AC){ + return 0x200AC; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[2].V2_CODE); + DEBUG_OUT("0x%05X\tCSA_GAIN[2].V2_CODE\r\n",test_addr); + if (test_addr != 0x200AE){ + return 0x200AE; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[2].GAIN); + DEBUG_OUT("0x%05X\tCSA_GAIN[2].GAIN\r\n",test_addr); + if (test_addr != 0x200B0){ + return 0x200B0; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[2].RESVD); + DEBUG_OUT("0x%05X\tCSA_GAIN[2].RESVD\r\n",test_addr); + if (test_addr != 0x200B2){ + return 0x200B2; + } + + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[3].V1_mV); + DEBUG_OUT("0x%05X\tCSA_GAIN[3].V1_mV\r\n",test_addr); + if (test_addr != 0x200B4){ + return 0x200B4; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[3].V2_mV); + DEBUG_OUT("0x%05X\tCSA_GAIN[3].V2_mV\r\n",test_addr); + if (test_addr != 0x200B6){ + return 0x200B6; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[3].V1_CODE); + DEBUG_OUT("0x%05X\tCSA_GAIN[3].V1_CODE\r\n",test_addr); + if (test_addr != 0x200B8){ + return 0x200B8; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[3].V2_CODE); + DEBUG_OUT("0x%05X\tCSA_GAIN[3].V2_CODE\r\n",test_addr); + if (test_addr != 0x200BA){ + return 0x200BA; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[3].GAIN); + DEBUG_OUT("0x%05X\tCSA_GAIN[3].GAIN\r\n",test_addr); + if (test_addr != 0x200BC){ + return 0x200BC; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[3].RESVD); + DEBUG_OUT("0x%05X\tCSA_GAIN[3].RESVD\r\n",test_addr); + if (test_addr != 0x200BE){ + return 0x200BE; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->RESVD1); + DEBUG_OUT("0x%05X\tRESVD1\r\n",test_addr); + if (test_addr != 0x200C0){ + return 0x200BE; + } + DEBUG_OUT("\r\n"); + + + + test_addr = (uint32_t)(&HWCFG_SFRS->CHIP_NAME); + DEBUG_OUT("0x%05X\tCHIP_NAME\r\n",test_addr); + if (test_addr != 0x20100){ + return 0x20100; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CHIP_VERSION); + DEBUG_OUT("0x%05X\tCHIP_VERSION\r\n",test_addr); + if (test_addr != 0x20104){ + return 0x20104; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->LOT_ID_L); + DEBUG_OUT("0x%05X\tOLD_LOT_ID\r\n",test_addr); + //DEBUG_OUT("0x%05X,",test_addr); + if (test_addr != 0x20108){ + return 0x20108; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->LOT_ID_H); + //DEBUG_OUT("0x%05X\tLOT_ID\r\n",test_addr); + if (test_addr != 0x2010c){ + return 0x2010c; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->YEAR); + DEBUG_OUT("0x%05X\tYEAR\r\n",test_addr); + if (test_addr != 0x20110){ + return 0x20110; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->MON); + DEBUG_OUT("0x%05X\tMON\r\n",test_addr); + if (test_addr != 0x20114){ + return 0x20114; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->DAY); + DEBUG_OUT("0x%05X\tDAY\r\n",test_addr); + if (test_addr != 0x20116){ + return 0x20116; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CHIP_ID); + DEBUG_OUT("0x%05X\tCHIP_ID\r\n",test_addr); + if (test_addr != 0x20118){ + return 0x20118; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CHIP_ID_B); + DEBUG_OUT("0x%05X\tCHIP_ID_B\r\n",test_addr); + if (test_addr != 0x2011c){ + return 0x2011c; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CHIP_ID_S); + DEBUG_OUT("0x%05X\tCHIP_ID_S\r\n",test_addr); + if (test_addr != 0x2011e){ + return 0x2011e; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->TEST_PROGRAM_VERSION); + DEBUG_OUT("0x%05X\tTEST_PROGRAM_VERSION\r\n",test_addr); + if (test_addr != 0x20120){ + return 0x20120; + } + + + test_addr = (uint32_t)(&HWCFG_SFRS->RESVD4); + DEBUG_OUT("0x%05X\tRESVD4\r\n",test_addr); + if (test_addr != 0x20124){ + return 0x20124; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->TEST_FACTORY_L); + DEBUG_OUT("0x%05X\tTEST_FACTORY\r\n",test_addr); + if (test_addr != 0x20128){ + return 0x20128; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->TEST_FACTORY_H); + //DEBUG_OUT("0x%05X\tTEST_FACTORY_H\r\n",test_addr); + if (test_addr != 0x2012c){ + return 0x2012c; + } + + + test_addr = (uint32_t)(&HWCFG_SFRS->LOTID); + DEBUG_OUT("0x%05X\tLOTID\r\n",test_addr); + if (test_addr != 0x20130){ + return 0x20130; + } + test_addr = (uint32_t)(&HWCFG_SFRS->RESVD2); + DEBUG_OUT("0x%05X\tRESVD2\r\n",test_addr); + if (test_addr != 0x20150){ + return 0x20150; + } + + + DEBUG_OUT("\r\n"); + + + + + test_addr = (uint32_t)(&HWCFG_SFRS->CRC32); + DEBUG_OUT("0x%05X\tCRC32\r\n",test_addr); + if (test_addr != 0x201f8){ + return 0x201f8; + } + test_addr = (uint32_t)(&HWCFG_SFRS->RESVD3); + DEBUG_OUT("0x%05X\tRESVD3\r\n",test_addr); + if (test_addr != 0x201fc){ + return 0x201fc; + } + DEBUG_OUT("PASS\r\n"); + return 0; +} + + +uint32_t HWCFG_VERIFY_ContentVerify(void) +{ + uint32_t test_addr = 0; + + test_addr = (uint32_t)(&HWCFG_SFRS->OSC_TRIM); + DEBUG_OUT("0x%05X\tOSC_TRIM\r\n",test_addr); + if ( HWCFG_SFRS->OSC_TRIM != *(uint32_t *)0x20000){ + return 0x20000; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->OSC_TRIM_RESVD); + DEBUG_OUT("0x%05X\tOSC_TRIM_RESVD\r\n",test_addr); + if ( HWCFG_SFRS->OSC_TRIM_RESVD != *(uint32_t *)0x20004){ + return 0x20004; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->VDD3V3_LDO_TRIM); + DEBUG_OUT("0x%05X\tVDD3V3_LDO_TRIM\r\n",test_addr); + if ( HWCFG_SFRS->VDD3V3_LDO_TRIM != *(uint16_t *)0x20008){ + return 0x20008; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->OCP_CTRL_3V3); + DEBUG_OUT("0x%05X\tOCP_CTRL_3V3\r\n",test_addr); + if ( HWCFG_SFRS->OCP_CTRL_3V3 != *(uint16_t *)0x2000A){ + return 0x2000A; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->VDD3V3EXT_LDO_TRIM); + DEBUG_OUT("0x%05X\tVDD3V3EXT_LDO_TRIM\r\n",test_addr); + if ( HWCFG_SFRS->VDD3V3EXT_LDO_TRIM != *(uint16_t *)0x2000C){ + return 0x2000C; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->OCP_CTRL_3V3_EXT); + DEBUG_OUT("0x%05X\tOCP_CTRL_3V3_EXT\r\n",test_addr); + if ( HWCFG_SFRS->OCP_CTRL_3V3_EXT != *(uint16_t *)0x2000E){ + return 0x2000E; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->VDD1V5_LDO_TRIM); + DEBUG_OUT("0x%05X\tVDD1V5_LDO_TRIM\r\n",test_addr); + + if ( HWCFG_SFRS->VDD1V5_LDO_TRIM != *(uint16_t *)0x20010){ + return 0x20010; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->OCP_CTRL_1V5); + DEBUG_OUT("0x%05X\tOCP_CTRL_1V5\r\n",test_addr); + + if ( HWCFG_SFRS->OCP_CTRL_1V5 != *(uint16_t *)0x20012){ + return 0x20012; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_BG); + DEBUG_OUT("0x%05X\tTRIM_BG\r\n",test_addr); + + if ( HWCFG_SFRS->TRIM_BG != *(uint16_t *)0x20014){ + return 0x20014; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_VREF_BUF); + DEBUG_OUT("0x%05X\tTRIM_VREF_BUF\r\n",test_addr); + + if ( HWCFG_SFRS->TRIM_VREF_BUF != *(uint16_t *)0x20016){ + return 0x20016; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_LF_RC); + DEBUG_OUT("0x%05X\tTRIM_LF_RC\r\n",test_addr); + if ( HWCFG_SFRS->TRIM_LF_RC != *(uint16_t *)0x20018){ + return 0x20018; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_HF_RC); + DEBUG_OUT("0x%05X\tTRIM_HF_RC\r\n",test_addr); + + if ( HWCFG_SFRS->TRIM_HF_RC != *(uint16_t *)0x2001A){ + return 0x2001A; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_UHF_RC); + DEBUG_OUT("0x%05X\tTRIM_UHF_RC\r\n",test_addr); + + if ( HWCFG_SFRS->TRIM_UHF_RC != *(uint16_t *)0x2001C){ + return 0x2001C; + } + test_addr = (uint32_t)(&HWCFG_SFRS->LINS_TX_DUTY); + DEBUG_OUT("0x%05X\tLINS_TX_DUTY\r\n",test_addr); + + if ( HWCFG_SFRS->LINS_TX_DUTY != *(uint16_t *)0x2001E){ + return 0x2001E; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->LINS_TX_SLOPE); + DEBUG_OUT("0x%05X\tLINS_TX_SLOPE\r\n",test_addr); + if ( HWCFG_SFRS->LINS_TX_SLOPE != *(uint16_t *)0x20020){ + return 0x20020; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->LINS_TX_BIAS_BOOST); + DEBUG_OUT("0x%05X\tLINS_TX_BIAS_BOOST\r\n",test_addr); + if ( HWCFG_SFRS->LINS_TX_BIAS_BOOST != *(uint16_t *)0x20022){ + return 0x20022; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->S_BOR_1P5V); + DEBUG_OUT("0x%05X\tS_BOR_1P5V\r\n",test_addr); + if ( HWCFG_SFRS->S_BOR_1P5V != *(uint16_t *)0x20024){ + return 0x20024; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->S_BOR_3P3V); + DEBUG_OUT("0x%05X\tS_BOR_3P3V\r\n",test_addr); + if ( HWCFG_SFRS->S_BOR_3P3V != *(uint16_t *)0x20026){ + return 0x20026; + } + test_addr = (uint32_t)(&HWCFG_SFRS->RESVD0); + DEBUG_OUT("0x%05X\tRESVD0\r\n",test_addr); + + DEBUG_OUT("\r\n"); + + test_addr = (uint32_t)(&HWCFG_SFRS->BANDGAP_2TIMES_VOLT_mV); + DEBUG_OUT("0x%05X\tBANDGAP_2TIMES_VOLT_mV\r\n",test_addr); + if ( HWCFG_SFRS->BANDGAP_2TIMES_VOLT_mV != *(uint16_t *)0x20080){ + return 0x20080; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->ADC_CODE_2P0V); + DEBUG_OUT("0x%05X\tADC_CODE_2P0V\r\n",test_addr); + + if ( HWCFG_SFRS->ADC_CODE_2P0V != *(uint16_t *)0x20082){ + return 0x20082; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->ADC_CODE_1P0V); + DEBUG_OUT("0x%05X\tADC_CODE_1P0V\r\n",test_addr); + + + if ( HWCFG_SFRS->ADC_CODE_1P0V != *(uint16_t *)0x20084){ + return 0x20084; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->ADC_CODE_0P5V); + DEBUG_OUT("0x%05X\tADC_CODE_0P5V\r\n",test_addr); + + if ( HWCFG_SFRS->ADC_CODE_0P5V != *(uint16_t *)0x20086){ + return 0x20086; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->ADC_CODE_VBAT_13P5V); + DEBUG_OUT("0x%05X\tADC_CODE_VBAT_13P5V\r\n",test_addr); + if ( HWCFG_SFRS->ADC_CODE_VBAT_13P5V != *(uint16_t *)0x20088){ + return 0x20088; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->ADC_CODE_VBAT_8P0V); + DEBUG_OUT("0x%05X\tADC_CODE_VBAT_8P0V\r\n",test_addr); + + if ( HWCFG_SFRS->ADC_CODE_VBAT_8P0V != *(uint16_t *)0x2008A){ + return 0x2008A; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->ADC_CODE_TEMPSENSOR_25C); + DEBUG_OUT("0x%05X\tADC_CODE_TEMPSENSOR_25C\r\n",test_addr); + if ( HWCFG_SFRS->ADC_CODE_TEMPSENSOR_25C != *(uint16_t *)0x2008C){ + return 0x2008C; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->VOLTAGE_TEMPSENSOR_25C); + DEBUG_OUT("0x%05X\tVOLTAGE_TEMPSENSOR_25C\r\n",test_addr); + if ( HWCFG_SFRS->VOLTAGE_TEMPSENSOR_25C != *(uint16_t *)0x2008E){ + return 0x2008E; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[0].V1_mV); + DEBUG_OUT("0x%05X\tCSA_GAIN[0].V1_mV\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[0].V1_mV != *(uint16_t *)0x20090){ + return 0x20090; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[0].V2_mV); + DEBUG_OUT("0x%05X\tCSA_GAIN[0].V2_mV\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[0].V2_mV != *(uint16_t *)0x20092){ + return 0x20092; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[0].V1_CODE); + DEBUG_OUT("0x%05X\tCSA_GAIN[0].V1_CODE\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[0].V1_CODE != *(uint16_t *)0x20094){ + return 0x20094; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[0].V2_CODE); + DEBUG_OUT("0x%05X\tCSA_GAIN[0].V2_CODE\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[0].V2_CODE != *(uint16_t *)0x20096){ + return 0x20096; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[0].GAIN); + DEBUG_OUT("0x%05X\tCSA_GAIN[0].GAIN\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[0].GAIN != *(uint16_t *)0x20098){ + return 0x20098; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[0].RESVD); + DEBUG_OUT("0x%05X\tCSA_GAIN[0].GAIN\r\n",test_addr); + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[1].V1_mV); + DEBUG_OUT("0x%05X\tCSA_GAIN[1].V1_mV\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[1].V1_mV != *(uint16_t *)0x2009C){ + return 0x2009C; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[1].V2_mV); + DEBUG_OUT("0x%05X\tCSA_GAIN[1].V2_mV\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[1].V2_mV != *(uint16_t *)0x2009E){ + return 0x2009E; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[1].V1_CODE); + DEBUG_OUT("0x%05X\tCSA_GAIN[1].V1_CODE\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[1].V1_CODE != *(uint16_t *)0x200A0){ + return 0x200A0; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[1].V2_CODE); + DEBUG_OUT("0x%05X\tCSA_GAIN[1].V2_CODE\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[1].V2_CODE != *(uint16_t *)0x200A2){ + return 0x200A2; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[1].GAIN); + DEBUG_OUT("0x%05X\tCSA_GAIN[1].GAIN\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[1].GAIN != *(uint16_t *)0x200A4){ + return 0x200A4; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[1].RESVD); + DEBUG_OUT("0x%05X\tCSA_GAIN[1].GAIN\r\n",test_addr); + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[2].V1_mV); + DEBUG_OUT("0x%05X\tCSA_GAIN[2].V1_mV\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[2].V1_mV != *(uint16_t *)0x200A8){ + return 0x200A8; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[2].V2_mV); + DEBUG_OUT("0x%05X\tCSA_GAIN[2].V2_mV\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[2].V2_mV != *(uint16_t *)0x200AA){ + return 0x200AA; + } + + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[2].V1_CODE); + DEBUG_OUT("0x%05X\tCSA_GAIN[2].V1_CODE\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[2].V1_CODE != *(uint16_t *)0x200AC){ + return 0x200AC; + } + + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[2].V2_CODE); + DEBUG_OUT("0x%05X\tCSA_GAIN[2].V2_CODE\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[2].V2_CODE != *(uint16_t *)0x200AE){ + return 0x200AE; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[2].GAIN); + DEBUG_OUT("0x%05X\tCSA_GAIN[2].GAIN\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[2].GAIN != *(uint16_t *)0x200B0){ + return 0x200B0; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[2].RESVD); + DEBUG_OUT("0x%05X\tCSA_GAIN[2].GAIN\r\n",test_addr); + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[3].V1_mV); + DEBUG_OUT("0x%05X\tCSA_GAIN[3].V1_mV\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[3].V1_mV != *(uint16_t *)0x200B4){ + return 0x200B4; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[3].V2_mV); + DEBUG_OUT("0x%05X\tCSA_GAIN[3].V2_mV\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[3].V2_mV != *(uint16_t *)0x200B6){ + return 0x200B6; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[3].V1_CODE); + DEBUG_OUT("0x%05X\tCSA_GAIN[3].V1_CODE\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[3].V1_CODE != *(uint16_t *)0x200B8){ + return 0x200B8; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[3].V2_CODE); + DEBUG_OUT("0x%05X\tCSA_GAIN[3].V2_CODE\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[3].V2_CODE != *(uint16_t *)0x200BA){ + return 0x200BA; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[3].GAIN); + DEBUG_OUT("0x%05X\tCSA_GAIN[3].GAIN\r\n",test_addr); + if ( HWCFG_SFRS->CSA_GAIN[3].GAIN != *(uint16_t *)0x200BC){ + return 0x200BC; + } + test_addr = (uint32_t)(&HWCFG_SFRS->CSA_GAIN[3].RESVD); + DEBUG_OUT("0x%05X\tCSA_GAIN[3].GAIN\r\n",test_addr); + + test_addr = (uint32_t)(&HWCFG_SFRS->RESVD1); + DEBUG_OUT("0x%05X\tRESVD1\r\n",test_addr); + + + DEBUG_OUT("\r\n"); + + test_addr = (uint32_t)(&HWCFG_SFRS->CHIP_NAME); + DEBUG_OUT("0x%05X\tCHIP_NAME\r\n",test_addr); + if ( HWCFG_SFRS->CHIP_NAME != *(uint32_t *)0x20100){ + return 0x20100; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CHIP_VERSION); + DEBUG_OUT("0x%05X\tCHIP_VERSION\r\n",test_addr); + if ( HWCFG_SFRS->CHIP_VERSION != *(uint32_t *)0x20104){ + return 0x20104; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->LOT_ID_L); + DEBUG_OUT("0x%05X\tOLD_LOT_ID\r\n",test_addr); + if ( HWCFG_SFRS->LOT_ID_L != *(uint32_t *)0x20108){ + return 0x20108; + } + + if ( HWCFG_SFRS->LOT_ID_H != *(uint32_t *)0x2010c){ + return 0x2010c; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->YEAR); + DEBUG_OUT("0x%05X\tYEAR\r\n",test_addr); + + if ( HWCFG_SFRS->YEAR != *(uint32_t *)0x20110){ + return 0x20110; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->MON); + DEBUG_OUT("0x%05X\tMON\r\n",test_addr); + if ( HWCFG_SFRS->MON != *(uint16_t *)0x20114){ + return 0x20114; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->DAY); + DEBUG_OUT("0x%05X\tDAY\r\n",test_addr); + if ( HWCFG_SFRS->DAY != *(uint16_t *)0x20116){ + return 0x20116; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CHIP_ID); + DEBUG_OUT("0x%05X\tCHIP_ID\r\n",test_addr); + if ( HWCFG_SFRS->CHIP_ID != *(uint32_t *)0x20118){ + return 0x20118; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CHIP_ID_B); + DEBUG_OUT("0x%05X\tCHIP_ID_B\r\n",test_addr); + if ( HWCFG_SFRS->CHIP_ID_B != *(uint16_t *)0x2011c){ + return 0x2011c; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->CHIP_ID_S); + DEBUG_OUT("0x%05X\tCHIP_ID_S\r\n",test_addr); + if ( HWCFG_SFRS->CHIP_ID_S != *(uint16_t *)0x2011e){ + return 0x2011e; + } + + + test_addr = (uint32_t)(&HWCFG_SFRS->TEST_PROGRAM_VERSION); + DEBUG_OUT("0x%05X\tTEST_PROGRAM_VERSION\r\n",test_addr); + if ( HWCFG_SFRS->TEST_PROGRAM_VERSION != *(uint32_t *)0x20120){ + return 0x20120; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->RESVD4); + DEBUG_OUT("0x%05X\tRESVD4\r\n",test_addr); + if ( HWCFG_SFRS->RESVD4 != *(uint32_t *)0x20124){ + return 0x20124; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->TEST_FACTORY_L); + DEBUG_OUT("0x%05X\tTEST_FACTORY\r\n",test_addr); + if ( HWCFG_SFRS->TEST_FACTORY_L != *(uint32_t *)0x20128){ + return 0x20128; + } + + if ( HWCFG_SFRS->TEST_FACTORY_H != *(uint32_t *)0x2012c){ + return 0x2012c; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->LOTID); + DEBUG_OUT("0x%05X\tLOTID\r\n",test_addr); + + test_addr = (uint32_t)(&HWCFG_SFRS->RESVD2); + DEBUG_OUT("0x%05X\tRESVD2\r\n",test_addr); + + DEBUG_OUT("\r\n"); + + test_addr = (uint32_t)(&HWCFG_SFRS->CRC32); + DEBUG_OUT("0x%05X\tCRC32\r\n",test_addr); + if ( HWCFG_SFRS->CRC32 != *(uint32_t *)0x201f8){ + return 0x201f8; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->RESVD3); + DEBUG_OUT("0x%05X\tRESVD3\r\n",test_addr); + if ( HWCFG_SFRS->RESVD3 != *(uint32_t *)0x201fc){ + return 0x201fc; + } + DEBUG_OUT("PASS\r\n"); + return 0; +} + + +uint32_t HWCFG_VERIFY_ContentRangeVerify(void) +{ + uint32_t test_addr = 0; + + test_addr = (uint32_t)(&HWCFG_SFRS->OSC_TRIM); + DEBUG_OUT("0x%05X\tOSC_TRIM\t0x%08X\r\n",test_addr,HWCFG_SFRS->OSC_TRIM); + if ( HWCFG_SFRS->OSC_TRIM != *(uint32_t *)0x20000){ + return 0x20000; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->OSC_TRIM_RESVD); + DEBUG_OUT("0x%05X\tOSC_TRIM_RESVD\r\n",test_addr); + if ( HWCFG_SFRS->OSC_TRIM_RESVD != *(uint32_t *)0x20004){ + return 0x20004; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->VDD3V3_LDO_TRIM); + DEBUG_OUT("0x%05X\tVDD3V3_LDO_TRIM\t0x%04X\r\n",test_addr,HWCFG_SFRS->VDD3V3_LDO_TRIM); + if ( HWCFG_SFRS->VDD3V3_LDO_TRIM > 7U ){ + return 0x20008; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->OCP_CTRL_3V3); + DEBUG_OUT("0x%05X\tOCP_CTRL_3V3\t0x%04X\r\n",test_addr,HWCFG_SFRS->OCP_CTRL_3V3); + if ( HWCFG_SFRS->OCP_CTRL_3V3 > 15U){ + return 0x2000A; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->VDD3V3EXT_LDO_TRIM); + DEBUG_OUT("0x%05X\tVDD3V3EXT_LDO_TRIM\t0x%04X\r\n",test_addr,HWCFG_SFRS->VDD3V3EXT_LDO_TRIM); + if ( HWCFG_SFRS->VDD3V3EXT_LDO_TRIM > 15U){ + return 0x2000C; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->OCP_CTRL_3V3_EXT); + DEBUG_OUT("0x%05X\tOCP_CTRL_3V3_EXT\t0x%04X\r\n",test_addr,HWCFG_SFRS->OCP_CTRL_3V3_EXT); + if ( HWCFG_SFRS->OCP_CTRL_3V3_EXT > 15U){ + return 0x2000E; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->VDD1V5_LDO_TRIM); + DEBUG_OUT("0x%05X\tVDD1V5_LDO_TRIM\t0x%04X\r\n",test_addr,HWCFG_SFRS->VDD1V5_LDO_TRIM); + if ( HWCFG_SFRS->VDD1V5_LDO_TRIM > 3U){ + return 0x20010; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->OCP_CTRL_1V5); + DEBUG_OUT("0x%05X\tOCP_CTRL_1V5\t0x%04X\r\n",test_addr,HWCFG_SFRS->OCP_CTRL_1V5); + if ( HWCFG_SFRS->OCP_CTRL_1V5 > 15U){ + return 0x20012; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_BG); + DEBUG_OUT("0x%05X\tTRIM_BG\t0x%04X\r\n",test_addr,HWCFG_SFRS->TRIM_BG); + if ( HWCFG_SFRS->TRIM_BG > 0x3FU){ + return 0x20014; + } + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_VREF_BUF); + DEBUG_OUT("0x%05X\tTRIM_VREF_BUF\t0x%04X\r\n",test_addr,HWCFG_SFRS->TRIM_VREF_BUF); + if ( HWCFG_SFRS->TRIM_VREF_BUF > 0x1FU){ + return 0x20016; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_LF_RC); + DEBUG_OUT("0x%05X\tTRIM_LF_RC\t0x%04X\r\n",test_addr,HWCFG_SFRS->TRIM_LF_RC); + if ( HWCFG_SFRS->TRIM_LF_RC > 255U){ + return 0x20018; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_HF_RC); + DEBUG_OUT("0x%05X\tTRIM_HF_RC\t0x%04X\r\n",test_addr,HWCFG_SFRS->TRIM_HF_RC); + if ( HWCFG_SFRS->TRIM_HF_RC > 255U){ + return 0x2001A; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_UHF_RC); + DEBUG_OUT("0x%05X\tTRIM_UHF_RC\t0x%04X\r\n",test_addr,HWCFG_SFRS->TRIM_UHF_RC); + if ( HWCFG_SFRS->TRIM_UHF_RC > 255U){ + return 0x2001C; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->LINS_TX_DUTY); + DEBUG_OUT("0x%05X\tLINS_TX_DUTY\t0x%04X\r\n",test_addr,HWCFG_SFRS->LINS_TX_DUTY); + if ( HWCFG_SFRS->LINS_TX_DUTY >7U){ + return 0x2001E; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->LINS_TX_SLOPE); + DEBUG_OUT("0x%05X\tLINS_TX_SLOPE\t0x%04X\r\n",test_addr,HWCFG_SFRS->LINS_TX_SLOPE); + if ( HWCFG_SFRS->LINS_TX_SLOPE >7U){ + return 0x20020; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->LINS_TX_BIAS_BOOST); + DEBUG_OUT("0x%05X\tLINS_TX_BIAS_BOOST\t0x%04X\r\n",test_addr,HWCFG_SFRS->LINS_TX_BIAS_BOOST); + if ( HWCFG_SFRS->LINS_TX_BIAS_BOOST >7U){ + return 0x20022; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->S_BOR_1P5V); + DEBUG_OUT("0x%05X\tS_BOR_1P5V\t0x%04X\r\n",test_addr,HWCFG_SFRS->S_BOR_1P5V); + if ( HWCFG_SFRS->S_BOR_1P5V >15U){ + return 0x20024; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->S_BOR_3P3V); + DEBUG_OUT("0x%05X\tS_BOR_3P3V\t0x%04X\r\n",test_addr,HWCFG_SFRS->S_BOR_3P3V); + if ( HWCFG_SFRS->S_BOR_3P3V > 15U){ + return 0x20026; + } + + test_addr = (uint32_t)(&HWCFG_SFRS->RESVD0); + DEBUG_OUT("0x%05X\tRESVD0\r\n",test_addr); + + + + DEBUG_OUT("PASS\r\n"); + return 0; +} + + +uint32_t HWCFG_VERIFY_CRCVerify(void) +{ + uint32_t crc_struct, crc_ate,crc_memory; + + CRC32_Init(); + crc_struct = CRC32_GetRunTimeCRC32(HWCFG_SFRS_START->payload,504); + crc_memory = CRC32_GetRunTimeCRC32((uint8_t *)0x20000,504); + crc_ate = *(uint32_t *)0x201f8; + + DEBUG_OUT("crc_struct\t0x%08X\r\n",crc_struct); + DEBUG_OUT("crc_memory\t0x%08X\r\n",crc_memory); + DEBUG_OUT("crc_ate\t0x%08X\r\n",crc_ate); + + if (crc_struct != crc_memory || crc_struct != crc_ate || crc_memory != crc_ate ){ + return 0xFFFF; + } + DEBUG_OUT("PASS\r\n"); + return 0; +} + +uint32_t HWCFG_VERIFY_REGLoadVerify(void) +{ + uint32_t test_addr = 0; + uint32_t error_addr = 0; + + DEBUG_OUT("FLASH_SFRS->OSC_TRIM\t0x%08X\t",FLASH_SFRS->OSC_TRIM); + test_addr = (uint32_t)(&HWCFG_SFRS->OSC_TRIM); + DEBUG_OUT("0x%05X\tOSC_TRIM\t0x%08X\r\n",test_addr,HWCFG_SFRS->OSC_TRIM); + if ( HWCFG_SFRS->OSC_TRIM != *(uint32_t *)0x20000){ + error_addr = 0x20000; + } + + DEBUG_OUT("\t\t"); + test_addr = (uint32_t)(&HWCFG_SFRS->OSC_TRIM_RESVD); + DEBUG_OUT("0x%05X\tOSC_TRIM_RESVD\r\n",test_addr); + if ( HWCFG_SFRS->OSC_TRIM_RESVD != *(uint32_t *)0x20004){ + error_addr = 0x20004; + } + + DEBUG_OUT("TRIMHV_SFRS->PMUTRIM.VDD3V3_LDO_TRIM\t0x%04X\t",TRIMHV_SFRS->PMUTRIM.VDD3V3_LDO_TRIM); + test_addr = (uint32_t)(&HWCFG_SFRS->VDD3V3_LDO_TRIM); + DEBUG_OUT("0x%05X\tVDD3V3_LDO_TRIM\t0x%04X\r\n",test_addr,HWCFG_SFRS->VDD3V3_LDO_TRIM); + if ( HWCFG_SFRS->VDD3V3_LDO_TRIM > 7U ){ + error_addr = 0x20008; + } + + DEBUG_OUT("TTRIMHV_SFRS->PMUTRIM.OCP_CTRL_3V3\t0x%04X\t",TRIMHV_SFRS->PMUTRIM.OCP_CTRL_3V3); + test_addr = (uint32_t)(&HWCFG_SFRS->OCP_CTRL_3V3); + DEBUG_OUT("0x%05X\tOCP_CTRL_3V3\t0x%04X\r\n",test_addr,HWCFG_SFRS->OCP_CTRL_3V3); + if ( HWCFG_SFRS->OCP_CTRL_3V3 > 15U){ + error_addr = 0x2000A; + } + + DEBUG_OUT("TRIMHV_SFRS->BORTESTMODE.VDD3V3EXT_LDO_TRIM\t0x%04X\t",TRIMHV_SFRS->BORTESTMODE.VDD3V3EXT_LDO_TRIM); + test_addr = (uint32_t)(&HWCFG_SFRS->VDD3V3EXT_LDO_TRIM); + DEBUG_OUT("0x%05X\tVDD3V3EXT_LDO_TRIM\t0x%04X\r\n",test_addr,HWCFG_SFRS->VDD3V3EXT_LDO_TRIM); + if ( HWCFG_SFRS->VDD3V3EXT_LDO_TRIM > 15U){ + error_addr = 0x2000C; + } + + DEBUG_OUT("TRIMHV_SFRS->BORTESTMODE.OCP_CTRL_3V3_EXT\t0x%04X\t",TRIMHV_SFRS->BORTESTMODE.OCP_CTRL_3V3_EXT); + test_addr = (uint32_t)(&HWCFG_SFRS->OCP_CTRL_3V3_EXT); + DEBUG_OUT("0x%05X\tOCP_CTRL_3V3_EXT\t0x%04X\r\n",test_addr,HWCFG_SFRS->OCP_CTRL_3V3_EXT); + if ( HWCFG_SFRS->OCP_CTRL_3V3_EXT > 15U){ + error_addr = 0x2000E; + } + + DEBUG_OUT("TRIMHV_SFRS->PMUTRIM.VDD1V5_LDO_TRIM\t0x%04X\t",TRIMHV_SFRS->PMUTRIM.VDD1V5_LDO_TRIM); + test_addr = (uint32_t)(&HWCFG_SFRS->VDD1V5_LDO_TRIM); + DEBUG_OUT("0x%05X\tVDD1V5_LDO_TRIM\t0x%04X\r\n",test_addr,HWCFG_SFRS->VDD1V5_LDO_TRIM); + if ( HWCFG_SFRS->VDD1V5_LDO_TRIM > 3U){ + error_addr = 0x20010; + } + + DEBUG_OUT("TRIMHV_SFRS->PMUTRIM.OCP_CTRL_1V5\t0x%04X\t",TRIMHV_SFRS->PMUTRIM.OCP_CTRL_1V5); + test_addr = (uint32_t)(&HWCFG_SFRS->OCP_CTRL_1V5); + DEBUG_OUT("0x%05X\tOCP_CTRL_1V5\t0x%04X\r\n",test_addr,HWCFG_SFRS->OCP_CTRL_1V5); + if ( HWCFG_SFRS->OCP_CTRL_1V5 > 15U){ + error_addr = 0x20012; + } + + DEBUG_OUT("TRIMHV_SFRS->PMUTRIM.TRIM_BG\t0x%04X\t",TRIMHV_SFRS->PMUTRIM.TRIM_BG); + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_BG); + DEBUG_OUT("0x%05X\tTRIM_BG\t0x%04X\r\n",test_addr,HWCFG_SFRS->TRIM_BG); + if ( HWCFG_SFRS->TRIM_BG > 0x3FU){ + error_addr = 0x20014; + } + + DEBUG_OUT("TRIMHV_SFRS->PMUTRIM.TRIM_VREF_BUF\t0x%04X\t",TRIMHV_SFRS->PMUTRIM.TRIM_VREF_BUF); + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_VREF_BUF); + DEBUG_OUT("0x%05X\tTRIM_VREF_BUF\t0x%04X\r\n",test_addr,HWCFG_SFRS->TRIM_VREF_BUF); + if ( HWCFG_SFRS->TRIM_VREF_BUF > 0x1FU){ + error_addr = 0x20016; + } + + DEBUG_OUT("TRIMHV_SFRS->TRIM_LF_RC\t0x%04X\t",TRIMHV_SFRS->TRIM_LF_RC); + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_LF_RC); + DEBUG_OUT("0x%05X\tTRIM_LF_RC\t0x%04X\r\n",test_addr,HWCFG_SFRS->TRIM_LF_RC); + if ( HWCFG_SFRS->TRIM_LF_RC > 255U){ + error_addr = 0x20018; + } + + DEBUG_OUT("SYSCTRLA_SFRS->HF_OSC_TRIM.TRIM_HF_RC\t0x%04X\t",SYSCTRLA_SFRS->HF_OSC_TRIM.TRIM_HF_RC); + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_HF_RC); + DEBUG_OUT("0x%05X\tTRIM_HF_RC\t0x%04X\r\n",test_addr,HWCFG_SFRS->TRIM_HF_RC); + if ( HWCFG_SFRS->TRIM_HF_RC > 255U){ + error_addr = 0x2001A; + } + + DEBUG_OUT("SYSCTRLA_SFRS->UHF_OSC_TRIM.TRIM_UHF_RC\t0x%04X\t",SYSCTRLA_SFRS->UHF_OSC_TRIM.TRIM_UHF_RC); + test_addr = (uint32_t)(&HWCFG_SFRS->TRIM_UHF_RC); + DEBUG_OUT("0x%05X\tTRIM_UHF_RC\t0x%04X\r\n",test_addr,HWCFG_SFRS->TRIM_UHF_RC); + if ( HWCFG_SFRS->TRIM_UHF_RC > 255U){ + error_addr = 0x2001C; + } + + + DEBUG_OUT("TRIMHV_SFRS->LINSTRIM.LINS_TX_DUTY\t0x%04X\t",TRIMHV_SFRS->LINSTRIM.LINS_TX_DUTY); + test_addr = (uint32_t)(&HWCFG_SFRS->LINS_TX_DUTY); + DEBUG_OUT("0x%05X\tLINS_TX_DUTY\t0x%04X\r\n",test_addr,HWCFG_SFRS->LINS_TX_DUTY); + if ( HWCFG_SFRS->LINS_TX_DUTY >7U){ + error_addr = 0x2001E; + } + + + DEBUG_OUT("TRIMHV_SFRS->LINSTRIM.LINS_TX_SLOPE\t0x%04X\t",TRIMHV_SFRS->LINSTRIM.LINS_TX_SLOPE); + test_addr = (uint32_t)(&HWCFG_SFRS->LINS_TX_SLOPE); + DEBUG_OUT("0x%05X\tLINS_TX_SLOPE\t0x%04X\r\n",test_addr,HWCFG_SFRS->LINS_TX_SLOPE); + if ( HWCFG_SFRS->LINS_TX_SLOPE >7U){ + error_addr = 0x20020; + } + + DEBUG_OUT("TRIMHV_SFRS->LINSTRIM.LINS_TX_BIAS_BOOST\t0x%04X\t",TRIMHV_SFRS->LINSTRIM.LINS_TX_BIAS_BOOST); + test_addr = (uint32_t)(&HWCFG_SFRS->LINS_TX_BIAS_BOOST); + DEBUG_OUT("0x%05X\tLINS_TX_BIAS_BOOST\t0x%04X\r\n",test_addr,HWCFG_SFRS->LINS_TX_BIAS_BOOST); + if ( HWCFG_SFRS->LINS_TX_BIAS_BOOST >7U){ + error_addr = 0x20022; + } + + DEBUG_OUT("TRIMHV_SFRS->BORCONFIG.S_BOR_1P5V\t0x%04X\t",TRIMHV_SFRS->BORCONFIG.S_BOR_1P5V); + test_addr = (uint32_t)(&HWCFG_SFRS->S_BOR_1P5V); + DEBUG_OUT("0x%05X\tS_BOR_1P5V\t0x%04X\r\n",test_addr,HWCFG_SFRS->S_BOR_1P5V); + if ( HWCFG_SFRS->S_BOR_1P5V >15U){ + error_addr = 0x20024; + } + + DEBUG_OUT("TRIMHV_SFRS->BORCONFIG.S_BOR_3P3V\t0x%04X\t",TRIMHV_SFRS->BORCONFIG.S_BOR_3P3V); + test_addr = (uint32_t)(&HWCFG_SFRS->S_BOR_3P3V); + DEBUG_OUT("0x%05X\tS_BOR_3P3V\t0x%04X\r\n",test_addr,HWCFG_SFRS->S_BOR_3P3V); + if ( HWCFG_SFRS->S_BOR_3P3V > 15U){ + error_addr = 0x20026; + } + + DEBUG_OUT("\t\t"); + test_addr = (uint32_t)(&HWCFG_SFRS->RESVD0); + DEBUG_OUT("0x%05X\tRESVD0\r\n",test_addr); + + + + DEBUG_OUT("Finish!\r\n"); + return error_addr; +} + + + diff --git a/87400/usr/validation/src/val_adc.c b/87400/usr/validation/src/val_adc.c new file mode 100644 index 0000000..bd9dd4b --- /dev/null +++ b/87400/usr/validation/src/val_adc.c @@ -0,0 +1,127 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 + +#include +#include +#include + +#include +#include +#include + + + +uint16_t adc_cnt = 0; +uint16_t adc_code[3][10]; +uint16_t csagain = 0; +void validate_adc(void) +{ + SYSCTRLA_SFRS->DEBUG_ACCESS_KEY.DEBUG_ACCESS_KEY = 0X05U; + SAR_CTRL_SFRS->SARCLKDIV = 4U;//SAR CLOCK DIVIDE. Divide ration is (SAR_CLK_DIV+1) + + for (uint8_t i = 0U; i < 10U; i++){ + // VREF + //Channel1 adc vref select. + //0x0: adc_vref = vbg + //0x1: adc_vref = 2*vbg + //0x2: adc_vref = VDD_3V3 + //0x3: adc_vref = VDD_3V3 + SAR_CTRL_SFRS->ADCCHCTRL2R.WORD &= ~((uint32_t)0x03UL << (i*2+8U));//clear + SAR_CTRL_SFRS->ADCCHCTRL2R.WORD |= ((uint32_t)ADC_REF_VBG_2TIMES << (i*2+8U));//set + + // INPUT_MODE + //CH1 AFE Input Modes. ADC AFE Input Modes for Channel1. + //0x0: All external. + //0x1: VINP buffered, VINN external. + //0x2: VINN buffered, VINP external. + //0x3: Both VINP & VINN buffered. + SAR_CTRL_SFRS->ADCCHCTRL0R.WORD &= ~((uint32_t)0x03UL << (i*2+0U)); + SAR_CTRL_SFRS->ADCCHCTRL0R.WORD |= ((uint32_t)ADC_AFE_INPUT_ALL_EXT << (i*2+0U)); + + // INPUT GAIN + //ADC Channel1 input gain. + //0x0: 22/32 + //0x1: 31/32 + SAR_CTRL_SFRS->ADCCHCTRL0R.WORD &= ~((uint32_t)0x01UL << (i*1+20U)); + SAR_CTRL_SFRS->ADCCHCTRL0R.WORD |= ((uint32_t)ADC_AFE_GAIN_31_OF_32 << (i*1+20U)); + } + SAR_CTRL_SFRS->SARINT.ENABLE.INT_CONV_DONE_ENA = 0;//1:Convert Done Interrupt Enable. + SAR_CTRL_SFRS->SARINT.ENABLE.INT_TRIG_CLASH_ENA = 0;//1:Trigger Clash Interrupt Enable. + SAR_CTRL_SFRS->SARINT.CLEAR.INT_CONV_DONE_CLR = 1; + SAR_CTRL_SFRS->SARINT.CLEAR.INT_TRIG_CLASH_CLR = 1; + + SAR_CTRL_SFRS->SARCFG.TRIGDLY = 5U;//trigger delay. setting trigger delay time from 0 to 15 sar clock cycles. For PN-detect, trigger delay MUST >= 2us. + SAR_CTRL_SFRS->SARCFG.TRIGSEL = 0U;//0x0: Select TRIGSRC 0x1: Select PWMAUX_TRIGSEL + SAR_CTRL_SFRS->SARCFG.PWMAUXCHSEL = 0; + SAR_CTRL_SFRS->SARCFG.PWMAUXCHSEL = 0; + SAR_CTRL_SFRS->SARCFG.TRIGSRC = 0; + SAR_CTRL_SFRS->SARCFG.ROUND = 0;//0x1: Negative code+1 + + SYSCTRLA_SFRS->CSACTRLR.CSAGAINSEL = 0U;//5 gain + SYSCTRLA_SFRS->CSACTRLR.CSAZEROEN = 0U; + SYSCTRLA_SFRS->CSACTRLR.CSAPOWEN = 1U; + + SAR_CTRL_SFRS->AFECTRL.SARAFEEN = 0;//ADC AFE Enable. adc afe enable. If vinp, vinn and vin vcm all choose external, adc afe should be disabled: adc_adc_en=0, otherwise, adc afe must be enabled: adc_afe_en=1. + SAR_CTRL_SFRS->AFECTRL.ADCSELVINVCMEXT = 1;//Select External Inputs to ADC. choose ADC input common voltage. 0: choose internal vin_vcm, equals to (vinp+vinn)/2; 1: choose external vin_vcm, for PN detect. + SAR_CTRL_SFRS->AFECTRL.SARPREAMPEN = 1;// adc pre-amp enable. + + SAR_CTRL_SFRS->ADCCHCTRL0R.SARINPUTGAINCH1 = 0x0;//0: 22/32 + SAR_CTRL_SFRS->ADCCHCTRL0R.SARINPUTGAINCH2 = 0x0;//0: 22/32 + SAR_CTRL_SFRS->ADCCHCTRL0R.SARINPUTGAINCH3 = 0x0;//0: 22/32 + + SAR_CTRL_SFRS->ADCCHCTRL1R.SAMPCYCCH1 = 0x7;//Channel1 Sample cycle. setting sampling time from 1 to 16 sar clock cycles. + SAR_CTRL_SFRS->ADCCHCTRL1R.SAMPCYCCH2 = 0x7; + SAR_CTRL_SFRS->ADCCHCTRL1R.SAMPCYCCH3 = 0x7; + + SAR_CTRL_SFRS->ADCCHCONF.TESTBATTERYGAINCHOOSE = 0;//0: gain=1/14, vbat max 30V/14=2.14v, under ADC vref=2.4v + SAR_CTRL_SFRS->ADCCHCONF.CH1SEL = 0x8;//: adc_vinp=VBAT ACCURATE (gain selected by TEST_BATTERY_GAIN_CHOOSE), adc_vinn=vref_gnd + SAR_CTRL_SFRS->ADCCHCONF.CH2SEL = 0x4;//0x4: adc_vinp=TempSensor , adc_vinn=vref_gnd +// SAR_CTRL_SFRS->ADCCHCONF.CH3SEL = 0x9;//0x9: adc_vinp=CSA_Filter_OUT , adc_vinn=vref_gnd + SAR_CTRL_SFRS->ADCCHCONF.CH3SEL = 0xa;//0xa: adc_vinp=CSA_OUT , adc_vinn=vref_gnd + SAR_CTRL_SFRS->ADCCHCONF.SEQCNT = 0x3;//0x3: CH1->CH2->CH3 + + SAR_CTRL_SFRS->SARCTRL.DIGRESET = 1; + SAR_CTRL_SFRS->SARCTRL.CONT = 1;//Continuous Conversion Enable. If this bit has been set before an ADC conversion sequence trigged by CONVERT bit or PWM signals, the sequence will be treated as a sequential conversion, rather than a single conversion. + + SAR_CTRL_SFRS->SARINT.CLEAR.INT_CONV_DONE_CLR = 1U; + SAR_CTRL_SFRS->SARCTRL.SARENAREQ = 1U; + SAR_CTRL_SFRS->SARCTRL.CONVERT = 1;//ADC START/STATUS Register. If SOFTWARE trigger source is selected, set to start a conversion, If HARDWARE trigger source is selected, write to this field will be ignored. Read 1 indicates ADC conversion is active; Read 0 indicates ADC is in idle state. + + + while(1){ + csagain = SYSCTRLA_SFRS->CSACTRLR.CSAGAINSEL; + csagain = 5<SARINT.STATUS.CONV_DONE == 1){ + adc_code[0][adc_cnt] = (uint16_t)(SAR_CTRL_SFRS->DATA[0].DATA & 0x0FFFU); + adc_code[1][adc_cnt] = (uint16_t)(SAR_CTRL_SFRS->DATA[1].DATA & 0x0FFFU); + adc_code[2][adc_cnt] = (uint16_t)(SAR_CTRL_SFRS->DATA[2].DATA & 0x0FFFU); + +// DEBUG_OUT("SETVBAT\t%5d\tVBATcode\t%4d\tTempSensorcode\t%4d\tCSA_GAIN\t%4d\tCSAcode\t%2d\n",9500,adc_code[0][adc_cnt],adc_code[1][adc_cnt],csagain,adc_code[2][adc_cnt]); + DEBUG_OUT("VIN\t%4d\tCSA_GAIN\t%2d\tCSAcode\t%4d\n",1000,csagain,adc_code[2][adc_cnt]); + + adc_cnt++; + if(adc_cnt>9){ + adc_cnt = 0; + if(SYSCTRLA_SFRS->CSACTRLR.CSAGAINSEL == 0){ + SYSCTRLA_SFRS->CSACTRLR.CSAGAINSEL = 1; + }else if(SYSCTRLA_SFRS->CSACTRLR.CSAGAINSEL == 1){ + SYSCTRLA_SFRS->CSACTRLR.CSAGAINSEL = 2; + }else if(SYSCTRLA_SFRS->CSACTRLR.CSAGAINSEL == 2){ + SYSCTRLA_SFRS->CSACTRLR.CSAGAINSEL = 3; + }else if(SYSCTRLA_SFRS->CSACTRLR.CSAGAINSEL == 3){ + SYSCTRLA_SFRS->CSACTRLR.CSAGAINSEL = 0; + SAR_CTRL_SFRS->SARINT.CLEAR.INT_CONV_DONE_CLR = 1U; + SAR_CTRL_SFRS->SARCTRL.SARENAREQ = 0U; + SAR_CTRL_SFRS->SARCTRL.CONVERT = 0U; + } + } + + SAR_CTRL_SFRS->SARINT.CLEAR.INT_CONV_DONE_CLR = 1; + + } + } +} + + + +#endif diff --git a/87400/usr/validation/src/val_clock.c b/87400/usr/validation/src/val_clock.c new file mode 100644 index 0000000..623cb1f --- /dev/null +++ b/87400/usr/validation/src/val_clock.c @@ -0,0 +1,143 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 + + +#include +#include +#include + + + + +void LFRC_Trim_Test(void) +{ + DigitalTestMux_OutputSelect(TEST_MUX1_PB1, TEST_MUX_LFRC); + + for(uint8_t i=0;i<16;i++){ + TRIMHV_SFRS->TRIM_LF_RC = i*0x10; + } + + while(1) + { + + } + +} + + +void HFRC_Trim_Test(void) +{ + DigitalTestMux_OutputSelect(TEST_MUX1_PB1, TEST_MUX_HFRC); + + CRGA_SFRS->SYSCLKCTRL.HFRCENA = 1U; + while(CRGA_SFRS->SYSCLKCTRL.HFRCSTS == 0U){} + + CRGA_SFRS->SYSCLKCTRL.SELFASTCLK = 0;//0-HFRC£»1-UHFRC + CRGA_SFRS->SYSCLKCTRL.SYSCLKSEL = 1;//Fast Clock + CRGA_SFRS->SYSCLKCTRL.DIVSYSCLK = 0;//0-no division;1-2 div + + SYSCTRLA_SFRS->HF_OSC_TRIM.SSCDEEP = 7U; + SYSCTRLA_SFRS->HF_OSC_TRIM.SSCDIV = 15U; + SYSCTRLA_SFRS->HF_OSC_TRIM.SSCENA = 0U; + + for(uint8_t i=0;i<16;i++){ + SYSCTRLA_SFRS->HF_OSC_TRIM.TRIM_HF_RC = i*0x10; + } + + while(1) + { + + } + + +} + +void UHFRC_Trim_Test(void) +{ + DigitalTestMux_OutputSelect(TEST_MUX3_PB7, TEST_MUX_SYSCLOCK); + + CRGA_SFRS->SYSCLKCTRL.UHFRCHIGHBWEN = 1U; + CRGA_SFRS->SYSCLKCTRL.UHFRCENA = 1U; + + + CRGA_SFRS->SYSCLKCTRL.SELFASTCLK = 1;//0-HFRC£»1-UHFRC + CRGA_SFRS->SYSCLKCTRL.SYSCLKSEL = 1;//Fast Clock + CRGA_SFRS->SYSCLKCTRL.DIVSYSCLK = 0;//0-no division;1-2 div + + SYSCTRLA_SFRS->UHF_OSC_TRIM.UHFSSCENA = 0U; + + for(uint8_t i=0;i<16;i++){ + SYSCTRLA_SFRS->UHF_OSC_TRIM.TRIM_UHF_RC = i*0x10; + } + + + while(1) + { + + } + +} + +void HFRC_SSC_Test(void) +{ + DigitalTestMux_OutputSelect(TEST_MUX1_PB1, TEST_MUX_HFRC); + DigitalTestMux_OutputSelect(TEST_MUX3_PB7, TEST_MUX_SYSCLOCK); + + + CRGA_SFRS->SYSCLKCTRL.HFRCENA = 1U; + while(CRGA_SFRS->SYSCLKCTRL.HFRCSTS == 0U){} + + CRGA_SFRS->SYSCLKCTRL.SELFASTCLK = 0;//0-HFRC£»1-UHFRC + CRGA_SFRS->SYSCLKCTRL.SYSCLKSEL = 1;//Fast Clock + CRGA_SFRS->SYSCLKCTRL.DIVSYSCLK = 1;//0-no division;1-2 div + + SYSCTRLA_SFRS->HF_OSC_TRIM.SSCDEEP = 7U; + SYSCTRLA_SFRS->HF_OSC_TRIM.SSCDIV = 15U; + SYSCTRLA_SFRS->HF_OSC_TRIM.SSCENA = 1U; + + while(1) + { + + } + +} + + +void UHFRC_SSC_Test(void) +{ + DigitalTestMux_OutputSelect(TEST_MUX1_PB1, TEST_MUX_HFRC); + DigitalTestMux_OutputSelect(TEST_MUX3_PB7, TEST_MUX_SYSCLOCK); + + CRGA_SFRS->SYSCLKCTRL.UHFRCHIGHBWEN = 1U; + CRGA_SFRS->SYSCLKCTRL.UHFRCENA = 1U; + + + CRGA_SFRS->SYSCLKCTRL.SELFASTCLK = 1;//0-HFRC£»1-UHFRC + CRGA_SFRS->SYSCLKCTRL.SYSCLKSEL = 1;//Fast Clock + CRGA_SFRS->SYSCLKCTRL.DIVSYSCLK = 1;//0-no division;1-2 div + + SYSCTRLA_SFRS->UHF_OSC_TRIM.UHFSSCENA = 0U; + + while(1) + { + + } + +} + +void validate_clock(void) +{ + + //HFRC_SSC_Test(); +// UHFRC_SSC_Test(); + + +// LFRC_Trim_Test(); + HFRC_Trim_Test(); +// UHFRC_Trim_Test(); + + +} + + +#endif diff --git a/87400/usr/validation/src/val_cttimer.c b/87400/usr/validation/src/val_cttimer.c new file mode 100644 index 0000000..3880f88 --- /dev/null +++ b/87400/usr/validation/src/val_cttimer.c @@ -0,0 +1,17 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 + + +#include + + + +void validate_cttimer(void) +{ + + + +} + + +#endif diff --git a/87400/usr/validation/src/val_delay.c b/87400/usr/validation/src/val_delay.c new file mode 100644 index 0000000..7de2e59 --- /dev/null +++ b/87400/usr/validation/src/val_delay.c @@ -0,0 +1,19 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 + + +#include + + +void delay(uint32_t delay) +{ + for (uint32_t i = 0; i < delay; i++){ + for (uint32_t j = 0; j < 10000; j++){ + __asm("NOP"); + } + } +} + + + +#endif diff --git a/87400/usr/validation/src/val_flash.c b/87400/usr/validation/src/val_flash.c new file mode 100644 index 0000000..cc4d248 --- /dev/null +++ b/87400/usr/validation/src/val_flash.c @@ -0,0 +1,17 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 + + +#include + + + +void validate_flash(void) +{ + + + +} + + +#endif diff --git a/87400/usr/validation/src/val_gpio.c b/87400/usr/validation/src/val_gpio.c new file mode 100644 index 0000000..8383670 --- /dev/null +++ b/87400/usr/validation/src/val_gpio.c @@ -0,0 +1,117 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 + +#include + +#include + +//test case1 GPIO Input +//test case2 GPIO Output +//test case3 GPIO IRQ +//test case4 DriverStrength +//test case5 pullmode + + + +void GPIO_Input_Test(void) +{ + +} + +void GPIO_OutputTest(void) +{ + + +// for (uint8_t i = (uint8_t)GPIO_PORT_1; i <= (uint8_t)GPIO_PORT_8; i++){ +// GPIO_Init((GpioPort_t)i, GPIO_DIR_OUTPUT,GPIO_PULL_NONE); +// } +// +// +// for (uint8_t i = (uint8_t)GPIO_PORT_1; i <= (uint8_t)GPIO_PORT_8; i++){ +// GPIO_Set((GpioPort_t)i, GPIO_LOW); +// } +// +// +// for (uint8_t i = (uint8_t)GPIO_PORT_1; i <= (uint8_t)GPIO_PORT_8; i++){ +// GPIO_Set((GpioPort_t)i, GPIO_HIGH); +// } +// +// for (uint8_t i = (uint8_t)GPIO_PORT_1; i <= (uint8_t)GPIO_PORT_8; i++){ +// GPIO_Set((GpioPort_t)i, GPIO_LOW); +// } +// +// +// for (uint8_t i = (uint8_t)GPIO_PORT_1; i <= (uint8_t)GPIO_PORT_8; i++){ +// GPIO_Set((GpioPort_t)i, GPIO_HIGH); +// } +// + + + while(1){ + + } +} + + +void GPIO_IRQ_Test(void) +{ +// for (uint8_t i = (uint8_t)GPIO_PORT_2; i <= (uint8_t)GPIO_PORT_8; i++){ +// GPIO_Init((GpioPort_t)i, GPIO_DIR_OUTPUT,GPIO_PULL_NONE); +// } +// +// +// for (uint8_t i = (uint8_t)GPIO_PORT_2; i <= (uint8_t)GPIO_PORT_8; i++){ +// GPIO_Set((GpioPort_t)i, GPIO_LOW); +// } +// +// +// for (uint8_t i = (uint8_t)GPIO_PORT_2; i <= (uint8_t)GPIO_PORT_8; i++){ +// GPIO_Set((GpioPort_t)i, GPIO_HIGH); +// } +// +// for (uint8_t i = (uint8_t)GPIO_PORT_2; i <= (uint8_t)GPIO_PORT_8; i++){ +// GPIO_Set((GpioPort_t)i, GPIO_LOW); +// } + +} + +void GPIO_DriverStrength_Test(void) +{ + +} + +void GPIO_Init_Test(void) +{ +// for (uint8_t i = (uint8_t)GPIO_PORT_2; i <= (uint8_t)GPIO_PORT_8; i++){ +// GPIO_Init((GpioPort_t)i, GPIO_DIR_OUTPUT,GPIO_PULL_NONE); +// } +// +// +// for (uint8_t i = (uint8_t)GPIO_PORT_2; i <= (uint8_t)GPIO_PORT_8; i++){ +// GPIO_Set((GpioPort_t)i, GPIO_LOW); +// } +// +// +// for (uint8_t i = (uint8_t)GPIO_PORT_2; i <= (uint8_t)GPIO_PORT_8; i++){ +// GPIO_Set((GpioPort_t)i, GPIO_HIGH); +// } +// +// for (uint8_t i = (uint8_t)GPIO_PORT_2; i <= (uint8_t)GPIO_PORT_8; i++){ +// GPIO_Set((GpioPort_t)i, GPIO_LOW); +// } + +} +void validate_gpio(void) +{ +// GPIO_Input_Test(); +// GPIO_OutputTest(); +// GPIO_IRQ_Test(); +// GPIO_DriverStrength_Test(); +// while(1); + +// GPIO_Init_Test(); + +} + + +#endif diff --git a/87400/usr/validation/src/val_gtimer.c b/87400/usr/validation/src/val_gtimer.c new file mode 100644 index 0000000..e7119ef --- /dev/null +++ b/87400/usr/validation/src/val_gtimer.c @@ -0,0 +1,17 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 + + +#include + + + +void validate_gtimer(void) +{ + + + +} + + +#endif diff --git a/87400/usr/validation/src/val_lins.c b/87400/usr/validation/src/val_lins.c new file mode 100644 index 0000000..11554a4 --- /dev/null +++ b/87400/usr/validation/src/val_lins.c @@ -0,0 +1,27 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 + +#include +#include + +#include +#include +#include + + + +void LIN_PL_Test(void) +{ + +} + + +void validate_lins(void) +{ + LIN_PL_Test(); + + while(1){} +} + + +#endif diff --git a/87400/usr/validation/src/val_m0.c b/87400/usr/validation/src/val_m0.c new file mode 100644 index 0000000..7801a9e --- /dev/null +++ b/87400/usr/validation/src/val_m0.c @@ -0,0 +1,17 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 + + +#include + + + +void validate_m0(void) +{ + + + +} + + +#endif diff --git a/87400/usr/validation/src/val_mux.c b/87400/usr/validation/src/val_mux.c new file mode 100644 index 0000000..2efc6e6 --- /dev/null +++ b/87400/usr/validation/src/val_mux.c @@ -0,0 +1,149 @@ +/** + * @copyright 2015 Indie Semiconductor. + * + * This file is proprietary to Indie Semiconductor. + * All rights reserved. Reproduction or distribution, in whole + * or in part, is forbidden except by express written permission + * of Indie Semiconductor. + * + * @file val_mux.c + * @Author: Winter.Yuan + * @E-mail:winter.yuan@indiemicro.com + * @Date: 2023/03/15 + */ + + + +#include +#if ENABLE_FUNCTION_VALIDATION == 1 + + +#include +#include + + +void DigitalTestMux_OutputSelect(Test_Mux_Port_t port, Test_Mux_Select_t mode) +{ + if(port == TEST_MUX0_PC3){ + //no pullup no pulldown + IOCTRLA_SFRS->CTRL_MODE[GROUP_GPIOC].PU &= ~(1U << (uint8_t)GPIO_PORT_3); + IOCTRLA_SFRS->CTRL_MODE[GROUP_GPIOC].PD &= ~(1U << (uint8_t)GPIO_PORT_3); + //mode config 1 + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOC] &= ~(0x0FUL << (4U*(uint8_t)GPIO_PORT_3)); + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOC] |= (0x01UL << (4U*(uint8_t)GPIO_PORT_3)); + //select output signal + IOCTRLA_SFRS->TESTMUX.TESTMUX0 = (uint8_t)mode; + } + + if(port == TEST_MUX1_PB1){ + //no pullup no pulldown + IOCTRLA_SFRS->CTRL_MODE[GROUP_GPIOB].PU &= ~(1U << (uint8_t)GPIO_PORT_1); + IOCTRLA_SFRS->CTRL_MODE[GROUP_GPIOB].PD &= ~(1U << (uint8_t)GPIO_PORT_1); + //mode config 1 + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOB] &= ~(0x0FUL << (4U*(uint8_t)GPIO_PORT_1)); + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOB] |= (0x01UL << (4U*(uint8_t)GPIO_PORT_1)); + //select output signal + IOCTRLA_SFRS->TESTMUX.TESTMUX1 = (uint8_t)mode; + } + + + if(port == TEST_MUX2_PB4){ + //no pullup no pulldown + IOCTRLA_SFRS->CTRL_MODE[GROUP_GPIOB].PU &= ~(1U << (uint8_t)GPIO_PORT_4); + IOCTRLA_SFRS->CTRL_MODE[GROUP_GPIOB].PD &= ~(1U << (uint8_t)GPIO_PORT_4); + //mode config 1 + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOB] &= ~(0x0FUL << (4U*(uint8_t)GPIO_PORT_4)); + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOB] |= (0x01UL << (4U*(uint8_t)GPIO_PORT_4)); + //select output signal + IOCTRLA_SFRS->TESTMUX.TESTMUX2 = (uint8_t)mode; + } + + + if(port == TEST_MUX3_PB7){ + //no pullup no pulldown + IOCTRLA_SFRS->CTRL_MODE[GROUP_GPIOB].PU &= ~(1U << (uint8_t)GPIO_PORT_7); + IOCTRLA_SFRS->CTRL_MODE[GROUP_GPIOB].PD &= ~(1U << (uint8_t)GPIO_PORT_7); + //mode config 1 + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOB] &= ~(0x0FUL << (4U*(uint8_t)GPIO_PORT_7)); + IOCTRLA_SFRS->PORT_GROUP_MUX[GROUP_GPIOB] |= (0x01UL << (4U*(uint8_t)GPIO_PORT_7)); + //select output signal + IOCTRLA_SFRS->TESTMUX.TESTMUX3 = (uint8_t)mode; + } + + +} + + + +void AnalogTestMux_OutputSelect(AnalogTest_Mux_Port_t port, AnalogTest_Mux_Select_t mode) +{ + + + if(port == ANA_MUX_PB4){ + //no pullup no pulldown + IOCTRLA_SFRS->CTRL_MODE[GROUP_GPIOB].PU &= ~(1U << (uint8_t)GPIO_PORT_4); + IOCTRLA_SFRS->CTRL_MODE[GROUP_GPIOB].PD &= ~(1U << (uint8_t)GPIO_PORT_4); + } + if(port == ANA_MUX_PB5){ + //no pullup no pulldown + IOCTRLA_SFRS->CTRL_MODE[GROUP_GPIOB].PU &= ~(1U << (uint8_t)GPIO_PORT_5); + IOCTRLA_SFRS->CTRL_MODE[GROUP_GPIOB].PD &= ~(1U << (uint8_t)GPIO_PORT_5); + } + if(port == ANA_MUX_PB7){ + //no pullup no pulldown + IOCTRLA_SFRS->CTRL_MODE[GROUP_GPIOB].PU &= ~(1U << (uint8_t)GPIO_PORT_7); + IOCTRLA_SFRS->CTRL_MODE[GROUP_GPIOB].PD &= ~(1U << (uint8_t)GPIO_PORT_7); + } + + + IOCTRLA_SFRS->ANALOGTESTMUXOVERRIDE.ANASELREG = (uint16_t)port; + IOCTRLA_SFRS->ANALOGTESTMUXOVERRIDE.GPIOCONREG = (uint16_t)mode; + IOCTRLA_SFRS->ANALOGTESTMUXOVERRIDE.GPIOCONSEL = 1; +} + + + + + +void validate_mux(void) +{ +// DigitalTestMux_OutputSelect(TEST_MUX0_PC3, TEST_MUX_HFRC); +// DigitalTestMux_OutputSelect(TEST_MUX1_PB1, TEST_MUX_HFRC); +// DigitalTestMux_OutputSelect(TEST_MUX2_PB4, TEST_MUX_HFRC); +// DigitalTestMux_OutputSelect(TEST_MUX3_PB7, TEST_MUX_HFRC); +// +// DigitalTestMux_OutputSelect(TEST_MUX0_PC3, TEST_MUX_LFRC); +// DigitalTestMux_OutputSelect(TEST_MUX1_PB1, TEST_MUX_LFRC); +// DigitalTestMux_OutputSelect(TEST_MUX2_PB4, TEST_MUX_LFRC); +// DigitalTestMux_OutputSelect(TEST_MUX3_PB7, TEST_MUX_LFRC); +// +// +// DigitalTestMux_OutputSelect(TEST_MUX0_PC3, TEST_MUX_SYSCLOCK); +// DigitalTestMux_OutputSelect(TEST_MUX1_PB1, TEST_MUX_SYSCLOCK); +// DigitalTestMux_OutputSelect(TEST_MUX2_PB4, TEST_MUX_SYSCLOCK); +// DigitalTestMux_OutputSelect(TEST_MUX3_PB7, TEST_MUX_SYSCLOCK); +// + + + AnalogTestMux_OutputSelect(ANA_MUX_PB4, TEST_MUX_PB4_VDD3V3_1_2); + AnalogTestMux_OutputSelect(ANA_MUX_PB4, TEST_MUX_PB4_VDD1V5_1_1); + AnalogTestMux_OutputSelect(ANA_MUX_PB4, TEST_MUX_PB4_PRE5V_1_4); + AnalogTestMux_OutputSelect(ANA_MUX_PB4, TEST_MUX_PB4_EXT3V3_1_2); + + + AnalogTestMux_OutputSelect(ANA_MUX_PB5, TEST_MUX_PB5_VBG_BUF); + AnalogTestMux_OutputSelect(ANA_MUX_PB5, TEST_MUX_PB5_VBG_1P2); + AnalogTestMux_OutputSelect(ANA_MUX_PB5, TEST_MUX_PB5_VBG_1P1); + AnalogTestMux_OutputSelect(ANA_MUX_PB5, TEST_MUX_PB5_TEMPSENSOR); + AnalogTestMux_OutputSelect(ANA_MUX_PB5, TEST_MUX_PB5_ADCREFERENCE); + AnalogTestMux_OutputSelect(ANA_MUX_PB5, TEST_MUX_PB5_BORREFERENCE); + + + AnalogTestMux_OutputSelect(ANA_MUX_PB7, TEST_MUX_PB7_CSA_FILTEROUT); + AnalogTestMux_OutputSelect(ANA_MUX_PB7, TEST_MUX_PB7_CSA_OUT); + AnalogTestMux_OutputSelect(ANA_MUX_PB7, TEST_MUX_PB7_DAC_OUT); + +} + + +#endif diff --git a/87400/usr/validation/src/val_pmu.c b/87400/usr/validation/src/val_pmu.c new file mode 100644 index 0000000..5efa40d --- /dev/null +++ b/87400/usr/validation/src/val_pmu.c @@ -0,0 +1,66 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 +#include +#include +#include +#include +#include + + + +void PMU_EXT3V3LDO_Test(void) +{ + //test EXT3V3LDO enable and disable + //test EXT3V3LDO discharge function + + TRIMHV_SFRS->BORTESTMODE.DISCHARGE_VDD33EXT = 0; + TRIMHV_SFRS->BORTESTMODE.VDD33EXT_EN = 1; + TRIMHV_SFRS->BORTESTMODE.VDD33EXT_EN = 0; + TRIMHV_SFRS->BORTESTMODE.VDD33EXT_EN = 1; + TRIMHV_SFRS->BORTESTMODE.VDD33EXT_EN = 0; + TRIMHV_SFRS->BORTESTMODE.VDD33EXT_EN = 1; + TRIMHV_SFRS->BORTESTMODE.VDD33EXT_EN = 0; + + TRIMHV_SFRS->BORTESTMODE.DISCHARGE_VDD33EXT = 1; + TRIMHV_SFRS->BORTESTMODE.VDD33EXT_EN = 1; + TRIMHV_SFRS->BORTESTMODE.VDD33EXT_EN = 0; + TRIMHV_SFRS->BORTESTMODE.VDD33EXT_EN = 1; + TRIMHV_SFRS->BORTESTMODE.VDD33EXT_EN = 0; + TRIMHV_SFRS->BORTESTMODE.VDD33EXT_EN = 1; + TRIMHV_SFRS->BORTESTMODE.VDD33EXT_EN = 0; + + + + while(1){ + + } + +} + +void PMU_EXT3V3LDO_Trim_Test(void) +{ + //test EXT3V3LDO voltage trim function + + TRIMHV_SFRS->BORTESTMODE.DISCHARGE_VDD33EXT = 1; + TRIMHV_SFRS->BORTESTMODE.VDD33EXT_EN = 1; + + for(uint8_t i=0;i<16;i++){ + TRIMHV_SFRS->BORTESTMODE.VDD3V3EXT_LDO_TRIM = i; + } + + while(1){ + + } + +} + + + +void validate_pmu(void) +{ + //PMU_EXT3V3LDO_Test(); + PMU_EXT3V3LDO_Trim_Test(); +} + + +#endif diff --git a/87400/usr/validation/src/val_power.c b/87400/usr/validation/src/val_power.c new file mode 100644 index 0000000..0746421 --- /dev/null +++ b/87400/usr/validation/src/val_power.c @@ -0,0 +1,31 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 + + +#include +#include +#include +#include + + + +void Bandgap_Trim_Test(void) +{ + +} + + + +void validate_power(void) +{ + + + while(1){ + + } + + +} + + +#endif diff --git a/87400/usr/validation/src/val_pwm.c b/87400/usr/validation/src/val_pwm.c new file mode 100644 index 0000000..7889328 --- /dev/null +++ b/87400/usr/validation/src/val_pwm.c @@ -0,0 +1,17 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 + + +#include + + + +void validate_pwm(void) +{ + + + +} + + +#endif diff --git a/87400/usr/validation/src/val_pwmaux.c b/87400/usr/validation/src/val_pwmaux.c new file mode 100644 index 0000000..357d3be --- /dev/null +++ b/87400/usr/validation/src/val_pwmaux.c @@ -0,0 +1,80 @@ +#include +//#if ENABLE_FUNCTION_VALIDATION == 1 +#include +#include +#include +#include + + + +void PWM_AUX_Test(void) +{ + PWMAUX_GPIO_Init(GROUP_GPIOA,GPIO_PORT_5);//0 + PWMAUX_GPIO_Init(GROUP_GPIOB,GPIO_PORT_0);//1 + PWMAUX_GPIO_Init(GROUP_GPIOB,GPIO_PORT_1);//2 + PWMAUX_GPIO_Init(GROUP_GPIOB,GPIO_PORT_3);//3 + + PWMAUX_GPIO_Init(GROUP_GPIOA,GPIO_PORT_2);//5 + + + PWMAUX_Init(PWMAUX_CHANNEL_0, PWMAUX_BASE_0, PWMAUX_CLK_DIV_1, 5); + PWMAUX_SetMatchValue(PWMAUX_CHANNEL_0, 0, 1); + + PWMAUX_Init(PWMAUX_CHANNEL_1, PWMAUX_BASE_0, PWMAUX_CLK_DIV_1, 5); + PWMAUX_SetMatchValue(PWMAUX_CHANNEL_1, 0, 2); + + PWMAUX_Init(PWMAUX_CHANNEL_2, PWMAUX_BASE_0, PWMAUX_CLK_DIV_1, 5); + PWMAUX_SetMatchValue(PWMAUX_CHANNEL_2, 0, 3); + + PWMAUX_Init(PWMAUX_CHANNEL_3, PWMAUX_BASE_0, PWMAUX_CLK_DIV_1, 5); + PWMAUX_SetMatchValue(PWMAUX_CHANNEL_3, 0, 4); + + + PWMAUX_Init(PWMAUX_CHANNEL_5, PWMAUX_BASE_1, PWMAUX_CLK_DIV_1, 10); + PWMAUX_SetMatchValue(PWMAUX_CHANNEL_4, 0, 1); + + while(1){ + + } +} + +void GPIOB0_Toggle(void) +{ + static uint8_t index = 0U; + if (index == 0U){ + index = 1U; + GPIO_SFRS->GPIO_SET[1].DATASET = 1; + }else{ + index = 0; + GPIO_SFRS->GPIO_SET[1].DATACLR = 1; + } +} + +void PWM_AUX_IRQ_Test(void) +{ + //DigitalTestMux_OutputSelect(TEST_MUX1_PB1, TEST_MUX_HFRC); + + + GPIO_Init(GROUP_GPIOB, GPIO_PORT_0, GPIO_DIR_OUTPUT, GPIO_PULL_NONE); + + PWMAUX_GPIO_Init(GROUP_GPIOA,GPIO_PORT_5);//0 + PWMAUX_RegisterReloadIRQ(PWMAUX_BASE_0,GPIOB0_Toggle); + PWMAUX_SetMatchValue(PWMAUX_CHANNEL_0, 0, 1); + PWMAUX_Init(PWMAUX_CHANNEL_0, PWMAUX_BASE_0, PWMAUX_CLK_DIV_1, 2000); + while(1){ + + } + +} + +void validate_pwmaux(void) +{ + + //PWM_AUX_Test(); + //PWM_AUX_IRQ_Test(); + + +} + + +//#endif diff --git a/87400/usr/validation/src/val_spi.c b/87400/usr/validation/src/val_spi.c new file mode 100644 index 0000000..f156f17 --- /dev/null +++ b/87400/usr/validation/src/val_spi.c @@ -0,0 +1,36 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 + +#include +#include +#include +#include + + + +void SPI_Wave_Test(void) +{ + + +} +void SPI_W25Q32_Test(void) +{ + //read Flash-ID + + while(1) + { + } +} + + + + +void validate_spi(void) +{ + //SPI_Wave_Test(); + SPI_W25Q32_Test(); + +} + + +#endif diff --git a/87400/usr/validation/src/val_system.c b/87400/usr/validation/src/val_system.c new file mode 100644 index 0000000..2351223 --- /dev/null +++ b/87400/usr/validation/src/val_system.c @@ -0,0 +1,55 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 + + +#include +#include +#include + +//BY Winter.Yuan +void Check_SystemStartUpStatus(void) +{ + //POR Flag + //WDTA Flag + //Other WAKEUP Flag + //Retain Reg + + +} + + +//BY Winter.Yuan +void SoftWareReset_Request_Test(void) +{ + DEBUG_OUT("----------SoftWareReset-Request----------------\r\n"); + //CRGA_SFRS->RESETCTRL.SOFTRSTREQ = 1; + delay(0x100); + delay(0x100); +} +//BY Winter.Yuan +void HardWareReset_Request_Test(void) +{ + DEBUG_OUT("----------HardWareReset-Request----------------\r\n"); + //CRGA_SFRS->RESETCTRL.HARDRSTREQ = 1; + delay(0x100); + delay(0x100); +} + + + + +void validate_system(void) +{ + //SoftWareReset_Request_Test(); + //HardWareReset_Request_Test(); + + + DigitalTestMux_OutputSelect(TEST_MUX3_PB7, TEST_MUX_SYSCLOCK); + + + + +} + + +#endif diff --git a/87400/usr/validation/src/val_tempsensor.c b/87400/usr/validation/src/val_tempsensor.c new file mode 100644 index 0000000..23692dd --- /dev/null +++ b/87400/usr/validation/src/val_tempsensor.c @@ -0,0 +1,35 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 +#include +#include + + + + +void TempSensor_Hibernate_Test(void) +{ + + + while(1){ + + } + +} + + + + +void validate_tempsensor(void) +{ + //TempSensor_Hibernate_Test(); + //TempSensor_OverTemp_Test(); + + + + while(1){ + + } +} + + +#endif diff --git a/87400/usr/validation/src/val_timer.c b/87400/usr/validation/src/val_timer.c new file mode 100644 index 0000000..e7119ef --- /dev/null +++ b/87400/usr/validation/src/val_timer.c @@ -0,0 +1,17 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 + + +#include + + + +void validate_gtimer(void) +{ + + + +} + + +#endif diff --git a/87400/usr/validation/src/val_uart.c b/87400/usr/validation/src/val_uart.c new file mode 100644 index 0000000..7881c2f --- /dev/null +++ b/87400/usr/validation/src/val_uart.c @@ -0,0 +1,29 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 + +#include +#include +#include +#include + +void validate_uart(void) +{ + uint8_t cnt=0; + UART_Init(BAUDRATE_9600, BITSIZE_8BITS, PARITY_NONE, STOPS_1BITS); + delay(0x100); + DEBUG_OUT("-------------validate_uart---------------\r\n"); + + + while(1) + { + delay(0x10); + DEBUG_OUT("------------%02X---------------\r\n",cnt); + cnt++; + + } + + +} + + +#endif diff --git a/87400/usr/validation/src/val_wdta.c b/87400/usr/validation/src/val_wdta.c new file mode 100644 index 0000000..71022f7 --- /dev/null +++ b/87400/usr/validation/src/val_wdta.c @@ -0,0 +1,25 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 +#include + +#include + +//BY Winter.Yuan +void WDT_Reset_Test(void) +{ + WDTA_Enable(WDTA_INTERVAL_1152MS); + while(1) + { + + } +} + +void validate_wdta(void) +{ + + WDT_Reset_Test(); + +} + + +#endif diff --git a/87400/usr/validation/src/validation.c b/87400/usr/validation/src/validation.c new file mode 100644 index 0000000..aec8fa2 --- /dev/null +++ b/87400/usr/validation/src/validation.c @@ -0,0 +1,84 @@ +#include +#if ENABLE_FUNCTION_VALIDATION == 1 + +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + + +void validation_main(void) +{ + Clock_SystemMainClockInit(CLOCK_DIV_1); + + delay(100); + delay(100); + + + SYSCTRLA_SFRS->DEBUG_ACCESS_KEY.DEBUG_ACCESS_KEY = 0x05; + while(SYSCTRLA_SFRS->DEBUG_ACCESS_ENABLED == 0); + + SYSCTRLA_SFRS->TRIM_ACCESS_KEY.TRIM_ACCESS_KEY = 0x0E; + while(SYSCTRLA_SFRS->TRIM_ACCESS_ENABLED == 0); + + + SYSCTRLA_SFRS->PMU_ACCESS_KEY.PMU_ACCESS_KEY = 0x0A; + while(SYSCTRLA_SFRS->PMU_ACCESS_ENABLED == 0); + + + + +// validate_lins(); +// validate_wdta(); +// validate_uart(); +// validate_tempsensor(); +// validate_system(); +// validate_pwmaux(); +// validate_pwm(); +// validate_mux(); +// validate_flash(); + validate_clock(); +// validate_adc(); +// validate_pmu(); +// validate_spi(); +// validate_gpio(); + + + while(1) + { + + } + +} + + + + +#endif