diff --git a/emBODY/eBcode/arch-arm/board/mtb4/application/proj/eventviewer-stm32-cfg.ini b/emBODY/eBcode/arch-arm/board/mtb4/application/proj/eventviewer-stm32-cfg.ini index 9491f80da..cf42ead30 100644 --- a/emBODY/eBcode/arch-arm/board/mtb4/application/proj/eventviewer-stm32-cfg.ini +++ b/emBODY/eBcode/arch-arm/board/mtb4/application/proj/eventviewer-stm32-cfg.ini @@ -12,11 +12,11 @@ FUNC void DebugSetup (void) { - _WDWORD(0x40023830, _RDWORD(0x40023830) | 0x00000010); // RCC_AHB1ENR: IO port E clock enable - _WDWORD(0x40021000, 0x00002AA0); // GPIOE_MODER: PE2..PE6 = Alternate function mode - _WDWORD(0x40021008, 0x00003FF0); // GPIOE_OSPEEDR: PE2..PE6 = 100 MHz speed - _WDWORD(0x4002100C, 0x00000000); // GPIOE_PUPDR: PE2..PE6 = No Pull-up/Pull-down - _WDWORD(0x40021020, 0x00000000); // GPIOE_AFRL: PE2..PE6 = AF0 +// _WDWORD(0x40023830, _RDWORD(0x40023830) | 0x00000010); // RCC_AHB1ENR: IO port E clock enable +// _WDWORD(0x40021000, 0x00002AA0); // GPIOE_MODER: PE2..PE6 = Alternate function mode +// _WDWORD(0x40021008, 0x00003FF0); // GPIOE_OSPEEDR: PE2..PE6 = 100 MHz speed +// _WDWORD(0x4002100C, 0x00000000); // GPIOE_PUPDR: PE2..PE6 = No Pull-up/Pull-down +// _WDWORD(0x40021020, 0x00000000); // GPIOE_AFRL: PE2..PE6 = AF0 // Debug MCU Configuration // DBG_SLEEP Debug Sleep Mode @@ -29,37 +29,37 @@ FUNC void DebugSetup (void) { // <2=> Synchronous: TRACEDATA Size 2 // <3=> Synchronous: TRACEDATA Size 4 // - _WDWORD(0xE0042004, 0x00000027); // DBGMCU_CR +// _WDWORD(0xE0042004, 0x00000027); // DBGMCU_CR -// Debug MCU APB1 Freeze -// DBG_TIM2_STOP Timer 2 Stopped when Core is halted -// DBG_TIM3_STOP Timer 3 Stopped when Core is halted -// DBG_TIM4_STOP Timer 4 Stopped when Core is halted -// DBG_TIM5_STOP Timer 5 Stopped when Core is halted -// DBG_TIM6_STOP Timer 6 Stopped when Core is halted -// DBG_TIM7_STOP Timer 7 Stopped when Core is halted -// DBG_TIM12_STOP Timer 12 Stopped when Core is halted -// DBG_TIM13_STOP Timer 13 Stopped when Core is halted -// DBG_TIM14_STOP Timer 14 Stopped when Core is halted -// DBG_RTC_STOP RTC Stopped when Core is halted -// DBG_WWDG_STOP Window Watchdog Stopped when Core is halted -// DBG_IWDG_STOP Independent Watchdog Stopped when Core is halted -// DBG_I2C1_SMBUS_TIMEOUT I2C1 SMBUS Timeout Mode Stopped when Core is halted -// DBG_I2C2_SMBUS_TIMEOUT I2C2 SMBUS Timeout Mode Stopped when Core is halted -// DBG_I2C3_SMBUS_TIMEOUT I2C3 SMBUS Timeout Mode Stopped when Core is halted -// DBG_CAN1_STOP CAN1 Stopped when Core is halted -// DBG_CAN2_STOP CAN2 Stopped when Core is halted -// - _WDWORD(0xE0042008, 0x06E01DFF); // DBGMCU_APB1_FZ +//// Debug MCU APB1 Freeze +//// DBG_TIM2_STOP Timer 2 Stopped when Core is halted +//// DBG_TIM3_STOP Timer 3 Stopped when Core is halted +//// DBG_TIM4_STOP Timer 4 Stopped when Core is halted +//// DBG_TIM5_STOP Timer 5 Stopped when Core is halted +//// DBG_TIM6_STOP Timer 6 Stopped when Core is halted +//// DBG_TIM7_STOP Timer 7 Stopped when Core is halted +//// DBG_TIM12_STOP Timer 12 Stopped when Core is halted +//// DBG_TIM13_STOP Timer 13 Stopped when Core is halted +//// DBG_TIM14_STOP Timer 14 Stopped when Core is halted +//// DBG_RTC_STOP RTC Stopped when Core is halted +//// DBG_WWDG_STOP Window Watchdog Stopped when Core is halted +//// DBG_IWDG_STOP Independent Watchdog Stopped when Core is halted +//// DBG_I2C1_SMBUS_TIMEOUT I2C1 SMBUS Timeout Mode Stopped when Core is halted +//// DBG_I2C2_SMBUS_TIMEOUT I2C2 SMBUS Timeout Mode Stopped when Core is halted +//// DBG_I2C3_SMBUS_TIMEOUT I2C3 SMBUS Timeout Mode Stopped when Core is halted +//// DBG_CAN1_STOP CAN1 Stopped when Core is halted +//// DBG_CAN2_STOP CAN2 Stopped when Core is halted +//// +// _WDWORD(0xE0042008, 0x06E01DFF); // DBGMCU_APB1_FZ -// Debug MCU APB2 Freeze -// DBG_TIM1_STOP Timer 1 Stopped when Core is halted -// DBG_TIM8_STOP Timer 8 Stopped when Core is halted -// DBG_TIM9_STOP Timer 9 Stopped when Core is halted -// DBG_TIM10_STOP Timer 10 Stopped when Core is halted -// DBG_TIM11_STOP Timer 11 Stopped when Core is halted -// - _WDWORD(0xE004200C, 0x00070003); // DBGMCU_APB2_FZ +//// Debug MCU APB2 Freeze +//// DBG_TIM1_STOP Timer 1 Stopped when Core is halted +//// DBG_TIM8_STOP Timer 8 Stopped when Core is halted +//// DBG_TIM9_STOP Timer 9 Stopped when Core is halted +//// DBG_TIM10_STOP Timer 10 Stopped when Core is halted +//// DBG_TIM11_STOP Timer 11 Stopped when Core is halted +//// +// _WDWORD(0xE004200C, 0x00070003); // DBGMCU_APB2_FZ } diff --git a/emBODY/eBcode/arch-arm/board/mtb4/application/proj/mtb4-application-v6.uvoptx b/emBODY/eBcode/arch-arm/board/mtb4/application/proj/mtb4-application-v6.uvoptx index c107fc746..54e7ed536 100644 --- a/emBODY/eBcode/arch-arm/board/mtb4/application/proj/mtb4-application-v6.uvoptx +++ b/emBODY/eBcode/arch-arm/board/mtb4/application/proj/mtb4-application-v6.uvoptx @@ -410,17 +410,17 @@ 0 UL2CM3 - UL2CM3(-S0 -C0 -P0 ) -FN1 -FC1000 -FD20000000 -FF0STM32L4xx_256 -FL040000 -FS08000000 -FP0($$Device:STM32L433RCTx$CMSIS\Flash\STM32L4xx_256.FLM) + -UAny -O206 -S8 -C0 -P00 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO65555 -TC40000000 -TT10000000 -TP21 -TDS801F -TDT0 -TDC1F -TIE80000001 -TIP9 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32L4xx_256.FLM -FS08000000 -FL040000 -FP0($$Device:STM32L433RCTx$CMSIS\Flash\STM32L4xx_256.FLM) 0 ULP2CM3 - -UAny -O206 -S8 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP18 -TDX0 -TDD0 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32L4xx_256.FLM -FS08000000 -FL040000 -FP0($$Device:STM32L433RCTx$CMSIS\Flash\STM32L4xx_256.FLM) + -UP1123153 -O206 -S8 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO98323 -TC40000000 -TT10000000 -TP18 -TDX0 -TDD0 -TDS8000 -TDT0 -TDC1F -TIE80000001 -TIP9 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32L4xx_256.FLM -FS08000000 -FL040000 -FP0($$Device:STM32L433RCTx$CMSIS\Flash\STM32L4xx_256.FLM) 0 ARMRTXEVENTFLAGS - -L70 -Z18 -C0 -M0 -T1 + -L200 -Z18 -C0 -M1 -T1 0 @@ -442,50 +442,34 @@ 0 0 - 212 + 263 1 -
134402072
+
134422882
0 0 0 0 0 1 - ..\..\..\..\..\..\eBcode\arch-arm\embot\app\embot_app_application_theIMU.cpp + ..\src\others\AD7147.c - \\\../../../../../../eBcode/arch-arm/embot/app/embot_app_application_theIMU.cpp\212 + \\mtb4_a\../src/others/AD7147.c\263
1 - 0 - 87 + 2 + 0 1 -
0
- 0 +
536890767
+ 1 0 - 0 - 0 - 0 + 1 + 1 + 2 1 - ..\..\bsp\embot_hw_bsp_mtb4.cpp + - \\mtb4_v190\../../bsp/embot_hw_bsp_mtb4.cpp\87 -
- - 2 - 0 - 84 - 1 -
134423098
- 0 - 0 - 0 - 0 - 0 - 1 - ../src/main-appcan.cpp - - \\mtb4_v190\../src/main-appcan.cpp\84 + 0x20004D8F
@@ -494,6 +478,41 @@ 1 SystemCoreClock/1000000,0x0A + + 1 + 1 + the12rawvalues + + + 2 + 1 + SKV,0x0A + + + 3 + 1 + rawvalues5th + + + 4 + 1 + taxsel0 + + + 5 + 1 + taxsel4 + + + 6 + 1 + taxsel5 + + + 7 + 1 + dbg + @@ -516,12 +535,17 @@ 2 s_AD7147Registers[3] + + 4 + 2 + taxsel120 + 1 0 - 0x20003E7E + s_AD7147Registers_5th 0 @@ -529,10 +553,18 @@ 2 0 - the12capoffsets + ext_capoffsets5th 0 + + + 3 + 0 + s_CapOffset_5th + 0 + + 0 @@ -552,13 +584,13 @@ 0 0 0 - 0 - 0 + 1 + 1 0 0 0 0 - 0 + 1 0 0 @@ -575,6 +607,13 @@ + + + 0 + `SKV + FF0000000000000000000000000000000000494000000000000000000000000000000000534B5600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F1700000000000000000000000000000000000000D60A0308 + + 1 1 @@ -587,7 +626,7 @@ main - 0 + 1 0 0 0 @@ -683,7 +722,7 @@ rtos - 0 + 1 0 0 0 @@ -715,7 +754,7 @@ embot-core - 0 + 1 0 0 0 @@ -843,7 +882,7 @@ embot-app-protocol - 0 + 1 0 0 0 @@ -1015,7 +1054,7 @@ embot-application - 0 + 1 0 0 0 @@ -1131,7 +1170,7 @@ embot-hw - 0 + 1 0 0 0 @@ -1319,7 +1358,7 @@ other-hw - 0 + 1 0 0 0 @@ -1395,7 +1434,7 @@ embot::hw::bsp - 0 + 1 0 0 0 diff --git a/emBODY/eBcode/arch-arm/board/mtb4/application/proj/mtb4-application-v6.uvprojx b/emBODY/eBcode/arch-arm/board/mtb4/application/proj/mtb4-application-v6.uvprojx index a49206dfa..876018df5 100644 --- a/emBODY/eBcode/arch-arm/board/mtb4/application/proj/mtb4-application-v6.uvprojx +++ b/emBODY/eBcode/arch-arm/board/mtb4/application/proj/mtb4-application-v6.uvprojx @@ -16,8 +16,8 @@ STM32L433RCTx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.7.0 + https://www.keil.com/pack/ IRAM(0x20000000,0x0000C000) IRAM2(0x10000000,0x00004000) IROM(0x08000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 DSP CLOCK(12000000) ELITTLE @@ -873,14 +873,15 @@ mtb4-v1D3 0x4 ARM-ADS - 6190000::V6.19::ARMCLANG + 6190000::V6.19::.\armclang-r6p19-00rel0 + 6190000::V6.19::.\armclang-r6p19-00rel0 1 STM32L433RCTx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.7.0 + https://www.keil.com/pack/ IRAM(0x20000000,0x0000C000) IRAM2(0x10000000,0x00004000) IROM(0x08000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 DSP CLOCK(12000000) ELITTLE @@ -945,7 +946,7 @@ 1 0 - cmd.exe /C copy .\Obj\mtb4_a.hex ..\bin\mtb4.v1D3.hex + cmd.exe /C copy .\Obj\mtb4_a.hex ..\bin\mtb4_hand5_1.v1D3.hex 0 0 diff --git a/emBODY/eBcode/arch-arm/board/mtb4/bootloader/proj/mtb4-bootloader-v6.uvprojx b/emBODY/eBcode/arch-arm/board/mtb4/bootloader/proj/mtb4-bootloader-v6.uvprojx index 9bc8d6f29..06b2eed89 100644 --- a/emBODY/eBcode/arch-arm/board/mtb4/bootloader/proj/mtb4-bootloader-v6.uvprojx +++ b/emBODY/eBcode/arch-arm/board/mtb4/bootloader/proj/mtb4-bootloader-v6.uvprojx @@ -16,8 +16,8 @@ STM32L433RCTx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.2.0 + http://www.keil.com/pack IRAM(0x20000000,0x0000C000) IRAM2(0x10000000,0x00004000) IROM(0x08000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 DSP CLOCK(12000000) ELITTLE @@ -824,8 +824,8 @@ STM32L433RCTx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.2.0 + http://www.keil.com/pack IRAM(0x20000000,0x0000C000) IRAM2(0x10000000,0x00004000) IROM(0x08000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 DSP CLOCK(12000000) ELITTLE diff --git a/emBODY/eBcode/arch-arm/board/mtb4c/application/proj/mtb4c-application-v6.uvoptx b/emBODY/eBcode/arch-arm/board/mtb4c/application/proj/mtb4c-application-v6.uvoptx index 83939336b..631570a71 100644 --- a/emBODY/eBcode/arch-arm/board/mtb4c/application/proj/mtb4c-application-v6.uvoptx +++ b/emBODY/eBcode/arch-arm/board/mtb4c/application/proj/mtb4c-application-v6.uvoptx @@ -350,7 +350,7 @@ 0 ST-LINKIII-KEIL_SWO - -U50FF71067871515212360467 -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("") -D00(00000000) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC8000 -FN1 -FF0STM32L4xx_256.FLM -FS08000000 -FL040000 -FP0($$Device:STM32L452RCIx$CMSIS\Flash\STM32L4xx_256.FLM) + -U0055002D3331511334333834 -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC8000 -FN1 -FF0STM32L4xx_256.FLM -FS08000000 -FL040000 -FP0($$Device:STM32L452RCIx$CMSIS\Flash\STM32L4xx_256.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2 0 @@ -360,7 +360,7 @@ 0 ULP2CM3 - -UAny -O206 -S8 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP18 -TDX0 -TDD0 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC8000 -FN1 -FF0STM32L4xx_256.FLM -FS08000000 -FL040000 -FP0($$Device:STM32L452RCIx$CMSIS\Flash\STM32L4xx_256.FLM) + -UP1123153 -O206 -S8 -C0 -P00000000 -N00("") -D00(00000000) -L00(0) -TO65554 -TC20000000 -TT10000000 -TP18 -TDX0 -TDD0 -TDS8000 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC8000 -FN1 -FF0STM32L4xx_256.FLM -FS08000000 -FL040000 -FP0($$Device:STM32L452RCIx$CMSIS\Flash\STM32L4xx_256.FLM) 0 @@ -387,6 +387,22 @@ 0 0 + 234 + 1 +
0
+ 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\..\..\..\eBcode\arch-arm\embot\app\embot_app_application_theSkin.cpp + + +
+ + 1 + 0 0 1
12
@@ -401,7 +417,7 @@ 0x0000000C
- 1 + 2 0 1 1 @@ -506,7 +522,7 @@ 1 - 1 + 0 0 2 10000000 @@ -1247,7 +1263,7 @@
- other-hw + embot-hw-lowlevel 0 0 0 @@ -1259,75 +1275,75 @@ 0 0 0 - ..\src\others\AD7147.c - AD7147.c + ..\..\..\..\embot\hw\embot_hw_lowlevel.cpp + embot_hw_lowlevel.cpp 0 0 + + + + embot::hw::bsp + 0 + 0 + 0 + 0 - 10 + 11 57 8 0 0 0 - ..\src\others\I2C_Multi_SDA.c - I2C_Multi_SDA.c + ..\..\bsp\embot_hw_bsp_mtb4c.cpp + embot_hw_bsp_mtb4c.cpp 0 0 + + + + shared-hw + 0 + 0 + 0 + 0 - 10 + 12 58 8 - 0 + 1 0 0 - ..\src\others\AD7147_Configuration.c - AD7147_Configuration.c + ..\..\..\mtb4\application\src\others\AD7147.c + AD7147.c 0 0 - 10 + 12 59 8 0 0 0 - ..\src\others\if2hw_common.c - if2hw_common.c + ..\..\..\mtb4\application\src\others\AD7147_Configuration.c + AD7147_Configuration.c 0 0 - - - - embot-hw-lowlevel - 0 - 0 - 0 - 0 - 11 + 12 60 8 0 0 0 - ..\..\..\..\embot\hw\embot_hw_lowlevel.cpp - embot_hw_lowlevel.cpp + ..\..\..\mtb4\application\src\others\I2C_Multi_SDA.c + I2C_Multi_SDA.c 0 0 - - - - embot::hw::bsp - 0 - 0 - 0 - 0 12 61 @@ -1335,8 +1351,20 @@ 0 0 0 - ..\..\bsp\embot_hw_bsp_mtb4c.cpp - embot_hw_bsp_mtb4c.cpp + ..\..\..\mtb4\application\src\others\if2hw_common.c + if2hw_common.c + 0 + 0 + + + 12 + 62 + 5 + 0 + 0 + 0 + ..\..\..\mtb4\application\src\others\AD7147.h + AD7147.h 0 0 diff --git a/emBODY/eBcode/arch-arm/board/mtb4c/application/proj/mtb4c-application-v6.uvprojx b/emBODY/eBcode/arch-arm/board/mtb4c/application/proj/mtb4c-application-v6.uvprojx index b4bd58d76..63ccaf2d0 100644 --- a/emBODY/eBcode/arch-arm/board/mtb4c/application/proj/mtb4c-application-v6.uvprojx +++ b/emBODY/eBcode/arch-arm/board/mtb4c/application/proj/mtb4c-application-v6.uvprojx @@ -16,8 +16,8 @@ STM32L452RCIx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.7.0 + https://www.keil.com/pack/ IRAM(0x20000000,0x00020000) IRAM2(0x10000000,0x00008000) IROM(0x08000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 DSP CLOCK(12000000) ELITTLE @@ -720,82 +720,6 @@ - - other-hw - - - AD7147.c - 8 - ..\src\others\AD7147.c - - - I2C_Multi_SDA.c - 8 - ..\src\others\I2C_Multi_SDA.c - - - AD7147_Configuration.c - 8 - ..\src\others\AD7147_Configuration.c - - - if2hw_common.c - 8 - ..\src\others\if2hw_common.c - - - 2 - 0 - 0 - 0 - 0 - 2 - 2 - 2 - 2 - 2 - 11 - - - 1 - - - - 2 - 1 - 2 - 2 - 2 - 2 - 2 - 2 - 2 - 2 - 0 - 2 - 2 - 2 - 2 - 2 - 0 - 0 - 2 - 2 - 2 - 2 - 2 - - - - - - - - - - - - embot-hw-lowlevel @@ -936,20 +860,51 @@ + + shared-hw + + + AD7147.c + 8 + ..\..\..\mtb4\application\src\others\AD7147.c + + + AD7147_Configuration.c + 8 + ..\..\..\mtb4\application\src\others\AD7147_Configuration.c + + + I2C_Multi_SDA.c + 8 + ..\..\..\mtb4\application\src\others\I2C_Multi_SDA.c + + + if2hw_common.c + 8 + ..\..\..\mtb4\application\src\others\if2hw_common.c + + + AD7147.h + 5 + ..\..\..\mtb4\application\src\others\AD7147.h + + + mtb4c-v1D3 0x4 ARM-ADS - 6190000::V6.19::ARMCLANG + 6190000::V6.19::.\armclang-r6p19-00rel0 + 6190000::V6.19::.\armclang-r6p19-00rel0 1 STM32L452RCIx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.7.0 + https://www.keil.com/pack/ IRAM(0x20000000,0x00020000) IRAM2(0x10000000,0x00008000) IROM(0x08000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 DSP CLOCK(12000000) ELITTLE @@ -1272,7 +1227,7 @@ -Wno-pragma-pack -Wno-deprecated-register USE_STM32HAL STM32HAL_BOARD_MTB4C STM32HAL_DRIVER_V1D3 - ..\src-plus;..\..\..\..\..\..\eBcode\arch-arm\libs\highlevel\abslayer\osal\api;..\..\..\..\..\..\eBcode\arch-arm\libs\midware\eventviewer\api;..\..\..\..\..\..\eBcode\arch-arm\embobj\core\exec\multitask;..\..\..\..\..\..\..\..\icub-firmware-shared\eth\embobj\core\core;..\..\..\..\..\..\eBcode\arch-arm\libs\lowlevel\stm32hal\api;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\core;..\..\..\..\..\..\eBcode\arch-arm\embot\app;..\..\..\..\..\..\eBcode\arch-arm\embot\i2h;..\..\..\..\..\..\eBcode\arch-arm\embot\hw;..\..\..\..\..\..\eBcode\arch-arm\embot\os;..\..\..\..\..\..\eBcode\arch-arm\embot;..\src\others;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\core;..\..\..\..\..\..\..\..\icub-firmware-shared\can\canProtocolLib;..\..\..\..\embot\app\skeleton;..\..\..\..\embot\prot\can;..\..\bsp + ..\src-plus;..\..\..\..\..\..\eBcode\arch-arm\libs\highlevel\abslayer\osal\api;..\..\..\..\..\..\eBcode\arch-arm\libs\midware\eventviewer\api;..\..\..\..\..\..\eBcode\arch-arm\embobj\core\exec\multitask;..\..\..\..\..\..\..\..\icub-firmware-shared\eth\embobj\core\core;..\..\..\..\..\..\eBcode\arch-arm\libs\lowlevel\stm32hal\api;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\core;..\..\..\..\..\..\eBcode\arch-arm\embot\app;..\..\..\..\..\..\eBcode\arch-arm\embot\i2h;..\..\..\..\..\..\eBcode\arch-arm\embot\hw;..\..\..\..\..\..\eBcode\arch-arm\embot\os;..\..\..\..\..\..\eBcode\arch-arm\embot;..\..\..\mtb4\application\src\others;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\core;..\..\..\..\..\..\..\..\icub-firmware-shared\can\canProtocolLib;..\..\..\..\embot\app\skeleton;..\..\..\..\embot\prot\can;..\..\bsp @@ -1652,82 +1607,6 @@
- - other-hw - - - AD7147.c - 8 - ..\src\others\AD7147.c - - - I2C_Multi_SDA.c - 8 - ..\src\others\I2C_Multi_SDA.c - - - AD7147_Configuration.c - 8 - ..\src\others\AD7147_Configuration.c - - - if2hw_common.c - 8 - ..\src\others\if2hw_common.c - - - 2 - 0 - 0 - 0 - 0 - 2 - 2 - 2 - 2 - 2 - 11 - - - 1 - - - - 2 - 1 - 2 - 2 - 2 - 2 - 2 - 2 - 2 - 2 - 0 - 2 - 2 - 2 - 2 - 2 - 0 - 0 - 2 - 2 - 2 - 2 - 2 - - - - - - - - - - - - embot-hw-lowlevel @@ -1868,6 +1747,36 @@ + + shared-hw + + + AD7147.c + 8 + ..\..\..\mtb4\application\src\others\AD7147.c + + + AD7147_Configuration.c + 8 + ..\..\..\mtb4\application\src\others\AD7147_Configuration.c + + + I2C_Multi_SDA.c + 8 + ..\..\..\mtb4\application\src\others\I2C_Multi_SDA.c + + + if2hw_common.c + 8 + ..\..\..\mtb4\application\src\others\if2hw_common.c + + + AD7147.h + 5 + ..\..\..\mtb4\application\src\others\AD7147.h + + + diff --git a/emBODY/eBcode/arch-arm/board/mtb4c/application/src/others/AD7147.c b/emBODY/eBcode/arch-arm/board/mtb4c/application/src/others/AD7147.c deleted file mode 100644 index 1f3d92322..000000000 --- a/emBODY/eBcode/arch-arm/board/mtb4c/application/src/others/AD7147.c +++ /dev/null @@ -1,282 +0,0 @@ -/****************************************************************************** - * AD7147.c - * - * - * Created on: Oct 29, 2015 - * Board: NUCLEO STML152RET - * Author: mmarco aggiali - * - * Description: This file contains the functions for sending and reading info to the AD7147 Capacitance to Digital Converter - * - * - * Modified: Andrea Mura, marco.accame - * - ******************************************************************************/ - -// -------------------------------------------------------------------------------------------------------------------- -// - external dependencies -// -------------------------------------------------------------------------------------------------------------------- - -#include "if2hw_common.h" - -#include "AD7147_Configuration.h" - -// marco.accame: removed -//#include "stm32l4xx_hal.h" -#include "AD7147RegMap.h" -#include "I2C_Multi_SDA.h" - -// marco.accame: moved into AD7147_Configuration.h to avoid multiple definitions. -//extern void ConfigAD7147(unsigned char Channel, unsigned int i, unsigned int pw_control_val, if2hw_data_ad7147_t * convalue); //i is the number of the triangle -//extern void ConfigAD7147_onSdaX(unsigned char Channel, unsigned char setNum, unsigned char indexInSet, unsigned int pw_control_val, if2hw_data_ad7147_t cdcoffset); - -// marco.accame: moved into AD7147_Configuration.h (also, made it const) -//unsigned char AD7147_ADD[4] = {0x2c, 0x2d, 0x2e, 0x2f}; - -// -------------------------------------------------------------------------------------------------------------------- -// - declaration of extern public interface -// -------------------------------------------------------------------------------------------------------------------- - - -#include "AD7147.h" - -// -------------------------------------------------------------------------------------------------------------------- -// - definition (and initialisation) of extern variables, but better using _get(), _set() -// -------------------------------------------------------------------------------------------------------------------- - -#if !defined(if2hw_common_AD7147_USE_EXTERNALCONTROLTYPES) - -if2hw_data_ad7147_t AD7147Registers[16][12]; // il primo campo rappresenta il numero dei canali (non c'e' +) -if2hw_data_ad7147_t CapOffset[16][12]; - - -#endif - -#if defined(if2hw_common_AD7147_USE_EXTERNALCONTROLTYPES) -#else - -triangle_cfg_t triangle_cfg_list[16]; -error_cap err[16]; - -#endif - - - -// -------------------------------------------------------------------------------------------------------------------- -// - definition (and initialisation) of static variables -// -------------------------------------------------------------------------------------------------------------------- - -static const if2hw_data_ad7147_t PW_CONTROL= 0x0B0; // 0x1B0 for 128 decim -static const if2hw_data_ad7147_t s_ConValue[2]={0x2200, 0x2200}; //offset of the CDC reading - - -#if defined(if2hw_common_AD7147_USE_EXTERNALCONTROLTYPES) -#else -static const unsigned int SHIFT = 2; -#endif - -#if defined(if2hw_common_AD7147_USE_EXTERNALDATA) - -static if2hw_data_ad7147_t (*s_AD7147Registers)[12] = NULL; -static if2hw_data_ad7147_t (*s_CapOffset)[12] = NULL; - -#else - - -static if2hw_data_ad7147_t (*s_AD7147Registers)[12] = AD7147Registers; -static if2hw_data_ad7147_t (*s_CapOffset)[12] = CapOffset; - -#endif - - - -static uint16_t triangleconnectionmask = 0xffff; - - - - -void SetCDCoffsetOnSingleTriangle(uint16_t cdcOffset, unsigned char triangleN) -{ -#if defined(if2hw_common_AD7147_USE_EXTERNALCONTROLTYPES) - - ConfigAD7147_onSdaX(CH0, triangleN/4, triangleN%4, PW_CONTROL, cdcOffset); - -#else - - -// uint16_t cdcOffset_aux = cdcOffset; - //init triangle_cfg_list - unsigned int j=0; - - for(j=0;j= triangles_max_num) - { - return(NULL); - } - return(s_AD7147Registers[trg]); -} - - -extern if2hw_data_ad7147_t * ad7147_get12capoffsetsoftriangle(uint8_t trg) -{ - if(trg >= triangles_max_num) - { - return(NULL); - } - return(s_CapOffset[trg]); -} - - -extern uint8_t ad7147_istriangleconnected(uint8_t trg) -{ - if(trg >= triangles_max_num) - { - return(0); - } - - if(triangleconnectionmask & (0x0001<0) -// { -// cycles--; -// //HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_5); -// // GPIOA->ODR ^= GPIO_PIN_5; //da aggiungere se si ottimizza -// } - -} - -void I2C_Multi_SDA_deInit(unsigned char Channel) { - MCE_0output(); - DE_0output(); - MCO_0_off(); - DO_0off(); -} - -void I2C_Multi_SDA_Init(unsigned char Channel) { - MCE_0output(); - DE_0output(); -} - -void I2C_Multi_SDA_test(unsigned char Channel) { - DE_0output(); - MCO_0_on(); - Wait(I2Cbit); // Wait(I2Cbit); - MCO_0_off(); - DO_0on(); - Wait(I2Cbit); //Wait(I2Cbit); - MCO_0_on(); - DO_0on(); - Wait(I2Cbit); //Wait(I2Cbit); - MCO_0_off(); - DO_0off(); - Wait(I2Cbit); //Wait(I2Cbit); -} - -//--------------------------------- -//WriteAD7147ViaI2C() -//--------------------------------- -//Function that writes one byte via the I2C port . It sends first the device -//address including the write bit, then the register address and finally the -//data. The function returns "1" if successfull otherwise "0". -//-------------------------------------------------------------------------------- -unsigned char WriteByteViaI2C(unsigned char Channel, - unsigned char DeviceAddress, const unsigned char RegisterStartAddress, - unsigned char DataBuffer) { - - unsigned char ByteAddress; - unsigned char AcknError; - unsigned char DeviceAddressHeader; - AcknError = 1; //No error on initialisation - - //Add the write bit to the device address - DeviceAddressHeader = DeviceAddress << 1 | I2C_WR; - //Split the address in two bytes - ByteAddress = RegisterStartAddress & 0xFF; - - //Start the I2C transfer - InitialiseI2CMaster(Channel); - StartI2CMaster(Channel); - //Send device address - if (!SendByteI2CMaster(Channel, DeviceAddressHeader)) { - //Send register address if the acknowledgement is there - if (!SendByteI2CMaster(Channel, ByteAddress)) { - SendByteI2CMaster(Channel, DataBuffer); - - StopI2CMaster(Channel); - AcknError = 0; - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster(Channel); - AcknError = 0; - } - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster(Channel); - AcknError = 0; - } - return (AcknError); -} - -//--------------------------------- -//WriteAD7147ViaI2C() -//--------------------------------- -//Function that writes via the I2C port pair of 16 bits data. It sends first the device -//address including the write bit, then the register address and finally the -//data. The function returns "1" if successfull otherwise "0". -//-------------------------------------------------------------------------------- -unsigned char WriteViaI2C(unsigned char Channel, unsigned char DeviceAddress, - const unsigned int RegisterStartAddress, - const unsigned char NumberOfRegistersToWrite, - if2hw_data_i2cmultisda_t *DataBuffer, const unsigned int OffsetInBuffer) { - - unsigned int DataToWrite; - unsigned char LowByteAddress, HighByteAddress; - unsigned char LowByteData, HighByteData; - unsigned char r, AcknError; - unsigned char DeviceAddressHeader; - - AcknError = 1; //No error on initialisation - - //Add the write bit to the device address - DeviceAddressHeader = DeviceAddress << 1 | I2C_WR; - //Split the address in two bytes - HighByteAddress = (RegisterStartAddress & 0xFF00) >> 8; - LowByteAddress = RegisterStartAddress & 0x00FF; - - //Start the I2C transfer - InitialiseI2CMaster(Channel); - StartI2CMaster(Channel); - //Send device address - if (!SendByteI2CMaster(Channel, DeviceAddressHeader)) { - //Send register address if the acknowledgement is there - if (!SendByteI2CMaster(Channel, HighByteAddress)) { - if (!SendByteI2CMaster(Channel, LowByteAddress)) { - //Perform block write - for (r = 0; r < NumberOfRegistersToWrite; r++) { - DataToWrite = DataBuffer[OffsetInBuffer + r]; - LowByteData = DataToWrite & 0x00FF; - HighByteData = (DataToWrite & 0xFF00) >> 8; - if (!SendByteI2CMaster(Channel, HighByteData)) { - SendByteI2CMaster(Channel, LowByteData); - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster(Channel); - AcknError = 0; - } - } - //Stop transfer - StopI2CMaster(Channel); - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster(Channel); - AcknError = 0; - } - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster(Channel); - AcknError = 0; - } - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster(Channel); - AcknError = 0; - } - return (AcknError); -} - -//--------------------------------- -//WriteAD7147ViaI2C() -//--------------------------------- -//Function that writes via the I2C port pair of 16 bits data. It sends first the device -//address including the write bit, then the register address and finally the -//data. The function returns "1" if successfull otherwise "0". -//-------------------------------------------------------------------------------- -unsigned char WriteViaI2C_onSdaX(unsigned char Channel, i2c_sda_num_t sdaNum, - unsigned char DeviceAddress, const unsigned int RegisterStartAddress, - const unsigned char NumberOfRegistersToWrite, - if2hw_data_i2cmultisda_t *DataBuffer, const unsigned int OffsetInBuffer) { - - unsigned int DataToWrite; - unsigned char LowByteAddress, HighByteAddress; - unsigned char LowByteData, HighByteData; - unsigned char r, AcknError; - unsigned char DeviceAddressHeader; - - AcknError = 1; //No error on initialisation - - //Add the write bit to the device address - DeviceAddressHeader = DeviceAddress << 1 | I2C_WR; - //Split the address in two bytes - HighByteAddress = (RegisterStartAddress & 0xFF00) >> 8; - LowByteAddress = RegisterStartAddress & 0x00FF; - - //Start the I2C transfer - InitialiseI2CMaster(Channel); - StartI2CMaster_onSdaX(Channel, sdaNum); - //Send device address - if (!SendByteI2CMaster_onSdaX(Channel, sdaNum, DeviceAddressHeader)) { - //Send register address if the acknowledgement is there - if (!SendByteI2CMaster_onSdaX(Channel, sdaNum, HighByteAddress)) { - if (!SendByteI2CMaster_onSdaX(Channel, sdaNum, LowByteAddress)) { - //Perform block write - for (r = 0; r < NumberOfRegistersToWrite; r++) { - DataToWrite = DataBuffer[OffsetInBuffer + r]; - LowByteData = DataToWrite & 0x00FF; - HighByteData = (DataToWrite & 0xFF00) >> 8; - if (!SendByteI2CMaster_onSdaX(Channel, sdaNum, - HighByteData)) { - SendByteI2CMaster_onSdaX(Channel, sdaNum, LowByteData); - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster_onSdaX(Channel, sdaNum); - AcknError = 0; - } - } - //Stop transfer - StopI2CMaster_onSdaX(Channel, sdaNum); - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster_onSdaX(Channel, sdaNum); - AcknError = 0; - } - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster_onSdaX(Channel, sdaNum); - AcknError = 0; - } - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster_onSdaX(Channel, sdaNum); - AcknError = 0; - } - return (AcknError); -} - -//unsigned char WriteByteI2C_onSdaX(unsigned char Channel, i2c_sda_num_t sdaNum, -// unsigned char DeviceAddress, const unsigned int RegisterStartAddress, -// const unsigned char NumberOfRegistersToWrite, -// if2hw_data_i2cmultisda_t *DataBuffer, const unsigned int OffsetInBuffer) { -// -// unsigned int DataToWrite; -//// unsigned char LowByteAddress, HighByteAddress; -// unsigned char LowByteData; -//// unsigned char HighByteData; -// unsigned char r, AcknError; -// unsigned char DeviceAddressHeader; - -// AcknError = 1; //No error on initialisation - -// //Add the write bit to the device address -// DeviceAddressHeader = DeviceAddress << 1 | I2C_WR; -// //Start the I2C transfer -// InitialiseI2CMaster(Channel); -// StartI2CMaster_onSdaX(Channel, sdaNum); -// //Send device address -// if (!SendByteI2CMaster_onSdaX(Channel, sdaNum, DeviceAddressHeader)) { -// //Send register address if the acknowledgement is there -// if (!SendByteI2CMaster_onSdaX(Channel, sdaNum, RegisterStartAddress)) { -// //Perform block write -// for (r = 0; r < NumberOfRegistersToWrite; r++) { -// DataToWrite = DataBuffer[OffsetInBuffer + r]; -// LowByteData = DataToWrite & 0x00FF; -// if (!SendByteI2CMaster_onSdaX(Channel, sdaNum, LowByteData)){ -// } else //No acknowledgement was found therefore send the stop condition -// { -// StopI2CMaster_onSdaX(Channel, sdaNum); -// AcknError = 0; -// } -// } -// //Stop transfer -// StopI2CMaster_onSdaX(Channel, sdaNum); -// } else //No acknowledgement was found therefore send the stop condition -// { -// StopI2CMaster_onSdaX(Channel, sdaNum); -// AcknError = 0; -// } -// } else //No acknowledgement was found therefore send the stop condition -// { -// StopI2CMaster_onSdaX(Channel, sdaNum); -// AcknError = 0; -// } -// return (AcknError); -//} - - - -unsigned char WriteViaI2C_onSdaX2( i2c_sda_num_t sdaNum, - unsigned char DeviceAddress, - const unsigned int RegisterStartAddress, - const unsigned char NumberOfRegistersToWrite, - if2hw_data_i2cmultisda_t *DataBuffer, - const unsigned int OffsetInBuffer) { - - unsigned int DataToWrite; - unsigned char LowByteAddress, HighByteAddress; - unsigned char LowByteData, HighByteData; - unsigned char r, AcknError; - unsigned char DeviceAddressHeader; - - int Channel = 0; - - AcknError = 1; //No error on initialisation - - //Add the write bit to the device address - DeviceAddressHeader = DeviceAddress << 1 | I2C_WR; - //Split the address in two bytes - HighByteAddress = (RegisterStartAddress & 0xFF00) >> 8; - LowByteAddress = RegisterStartAddress & 0x00FF; - - //Start the I2C transfer - InitialiseI2CMaster(Channel); - ace_StartI2CMaster(static_cast(sdaNum)); - //Send device address - if (!ace_SendByteI2CMaster(static_cast(sdaNum), DeviceAddressHeader)) { - //Send register address if the acknowledgement is there - if (!ace_SendByteI2CMaster(static_cast(sdaNum), HighByteAddress)) { - if (!ace_SendByteI2CMaster(static_cast(sdaNum), LowByteAddress)) { - //Perform block write - for (r = 0; r < NumberOfRegistersToWrite; r++) { - DataToWrite = DataBuffer[OffsetInBuffer + r]; - LowByteData = DataToWrite & 0x00FF; - HighByteData = (DataToWrite & 0xFF00) >> 8; - if (!ace_SendByteI2CMaster(static_cast(sdaNum), - HighByteData)) { - ace_SendByteI2CMaster(static_cast(sdaNum), LowByteData); - } else //No acknowledgement was found therefore send the stop condition - { - ace_StopI2CMaster(static_cast(sdaNum)); - AcknError = 0; - } - } - //Stop transfer - ace_StopI2CMaster(static_cast(sdaNum)); - } else //No acknowledgement was found therefore send the stop condition - { - ace_StopI2CMaster(static_cast(sdaNum)); - AcknError = 0; - } - } else //No acknowledgement was found therefore send the stop condition - { - ace_StopI2CMaster(static_cast(sdaNum)); - AcknError = 0; - } - } else //No acknowledgement was found therefore send the stop condition - { - ace_StopI2CMaster(static_cast(sdaNum)); - AcknError = 0; - } - return (AcknError); -} - -//--------------------------------- -//ReadByteViaI2C() -//--------------------------------- -//Function that reads a Byte from via the I2C port. It sends first the device -//address including the write bit, then the register address and finally reads data -//back. The function returns "1" if successfull otherwise "0". If an error occurs, -//Then the stop condition is sent. -//-------------------------------------------------------------------------------- -unsigned char ReadByteViaI2C(unsigned char Channel, unsigned char SDAnum, - unsigned char DeviceAddress, const unsigned char RegisterAddress, - unsigned char *DataBuffer) { - - unsigned char AcknError; - unsigned char SDA_number = SDAnum; //for the palm - unsigned char DeviceAddressHeader; - - AcknError = 1; //No error on initialisation - - //Add the write bit to the device address - DeviceAddressHeader = DeviceAddress << 1 | I2C_WR; //qui ci vuole I2C_WR o RD secondo me RD - - //Start the I2C transfer - InitialiseI2CMaster(Channel); - StartI2CMaster(Channel); - - //Send device address - if (!SendByteI2CMaster(Channel, DeviceAddressHeader)) { - //Send register address - if (!SendByteI2CMaster(Channel, RegisterAddress)) { - //Send the repeated start - StartI2CMaster(Channel); - //Send device address again changing the Rd/Wr bit - DeviceAddressHeader = DeviceAddress << 1 | I2C_RD; - if (!SendByteI2CMaster(Channel, DeviceAddressHeader)) { - //Perform block read, but first,we need to know if we must send an ACKN or a NACK - - ReceiveByteI2CMaster(Channel, NACK); - *DataBuffer = ReceivedByte[SDA_number]; - //Stop transfer - StopI2CMaster(Channel); - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster(Channel); - AcknError = 0; - } - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster(Channel); - AcknError = 0; - } - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster(Channel); - AcknError = 0; - } - return (AcknError); -} -//--------------------------------- -//ReadViaI2C() -//--------------------------------- -//Function that reads from via the I2C port. It sends first the device -//address including the write bit, then the register address and finally reads data -//back. The function returns "1" if successfull otherwise "0". If an error occurs, -//Then the stop condition is sent. -//-------------------------------------------------------------------------------- -unsigned char ReadViaI2C(unsigned char Channel, unsigned char DeviceAddress, - const unsigned int RegisterStartAddress, - const unsigned char NumberOfRegistersToRead, - if2hw_data_i2cmultisda_t *DataBuffer1, if2hw_data_i2cmultisda_t *DataBuffer2, - if2hw_data_i2cmultisda_t *DataBuffer3, if2hw_data_i2cmultisda_t *DataBuffer4, - const unsigned int OffsetInBuffer) { - - unsigned char LowByteAddress, HighByteAddress; - unsigned char LowByteData[4], HighByteData[4]; - unsigned char r, AcknError; - unsigned char DeviceAddressHeader; - - AcknError = 1; //No error on initialisation - - //Add the write bit to the device address - DeviceAddressHeader = DeviceAddress << 1 | I2C_WR; //qui ci vuole I2C_WR o RD secondo me RD - //Split the address in two bytes - HighByteAddress = (RegisterStartAddress & 0xFF00) >> 8; - LowByteAddress = RegisterStartAddress & 0x00FF; - - //Start the I2C transfer - InitialiseI2CMaster(Channel); - StartI2CMaster(Channel); - - //Send device address - if (!SendByteI2CMaster(Channel, DeviceAddressHeader)) { - //Send register address - if (!SendByteI2CMaster(Channel, HighByteAddress)) { - if (!SendByteI2CMaster(Channel, LowByteAddress)) { - //Send the repeated start - StartI2CMaster(Channel); - //Send device address again changing the Rd/Wr bit - DeviceAddressHeader = DeviceAddress << 1 | I2C_RD; - if (!SendByteI2CMaster(Channel, DeviceAddressHeader)) { - //Perform block read, but first,we need to know if we must send an ACKN or a NACK - if (NumberOfRegistersToRead == 1) { - ReceiveByteI2CMaster(Channel, ACK); - HighByteData[0] = ReceivedByte[0]; - HighByteData[1] = ReceivedByte[1]; - HighByteData[2] = ReceivedByte[2]; - HighByteData[3] = ReceivedByte[3]; - - ReceiveByteI2CMaster(Channel, NACK); - LowByteData[0] = ReceivedByte[0]; - LowByteData[1] = ReceivedByte[1]; - LowByteData[2] = ReceivedByte[2]; - LowByteData[3] = ReceivedByte[3]; - - DataBuffer1[OffsetInBuffer] = ((HighByteData[0] & 0xFF) - << 8) | LowByteData[0]; - - DataBuffer2[OffsetInBuffer] = ((HighByteData[1] & 0xFF) - << 8) | LowByteData[1]; - - DataBuffer3[OffsetInBuffer] = ((HighByteData[2] & 0xFF) - << 8) | LowByteData[2]; - - DataBuffer4[OffsetInBuffer] = ((HighByteData[3] & 0xFF) - << 8) | LowByteData[3]; - - } else { - for (r = 0; r < (NumberOfRegistersToRead - 1); r++) { - ReceiveByteI2CMaster(Channel, ACK); - HighByteData[0] = ReceivedByte[0]; - HighByteData[1] = ReceivedByte[1]; - HighByteData[2] = ReceivedByte[2]; - HighByteData[3] = ReceivedByte[3]; - - ReceiveByteI2CMaster(Channel, ACK); - LowByteData[0] = ReceivedByte[0]; - LowByteData[1] = ReceivedByte[1]; - LowByteData[2] = ReceivedByte[2]; - LowByteData[3] = ReceivedByte[3]; - - DataBuffer1[OffsetInBuffer + r] = ((HighByteData[0] - & 0xFF) << 8) | LowByteData[0]; - - DataBuffer2[OffsetInBuffer + r] = ((HighByteData[1] - & 0xFF) << 8) | LowByteData[1]; - - DataBuffer3[OffsetInBuffer + r] = ((HighByteData[2] - & 0xFF) << 8) | LowByteData[2]; - - DataBuffer4[OffsetInBuffer + r] = ((HighByteData[3] - & 0xFF) << 8) | LowByteData[3]; - - } - //Do the last read sending the NACK - ReceiveByteI2CMaster(Channel, ACK); - HighByteData[0] = ReceivedByte[0]; - HighByteData[1] = ReceivedByte[1]; - HighByteData[2] = ReceivedByte[2]; - HighByteData[3] = ReceivedByte[3]; - - ReceiveByteI2CMaster(Channel, NACK); - LowByteData[0] = ReceivedByte[0]; - LowByteData[1] = ReceivedByte[1]; - LowByteData[2] = ReceivedByte[2]; - LowByteData[3] = ReceivedByte[3]; - - DataBuffer1[OffsetInBuffer + NumberOfRegistersToRead - 1] = - ((HighByteData[0] & 0xFF) << 8) - | LowByteData[0]; - - DataBuffer2[OffsetInBuffer + NumberOfRegistersToRead - 1] = - ((HighByteData[1] & 0xFF) << 8) - | LowByteData[1]; - - DataBuffer3[OffsetInBuffer + NumberOfRegistersToRead - 1] = - ((HighByteData[2] & 0xFF) << 8) - | LowByteData[2]; - - DataBuffer4[OffsetInBuffer + NumberOfRegistersToRead - 1] = - ((HighByteData[3] & 0xFF) << 8) - | LowByteData[3]; - - } - //Stop transfer - StopI2CMaster(Channel); - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster(Channel); - AcknError = 0; - } - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster(Channel); - AcknError = 0; - } - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster(Channel); - AcknError = 0; - } - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster(Channel); - AcknError = 0; - } - return (AcknError); -} - -/********************************************************************************************************/ -/*** Low level functions, do not change anything below this line, however check the valid clock level ***/ -/********************************************************************************************************/ -//ReadViaI2C() -//--------------------------------- -//Function that reads from via the I2C port. It sends first the device -//address including the write bit, then the register address and finally reads data -//back. The function returns "1" if successfull otherwise "0". If an error occurs, -//Then the stop condition is sent. -//-------------------------------------------------------------------------------- -unsigned char ReadBurstViaI2C(unsigned char Channel, unsigned char SDAnum, - unsigned char DeviceAddress, const unsigned int RegisterStartAddress, - const unsigned char NumberOfRegistersToRead, if2hw_data_i2cmultisda_t *DataBuffer) { - - unsigned char ByteAddress; - unsigned char LowByteData, HighByteData; - unsigned char r, AcknError; - unsigned char SDA_number = SDAnum; - unsigned char DeviceAddressHeader; - - AcknError = 1; //No error on initialisation - - //Add the write bit to the device address - DeviceAddressHeader = DeviceAddress << 1 | I2C_WR; //qui ci vuole I2C_WR o RD secondo me RD - - ByteAddress = RegisterStartAddress & 0x00FF; - - //Start the I2C transfer - InitialiseI2CMaster(Channel); - StartI2CMaster(Channel); - - //Send device address - if (!SendByteI2CMaster(Channel, DeviceAddressHeader)) { - //Send register address - - if (!SendByteI2CMaster(Channel, ByteAddress)) { - //Send the repeated start - StartI2CMaster(Channel); - //Send device address again changing the Rd/Wr bit - DeviceAddressHeader = DeviceAddress << 1 | I2C_RD; - if (!SendByteI2CMaster(Channel, DeviceAddressHeader)) { - //Perform block read, but first,we need to know if we must send an ACKN or a NACK - if (NumberOfRegistersToRead == 1) { - ReceiveByteI2CMaster(Channel, ACK); - HighByteData = ReceivedByte[SDA_number]; - ; - - ReceiveByteI2CMaster(Channel, NACK); - LowByteData = ReceivedByte[SDA_number]; - ; - - DataBuffer[0] = ((HighByteData & 0xFF) << 8) | LowByteData; - - } else { - for (r = 0; r < (NumberOfRegistersToRead - 1); r++) { - ReceiveByteI2CMaster(Channel, ACK); - HighByteData = ReceivedByte[SDA_number]; - ; - - ReceiveByteI2CMaster(Channel, ACK); - LowByteData = ReceivedByte[SDA_number]; - ; - - DataBuffer[r] = ((HighByteData & 0xFF) << 8) - | LowByteData; - - } - //Do the last read sending the NACK - ReceiveByteI2CMaster(Channel, ACK); - HighByteData = ReceivedByte[SDA_number]; - ; - - ReceiveByteI2CMaster(Channel, NACK); - LowByteData = ReceivedByte[SDA_number]; - ; - - DataBuffer[NumberOfRegistersToRead - 1] = ((HighByteData - & 0xFF) << 8) | LowByteData; - - } - //Stop transfer - StopI2CMaster(Channel); - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster(Channel); - AcknError = 0; - } - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster(Channel); - AcknError = 0; - } - - } else //No acknowledgement was found therefore send the stop condition - { - StopI2CMaster(Channel); - AcknError = 0; - } - return (AcknError); -} - -//--------------------------------- -//InitialiseI2CMaster(); -//--------------------------------- -//Function that configures the I2C port of the ADuC841 in master mode. -//-------------------------------------------------------------------------------- - -void InitialiseI2CMaster(unsigned char Channel) { - switch (Channel) { - case CH0: { - MCE_0output(); - } - break; - case CH1: { - // MCE_1output; - } - break; - } - /*modificated - TRISFbits.TRISF6=0; //Write a "0" to CLK so that it becomes an output. - */ - //I2CCON = 0xA8; //Master mode -} - -//--------------------------------- -//StartI2CMaster(); -//--------------------------------- -//Function that implements the start condition of the I2C protocol. The start -//condition consists in a falling edge on SDA when SCL is high. -//-------------------------------------------------------------------------------- -void StartI2CMaster(unsigned char Channel) { - DE_0input();; - Wait(I2Cbit); - MCO_0_on(); - //SCL high - Wait(I2Cbit); - Wait(I2Cbit); - DE_0output(); - //SDA as output - DO_0off(); - Wait(I2Cbit); - MCO_0_off(); - //SCL low - Wait(I2Cbit); -} - - -#warning marco.accame: why param input is not used? -void SetSdaReg(i2c_sda_num_t sdaNum, unsigned char input) -{ - if(sdaNum < 4) - { - LL_GPIO_SetPinMode(props.sda[sdaNum].stmport, props.sda[sdaNum].stmpin, LL_GPIO_MODE_INPUT); - } - -} - -void SetValReg(i2c_sda_num_t sdaNum, unsigned char val) -{ - if(sdaNum < 4) - { // because val=0 -> GPIO_PIN_RESET else -> GPIO_PIN_SET - HAL_GPIO_WritePin(props.sda[sdaNum].stmport, props.sda[sdaNum].stmpin, (0==val) ? (GPIO_PIN_RESET) : (GPIO_PIN_SET)); - } - -} - -//void SetSdaReg(i2c_sda_num_t sdaNum, unsigned char input) { -// switch (sdaNum) { -// case sda0: { -// LL_GPIO_SetPinMode(props.sda[0].stmport, props.sda[0].stmpin, LL_GPIO_MODE_INPUT); -// } -// break; -// case sda1: { -// LL_GPIO_SetPinMode(props.sda[1].stmport, props.sda[1].stmpin, LL_GPIO_MODE_INPUT); -// } -// break; -// case sda2: { -// LL_GPIO_SetPinMode(props.sda[2].stmport, props.sda[2].stmpin, LL_GPIO_MODE_INPUT); -// } -// break; -// case sda3: { -// LL_GPIO_SetPinMode(props.sda[3].stmport, props.sda[3].stmpin, LL_GPIO_MODE_INPUT); -// } -// break; - -// -// default: -// { -// } break; -// -// } - -//} - -//void SetValReg(i2c_sda_num_t sdaNum, unsigned char val) { -// switch (sdaNum) { -// case sda0: { -// if (val == 0) -// HAL_GPIO_WritePin(props.sda[0].stmport, props.sda[0].stmpin, GPIO_PIN_RESET); -// else -// HAL_GPIO_WritePin(props.sda[0].stmport, props.sda[0].stmpin, GPIO_PIN_SET); -// } -// break; -// case sda1: { -// if (val == 0) -// HAL_GPIO_WritePin(props.sda[1].stmport, props.sda[1].stmpin, GPIO_PIN_RESET); -// else -// HAL_GPIO_WritePin(props.sda[1].stmport, props.sda[1].stmpin, GPIO_PIN_SET); -// } -// break; -// case sda2: { -// if (val == 0) -// HAL_GPIO_WritePin(props.sda[2].stmport, props.sda[2].stmpin, GPIO_PIN_RESET); -// else -// HAL_GPIO_WritePin(props.sda[2].stmport, props.sda[2].stmpin, GPIO_PIN_SET); -// } -// break; -// case sda3: { -// if (val == 0) -// HAL_GPIO_WritePin(props.sda[3].stmport, props.sda[3].stmpin, GPIO_PIN_RESET); -// else -// HAL_GPIO_WritePin(props.sda[3].stmport, props.sda[3].stmpin, GPIO_PIN_SET); -// } -// break; -// -// default: -// { -// } break; - -// }; - -//} - -void StartI2CMaster_onSdaX(unsigned char Channel, i2c_sda_num_t sdaNum) { - StartI2CMaster(Channel); - /* - switch (Channel) { - case CH0: { - //DE_0input();; - SetSdaReg(sdaNum, 1); - - Wait(I2Cbit); - MCO_0_on(); - //SCL high - Wait(I2Cbit); - - Wait(I2Cbit); - //DE_0output(); //SDA as output - SetSdaReg(sdaNum, 0); - - //DO_0off(); - SetValReg(sdaNum, 0); - Wait(I2Cbit); - MCO_0_off(); - //SCL low - Wait(I2Cbit); - } - break; - case CH1: { - //DE_0input();; - SetSdaReg(sdaNum, 1); - - Wait(I2Cbit); - MCO_1_on - //SCL high - Wait(I2Cbit); - - Wait(I2Cbit); - //DE_0output(); //SDA as output - SetSdaReg(sdaNum, 0); - - //DO_0off(); - SetValReg(sdaNum, 0); - Wait(I2Cbit); - MCO_1_off - //SCL low - Wait(I2Cbit); - } - break; - } -*/ -} - -//--------------------------------- -//StopI2CMaster(); -//--------------------------------- -//Function that implements the stop condition of the I2C protocol. The stop -//condition consists in a rising edge on SDA when SCL is high. -//-------------------------------------------------------------------------------- -void StopI2CMaster(unsigned char Channel) { - DE_0output(); - //SDA as output - DO_0off(); - //SDA low - Wait(I2Cbit); - MCO_0_on(); - //SCL high - Wait(I2Cbit); //Wait(I2Cbit); - DE_0input(); - //SDA as output - //DO_0on(); //SDA goes from low to high when SCL is already high, - Wait(I2Cbit);//Wait(I2Cbit); -} - -void StopI2CMaster_onSdaX(unsigned char Channel, i2c_sda_num_t sdaNum) { - StopI2CMaster(Channel); - - //DE_0output(); //SDA as output - SetSdaReg(sdaNum, 0); - //DO_0off(); //SDA low - SetValReg(sdaNum, 0); - Wait(I2Cbit); - MCO_0_on(); - //SCL high - Wait(I2Cbit); //Wait(I2Cbit); - //DE_0input(); //SDA as output - SetSdaReg(sdaNum, 1); -} - -//--------------------------------- -//SendByteI2CMaster(); -//--------------------------------- -//Function that sends a byte to the I2C port and then read the acknowledgement -//bit. If the acknowledgement is found, then the function returns "1" otherwise, -//it returns "0". -//-------------------------------------------------------------------------------- -unsigned char SendByteI2CMaster(unsigned char Channel, unsigned char ByteToSend) { - - unsigned char i; - unsigned char noack = 0; - - DE_0output(); - //SDAs as output - for (i = 8; i > 0; i--) { - MCO_0_off(); - //Reset SCL - if (ByteToSend >> 7) { - DO_0on();; - } else { - DO_0off();; - } - Wait(I2Cbit); - MCO_0_on(); //Set SCL - Wait(I2Cbit); - Wait(I2Cbit); - Wait(I2Cbit); - MCO_0_off(); - if (i == 1) { - DE_0input(); - ; - } else { //Reset SCL - Wait(I2Cbit); //Wait(I2Cbit); - ByteToSend <<= 1; //Rotate data - } - } - DO_0off(); - Wait(I2Cbit); - DE_0input(); //SDA becomes an input - MCO_0_off(); - //Reset SCL - Wait(I2Cbit); //Wait(I2Cbit); - MCO_0_on(); //Set SCL - noack = 0; - Wait(I2Cbit); //Wait(I2Cbit); - MCO_0_off(); - DE_0output(); //SDA becomes an output - - return (noack); -} - -unsigned char SendByteI2CMaster_onSdaX(unsigned char Channel, - i2c_sda_num_t sdaNum, unsigned char ByteToSend) { - - unsigned char i; - unsigned char noack = 0; - - //DE_0output(); //SDAs as output - SetSdaReg(sdaNum, 0); - - for (i = 8; i > 0; i--) { - MCO_0_off(); - //Reset SCL - /*@@@@@@@@@@@@ - DO = ByteToSend >> 7; //Send data to SDA pin - */ - if (ByteToSend >> 7) { - //DO_0on();; - SetValReg(sdaNum, 1); - } else { - //DO_0off();; - SetValReg(sdaNum, 0); - } - Wait(I2Cbit); //Wait(0); - - // Wait(I2Cbit);//Wait(I2Cbit); - MCO_0_on(); - //Set SCL - Wait(I2Cbit); //Wait(I2Cbit); - Wait(I2Cbit); - Wait(I2Cbit); - MCO_0_off(); - if (i == 1) { - //DE_0input();; - SetSdaReg(sdaNum, 1); - } else { //Reset SCL - Wait(I2Cbit); //Wait(I2Cbit); - ByteToSend <<= 1; //Rotate data - } - } - //DO_0off(); - SetValReg(sdaNum, 0); - - //DE_0input(); //SDA becomes an input - SetSdaReg(sdaNum, 1); - - MCO_0_off(); - //Reset SCL - - Wait(I2Cbit); //Wait(I2Cbit); - MCO_0_on(); //Set SCL - - noack = 0; - - Wait(I2Cbit); //Wait(I2Cbit); - MCO_0_off(); - //DE_0output(); //SDA becomes an output - SetSdaReg(sdaNum, 0); - - return (noack); -} - -//--------------------------------- -//ReceiveByteI2CMaster(); -//--------------------------------- -//Function that reads one byte from the I2C port. If we do continuous read, -//then the acknowledgement must be "0" excepted for the last read sequence which -//it must be "1". -//-------------------------------------------------------------------------------- -void ReceiveByteI2CMaster(unsigned char Channel, unsigned char ackn) // changed bit with unsigned char -{ - unsigned char i; - DE_0input(); - //SDA becomes an input - MCO_0_off(); - //Reset SCL - for (i = 8; i > 0; i--) { - Wait(I2Cbit); //Wait(I2Cbit); - ReceivedByte[0] <<= 1; //Rotate data - ReceivedByte[1] <<= 1; //Rotate data - ReceivedByte[2] <<= 1; //Rotate data - ReceivedByte[3] <<= 1; //Rotate data - MCO_0_on(); //Set SCL - Wait(I2Cbit); // added..... why? -// // debugged by marco.accame / andrea.mura -// // corrected shift value for the pins 5, 6, 7, 8 -// ReceivedByte[0] |= (uint16_t) ((GPIOA->IDR & (1<<8))>>8); //Read SDA0 -> data -// ReceivedByte[1] |= ((GPIOA->IDR &(1<<7))>>7); //Read SDA1 -> data -// ReceivedByte[2] |= ((GPIOA->IDR &(1<<6))>>6); //Read SDA2 -> data -// ReceivedByte[3] |= ((GPIOA->IDR &(1<<5))>>5); //Read SDA3 -> data - ReceivedByte[0] |= HAL_GPIO_ReadPin(props.sda[0].stmport, props.sda[0].stmpin); //Read I2C_SDA0 -> data - ReceivedByte[1] |= HAL_GPIO_ReadPin(props.sda[1].stmport, props.sda[1].stmpin); //Read I2C_SDA1 -> data - ReceivedByte[2] |= HAL_GPIO_ReadPin(props.sda[2].stmport, props.sda[2].stmpin); //Read I2C_SDA2 -> data - ReceivedByte[3] |= HAL_GPIO_ReadPin(props.sda[3].stmport, props.sda[3].stmpin); //Read I2C_SDA3 -> data - Wait(I2Cbit); //Wait(I2Cbit); - MCO_0_off(); - //Reset SCL - } - DE_0output(); - //SDA becomes an output - if (ackn == 1) { - DO_0on(); - } else - DO_0off(); - Wait(I2Cbit); //Wait(I2Cbit); - MCO_0_on(); - //Set SCL - Wait(I2Cbit); //Wait(I2Cbit); - MCO_0_off(); - //Reset SCL - -} - - - -void ace_StartI2CMaster(SDAch_t sda) { - ace_DE_0input(sda);; - Wait(I2Cbit); - ace_MCO_0_on(); - //SCL high - Wait(I2Cbit); - Wait(I2Cbit); - ace_DE_0output(sda); - //SDA as output - ace_DO_0off(sda); - Wait(I2Cbit); - ace_MCO_0_off(); - //SCL low - Wait(I2Cbit); -} - -void ace_StopI2CMaster(SDAch_t sda) { - ace_DE_0output(sda); - //SDA as output - ace_DO_0off(sda); - //SDA low - Wait(I2Cbit); - ace_MCO_0_on(); - //SCL high - Wait(I2Cbit); //Wait(I2Cbit); - ace_DE_0input(sda); - //SDA as output - //DO_0on(); //SDA goes from low to high when SCL is already high, - Wait(I2Cbit);//Wait(I2Cbit); -} - -//void StopI2CMaster_onSdaX(unsigned char Channel, i2c_sda_num_t sdaNum) { -// StopI2CMaster(Channel); -// -// //DE_0output(); //SDA as output -// SetSdaReg(sdaNum, 0); -// //DO_0off(); //SDA low -// SetValReg(sdaNum, 0); -// Wait(I2Cbit); -// MCO_0_on(); -// //SCL high -// Wait(I2Cbit); //Wait(I2Cbit); -// //DE_0input(); //SDA as output -// SetSdaReg(sdaNum, 1); -//} - - -unsigned char ace_SendByteI2CMaster(SDAch_t sda, unsigned char ByteToSend) { - - unsigned char i; - unsigned char noack = 0; - - ace_DE_0output(sda); //SDAs as output - - for (i = 8; i > 0; i--) { - ace_MCO_0_off(); - //Reset SCL - /*@@@@@@@@@@@@ - DO = ByteToSend >> 7; //Send data to SDA pin - */ - if (ByteToSend >> 7) { - ace_DO_0on(sda); - } else { - ace_DO_0off(sda); - } - Wait(I2Cbit); - ace_MCO_0_on(); //Set SCL - Wait(I2Cbit); - Wait(I2Cbit); - Wait(I2Cbit); - ace_MCO_0_off(); - if (i == 1) { - ace_DE_0input(sda); - } else { //Reset SCL - Wait(I2Cbit); //Wait(I2Cbit); - ByteToSend <<= 1; //Rotate data - } - } - ace_DO_0off(sda); - Wait(I2Cbit); - ace_DE_0input(sda); //SDA becomes an input - ace_MCO_0_off(); - //Reset SCL - Wait(I2Cbit); //Wait(I2Cbit); - ace_MCO_0_on(); //Set SCL - noack = 0; - Wait(I2Cbit); //Wait(I2Cbit); - ace_MCO_0_off(); - ace_DE_0output(sda); //SDA becomes an output - - return (noack); -} - - -// eof - - - - - diff --git a/emBODY/eBcode/arch-arm/board/mtb4c/application/src/others/I2C_Multi_SDA.h b/emBODY/eBcode/arch-arm/board/mtb4c/application/src/others/I2C_Multi_SDA.h deleted file mode 100644 index ebffb96c4..000000000 --- a/emBODY/eBcode/arch-arm/board/mtb4c/application/src/others/I2C_Multi_SDA.h +++ /dev/null @@ -1,95 +0,0 @@ -/****************************************************************************** - * I2C_Multi_SDA.h - * - * - * Created on: Oct 29, 2015 - * Board: NUCLEO STML152RET - * Author: marco aggiali - * - * Description: This file contains the functions for sending data from a non standard I2C - * with 1 SCK line and 4 SDA lines - * - * Modified: - * - ******************************************************************************/ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __i2c_SSI_H -#define __i2c_SSI_H - -#ifdef __cplusplus -extern "C" { -#endif - - -#include "if2hw_common.h" - - - -typedef enum -{ - sda0 = 0, - sda1 = 1, - sda2 = 2, - sda3 = 3, - sda4 = 4, - sda5 = 5, - sda6 = 6, - sda7 = 7, -} i2c_sda_num_t; - -enum SDAch_t { SDAch0 = 0, SDAch1 = 1, SDAch2 = 2, SDAch3 = 3, SDAall = 255 }; - - -#define i2c_sda_num_max 8 -#define CH0 0 -#define CH1 1 - - -void I2C_Multi_SDA_Init(unsigned char Channel); -void I2C_Multi_SDA_test(unsigned char Channel); -void I2C_Multi_SDA_deInit(unsigned char Channel); -//Local functions -//=============== -//High level functions -unsigned char WriteViaI2C_onSdaX2( i2c_sda_num_t sdaNum, - unsigned char DeviceAddress, - const unsigned int RegisterStartAddress, - const unsigned char NumberOfRegistersToWrite, - if2hw_data_i2cmultisda_t *DataBuffer, - const unsigned int OffsetInBuffer); - -unsigned char WriteViaI2C(unsigned char Channel, unsigned char DeviceAddress, const unsigned int RegisterStartAddress, const unsigned char NumberOfRegistersToWrite, - if2hw_data_i2cmultisda_t *DataBuffer, const unsigned int OffsetInBuffer); -extern unsigned char WriteByteViaI2C(unsigned char Channel, unsigned char DeviceAddress, const unsigned char RegisterStartAddress, unsigned char DataBuffer); -//unsigned char WriteByteI2C_onSdaX(unsigned char Channel, i2c_sda_num_t sdaNum, unsigned char DeviceAddress, const unsigned int RegisterStartAddress, const unsigned char NumberOfRegistersToWrite, -// if2hw_data_i2cmultisda_t *DataBuffer, const unsigned int OffsetInBuffer); -unsigned char WriteViaI2C_onSdaX(unsigned char Channel, i2c_sda_num_t sdaNum, unsigned char DeviceAddress, const unsigned int RegisterStartAddress, const unsigned char NumberOfRegistersToWrite, - if2hw_data_i2cmultisda_t *DataBuffer, const unsigned int OffsetInBuffer); -unsigned char ReadBurstViaI2C(unsigned char Channel, unsigned char SDAnum, unsigned char DeviceAddress, const unsigned int RegisterStartAddress, const unsigned char NumberOfRegistersToRead, - if2hw_data_i2cmultisda_t *DataBuffer); -extern unsigned char ReadViaI2C(unsigned char Channel,unsigned char DeviceAddress, const unsigned int RegisterStartAddress, const unsigned char NumberOfRegistersToRead, - if2hw_data_i2cmultisda_t *DataBuffer1, if2hw_data_i2cmultisda_t *DataBuffer2, if2hw_data_i2cmultisda_t *DataBuffer3, if2hw_data_i2cmultisda_t *DataBuffer4, - const unsigned int OffsetInBuffer); -unsigned char ReadByteViaI2C(unsigned char Channel, unsigned char SDAnum, unsigned char DeviceAddress, const unsigned char RegisterAddress, unsigned char *DataBuffer ); -unsigned char ReadByteViaI2C_onSdaX(unsigned char Channel, i2c_sda_num_t sdaNum, unsigned char DeviceAddress, const unsigned char RegisterAddress, unsigned char *DataBuffer ); - -//Low level functions -void Wait(unsigned int cycles); -void InitialiseI2CMaster(unsigned char Channel); -void StartI2CMaster(unsigned char Channel); -void StopI2CMaster(unsigned char Channel); -unsigned char SendByteI2CMaster(unsigned char Channel,unsigned char ByteToSend); -void ReceiveByteI2CMaster(unsigned char Channel,unsigned char ackn); //modificated bit with unsigned char - -void SetValReg(i2c_sda_num_t sdaNum, unsigned char val); -void SetSdaReg(i2c_sda_num_t sdaNum, unsigned char input); -void StartI2CMaster_onSdaX(unsigned char Channel, i2c_sda_num_t sdaNum); -void StopI2CMaster_onSdaX(unsigned char Channel, i2c_sda_num_t sdaNum); -unsigned char SendByteI2CMaster_onSdaX(unsigned char Channel, i2c_sda_num_t sdaNum, unsigned char ByteToSend); - -#ifdef __cplusplus -} // closing brace for extern "C" -#endif - -#endif diff --git a/emBODY/eBcode/arch-arm/board/mtb4c/application/src/others/if2hw_common.c b/emBODY/eBcode/arch-arm/board/mtb4c/application/src/others/if2hw_common.c deleted file mode 100644 index 5b89e5560..000000000 --- a/emBODY/eBcode/arch-arm/board/mtb4c/application/src/others/if2hw_common.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (C) 2017 iCub Facility - Istituto Italiano di Tecnologia - * Author: Marco Accame - * email: marco.accame@iit.it - * website: www.robotcub.org - * Permission is granted to copy, distribute, and/or modify this program - * under the terms of the GNU General Public License, version 2 or any - * later version published by the Free Software Foundation. - * - * A copy of the license can be found at - * http://www.robotcub.org/icub/license/gpl.txt - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - * Public License for more details -*/ - -// - -// -------------------------------------------------------------------------------------------------------------------- -// - external dependencies -// -------------------------------------------------------------------------------------------------------------------- - -#include "stdlib.h" - - -// -------------------------------------------------------------------------------------------------------------------- -// - declaration of extern public interface -// -------------------------------------------------------------------------------------------------------------------- - -#include "if2hw_common.h" - - -// -------------------------------------------------------------------------------------------------------------------- -// - declaration of extern hidden interface -// -------------------------------------------------------------------------------------------------------------------- -// - - -// -------------------------------------------------------------------------------------------------------------------- -// - #define with internal scope -// -------------------------------------------------------------------------------------------------------------------- -// empty-section - - -// -------------------------------------------------------------------------------------------------------------------- -// - definition (and initialisation) of extern variables, but better using _get(), _set() -// -------------------------------------------------------------------------------------------------------------------- -// empty-section - - - -// -------------------------------------------------------------------------------------------------------------------- -// - typedef with internal scope -// -------------------------------------------------------------------------------------------------------------------- -// empty-section - - -// -------------------------------------------------------------------------------------------------------------------- -// - declaration of static functions -// -------------------------------------------------------------------------------------------------------------------- - -//static void dd_bsp_delay(uint64_t t); - - -// -------------------------------------------------------------------------------------------------------------------- -// - definition (and initialisation) of static variables -// -------------------------------------------------------------------------------------------------------------------- -// commented out as it is not used -//static const char s_eobj_ownname[] = "EOaction"; - - -// -------------------------------------------------------------------------------------------------------------------- -// - definition of extern public functions -// -------------------------------------------------------------------------------------------------------------------- - - -//extern void if2hw_common_delay(uint64_t usec) -//{ -// dd_bsp_delay(usec); -//} - -// -------------------------------------------------------------------------------------------------------------------- -// - definition of extern hidden functions -// -------------------------------------------------------------------------------------------------------------------- - - - -// -------------------------------------------------------------------------------------------------------------------- -// - definition of static functions -// -------------------------------------------------------------------------------------------------------------------- - -//__asm static void dd_hl_sys_asm_xnumARMv7ops(uint32_t numberof) -//{ -// align -//dowaitloop -// subs r0,r0,#1 -// bne dowaitloop -// bx lr -// align -//} - - -//#if __ARMCOMPILER_VERSION > 6000000 -//int _execOperations(uint32_t i) -//{ -// int res = 0; -// __asm -// ( -// "DOWAITLOOP: \t\n" -// "SUBS %[input_i], %[input_i], #1 \t\n" -// "BNE DOWAITLOOP \t\n" -// : [result] "=&r" (res) -// : [input_i] "r" (i) -// ); -// return 0; -//} -//#else -//__asm void _execOperations(uint32_t numberof) -//{ -// align -//dowaitloop -// subs r0,r0,#1 -// bne dowaitloop -// bx lr -// align -//} -//#endif - -//static void dd_bsp_delay(uint64_t t) -//{ -// static uint64_t s_hl_sys_numofops1sec = 0; -// static uint32_t s_hl_sys_used_systemcoreclock = 0; -// if(s_hl_sys_used_systemcoreclock != SystemCoreClock) -// { - -// // to occupy a millisec i execute an operation for a number of times which depends on: -// // SystemCoreClock, cortex gain(1.25 dmips/mhz), flash access, etc. -// // to overcome all this i just consider SystemCoreClock w/out 1.25 gain and i measures -// // extra gain with on a simple assembly function which should take 4 cycles per iteration (?). -// //s_hl_sys_numofops1sec = (5*(SystemCoreClock)) / 4; -// s_hl_sys_used_systemcoreclock = SystemCoreClock; -// s_hl_sys_numofops1sec = SystemCoreClock; -// -// // with art technology enabled the flash is seen as fast as the cpu. wow. -// s_hl_sys_numofops1sec /= 3; -// // at this point i normalise the variable to keep not the nymber of operations for 1 sec, -// // but for 1024*1024 microsec. by doing so, later on i shift by 20 instead of using a division. -// s_hl_sys_numofops1sec <<= 20; -// s_hl_sys_numofops1sec /= 1000000; -// } -// -// -// volatile uint64_t num = s_hl_sys_numofops1sec * t; -// num >>= 20; -// //num -= offset; //we may remove some cycles to compensates for previous instructions, but ... we dont do it. it depends on c compiler optimisation -// if(0 == num) -// { -// return; -// } -// _execOperations((uint32_t)num); -//} -// -------------------------------------------------------------------------------------------------------------------- -// - end-of-file (leave a blank line after) -// -------------------------------------------------------------------------------------------------------------------- - - - - diff --git a/emBODY/eBcode/arch-arm/board/mtb4c/application/src/others/if2hw_common.h b/emBODY/eBcode/arch-arm/board/mtb4c/application/src/others/if2hw_common.h deleted file mode 100644 index e6009208a..000000000 --- a/emBODY/eBcode/arch-arm/board/mtb4c/application/src/others/if2hw_common.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2017 iCub Facility - Istituto Italiano di Tecnologia - * Author: Marco Accame - * email: marco.accame@iit.it - * website: www.robotcub.org - * Permission is granted to copy, distribute, and/or modify this program - * under the terms of the GNU General Public License, version 2 or any - * later version published by the Free Software Foundation. - * - * A copy of the license can be found at - * http://www.robotcub.org/icub/license/gpl.txt - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - * Public License for more details -*/ - -// - include guard ---------------------------------------------------------------------------------------------------- -#ifndef _IF2HW_COMMON_H_ -#define _IF2HW_COMMON_H_ - -#ifdef __cplusplus -extern "C" { -#endif - - - - -// - external dependencies -------------------------------------------------------------------------------------------- - -#include "stm32hal.h" - - -// - public #define -------------------------------------------------------------------------------------------------- - -// it forces AD7147 and I2C_Multi_SDA to use U32 or U16 data. -// the logical choice is U16 as everywhere the code uses only 2 bytes. -#define if2hw_common_SKIN_USE_U16 - -// it shapes code to use either internal or externally allocated buffers ... -#define if2hw_common_AD7147_USE_EXTERNALDATA - -// it shapes the code to use or not the data structure for controllling config of triangles as defined in AD7147 -#define if2hw_common_AD7147_USE_EXTERNALCONTROLTYPES - - -// - declaration of public user-defined types ------------------------------------------------------------------------- - - -#if defined(if2hw_common_SKIN_USE_U32) - -typedef uint32_t if2hw_data_ad7147_t; -typedef uint32_t if2hw_data_i2cmultisda_t; - -#elif defined(if2hw_common_SKIN_USE_U16) - -typedef uint16_t if2hw_data_ad7147_t; -typedef uint16_t if2hw_data_i2cmultisda_t; - -#else - -#error YOU MUST define either if2hw_common_SKIN_USE_U32 or if2hw_common_SKIN_USE_U16 - -#endif - - -// - declaration of extern public variables, ... but better using use _get/_set instead ------------------------------- - - -// - declaration of extern public functions --------------------------------------------------------------------------- - -//extern void if2hw_common_delay(uint64_t usec); - - - -#ifdef __cplusplus -} // closing brace for extern "C" -#endif - -#endif // include-guard - - -// - end-of-file (leave a blank line after)---------------------------------------------------------------------------- - diff --git a/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/lib/stm32hal.l4.v1D3.mtb4.lib b/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/lib/stm32hal.l4.v1D3.mtb4.lib index e703669c7..5c53c24e0 100644 Binary files a/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/lib/stm32hal.l4.v1D3.mtb4.lib and b/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/lib/stm32hal.l4.v1D3.mtb4.lib differ diff --git a/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/lib/stm32hal.l4.v1D3.mtb4c.lib b/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/lib/stm32hal.l4.v1D3.mtb4c.lib index d5f215627..68f480573 100644 Binary files a/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/lib/stm32hal.l4.v1D3.mtb4c.lib and b/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/lib/stm32hal.l4.v1D3.mtb4c.lib differ diff --git a/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/proj/stm32hal.l4.uvoptx b/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/proj/stm32hal.l4.uvoptx index 99a74e774..b378bc402 100644 --- a/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/proj/stm32hal.l4.uvoptx +++ b/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/proj/stm32hal.l4.uvoptx @@ -540,7 +540,7 @@ 1 0 - 0 + 1 18 @@ -1625,7 +1625,7 @@ 1 0 - 1 + 0 18 @@ -6962,7 +6962,7 @@ board-mtb4c-v1D3 - 0 + 1 0 0 0 diff --git a/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/proj/stm32hal.l4.uvprojx b/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/proj/stm32hal.l4.uvprojx index 12f02a3a1..4d6ee2a22 100644 --- a/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/proj/stm32hal.l4.uvprojx +++ b/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/proj/stm32hal.l4.uvprojx @@ -16,8 +16,8 @@ STM32L443RCIx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.7.0 + https://www.keil.com/pack/ IRAM(0x20000000,0x00010000) IROM(0x08000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE @@ -4065,8 +4065,8 @@ STM32L443RCIx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.7.0 + https://www.keil.com/pack/ IRAM(0x20000000,0x00010000) IROM(0x08000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE @@ -8114,8 +8114,8 @@ STM32L452RCIx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.7.0 + https://www.keil.com/pack/ IRAM(0x20000000,0x00020000) IRAM2(0x10000000,0x00008000) IROM(0x08000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 DSP CLOCK(12000000) ELITTLE @@ -12157,14 +12157,14 @@ mtb4c-v1D3 0x4 ARM-ADS - 6190000::V6.19::ARMCLANG + 6220000::V6.22::ARMCLANG 1 STM32L452RCIx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.7.0 + https://www.keil.com/pack/ IRAM(0x20000000,0x00020000) IRAM2(0x10000000,0x00008000) IROM(0x08000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 DSP CLOCK(12000000) ELITTLE @@ -16212,8 +16212,8 @@ STM32L476RGTx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.7.0 + https://www.keil.com/pack/ IRAM(0x20000000-0x20017FFF) IRAM2(0x10000000-0x10007FFF) IROM(0x8000000-0x80FFFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4") @@ -20261,8 +20261,8 @@ STM32L431KCUx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.7.0 + https://www.keil.com/pack/ IRAM(0x20000000,0x0000C000) IRAM2(0x10000000,0x00004000) IROM(0x08000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE @@ -24310,8 +24310,8 @@ STM32L452CEUx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.7.0 + https://www.keil.com/pack/ IRAM(0x20000000,0x00020000) IRAM2(0x10000000,0x00008000) IROM(0x08000000,0x00080000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE @@ -28719,8 +28719,8 @@ STM32L431KCUx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.7.0 + https://www.keil.com/pack/ IRAM(0x20000000,0x00010000) IROM(0x08000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE @@ -32990,8 +32990,8 @@ STM32L443RCIx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.7.0 + https://www.keil.com/pack/ IRAM(0x20000000,0x00010000) IROM(0x08000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE @@ -37039,8 +37039,8 @@ STM32L443RCIx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.7.0 + https://www.keil.com/pack/ IRAM(0x20000000,0x00010000) IROM(0x08000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE @@ -41088,8 +41088,8 @@ STM32L443RCIx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.7.0 + https://www.keil.com/pack/ IRAM(0x20000000,0x00010000) IROM(0x08000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE @@ -45137,8 +45137,8 @@ STM32L452RCIx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.7.0 + https://www.keil.com/pack/ IRAM(0x20000000,0x00020000) IRAM2(0x10000000,0x00008000) IROM(0x08000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 DSP CLOCK(12000000) ELITTLE @@ -49186,8 +49186,8 @@ STM32L452RCIx STMicroelectronics - Keil.STM32L4xx_DFP.2.6.1 - http://www.keil.com/pack/ + Keil.STM32L4xx_DFP.2.7.0 + https://www.keil.com/pack/ IRAM(0x20000000,0x00020000) IRAM2(0x10000000,0x00008000) IROM(0x08000000,0x00040000) CPUTYPE("Cortex-M4") FPU2 DSP CLOCK(12000000) ELITTLE diff --git a/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/src/board/mtb4/v1D3/inc/main.h b/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/src/board/mtb4/v1D3/inc/main.h index 738a2ba70..2a3462742 100644 --- a/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/src/board/mtb4/v1D3/inc/main.h +++ b/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/src/board/mtb4/v1D3/inc/main.h @@ -105,6 +105,8 @@ void Error_Handler(void); #define CAN1_SHDN_Pin GPIO_PIN_0 #define CAN1_SHDN_GPIO_Port GPIOB #define SDA2_Pin GPIO_PIN_6 +#define SDA4_GPIO_Port GPIOC +#define SDA4_Pin GPIO_PIN_0 #define SDA2_GPIO_Port GPIOA #define CAN1_STB_Pin GPIO_PIN_1 #define CAN1_STB_GPIO_Port GPIOB diff --git a/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/src/board/mtb4/v1D3/src/gpio.c b/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/src/board/mtb4/v1D3/src/gpio.c index 537c65fa2..57f647580 100644 --- a/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/src/board/mtb4/v1D3/src/gpio.c +++ b/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/src/board/mtb4/v1D3/src/gpio.c @@ -52,7 +52,10 @@ void MX_GPIO_Init(void) __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOH_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); - + __HAL_RCC_GPIOE_CLK_ENABLE(); +// __HAL_RCC_GPIOG_CLK_ENABLE(); +// __HAL_RCC_GPIOF_CLK_ENABLE(); + /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOC, BNO055_BOOT_Pin|BNO055_RESET_Pin|LED_RED_Pin|LED_BLUE_Pin, GPIO_PIN_RESET); @@ -86,7 +89,7 @@ void MX_GPIO_Init(void) /*Configure GPIO pins : PB4 PB3 PB5 PB15 PB2 PB12 */ - GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_3|GPIO_PIN_5|GPIO_PIN_15 + GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_15 |GPIO_PIN_2|GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; diff --git a/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/src/board/mtb4c/v1D3/src/gpio.c b/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/src/board/mtb4c/v1D3/src/gpio.c index 01e7aa72b..597a18dae 100644 --- a/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/src/board/mtb4c/v1D3/src/gpio.c +++ b/emBODY/eBcode/arch-arm/libs/lowlevel/stm32hal/src/board/mtb4c/v1D3/src/gpio.c @@ -87,7 +87,7 @@ void MX_GPIO_Init(void) /*Configure GPIO pins : PB4 PB3 PB5 PB15 PB2 PB12 */ - GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_3|GPIO_PIN_5|GPIO_PIN_15 + GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_15 |GPIO_PIN_2|GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL;