diff --git a/Expander/Expander.ioc b/Expander/Expander.ioc
index 3bf86c55..bf6d7553 100644
--- a/Expander/Expander.ioc
+++ b/Expander/Expander.ioc
@@ -1,226 +1,218 @@
#MicroXplorer Configuration settings - do not modify
-Mcu.Family=STM32F1
-Dma.SPI2_TX.2.PeriphInc=DMA_PINC_DISABLE
-ProjectManager.MainLocation=Src
-Dma.SPI2_TX.2.MemInc=DMA_MINC_ENABLE
-RCC.MCOFreq_Value=24000000
-Dma.SPI1_TX.1.Priority=DMA_PRIORITY_LOW
-PB13.GPIOParameters=GPIO_Label
-PA6.Mode=Full_Duplex_Master
-SPI2.VirtualNSS=VM_NSSHARD
-NVIC.DMA1_Channel5_IRQn=true\:0\:0\:false\:false\:true\:true\:true
-ProjectManager.KeepUserCode=true
-Mcu.UserName=STM32F100CBTx
-SPI1.VirtualType=VM_MASTER
-SPI2.VirtualType=VM_MASTER
-TIM1.IPParameters=Channel-Output Compare2 CH2,Pulse-Output Compare2 CH2,OCMode_2
-RCC.PLLCLKFreq_Value=24000000
-PB14.GPIO_Label=TLC_SOUT
-PA14.GPIO_Label=SWCLK
-ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_SPI1_Init-SPI1-false-HAL-true,5-MX_SPI2_Init-SPI2-false-HAL-true,6-MX_TIM1_Init-TIM1-false-HAL-true,7-MX_USART1_UART_Init-USART1-false-HAL-true
-PA9.GPIOParameters=GPIO_Speed,GPIO_Label
-PA11.GPIOParameters=GPIO_Label
+Dma.Request0=SPI1_RX
+Dma.Request1=SPI1_TX
+Dma.RequestsNb=2
+Dma.SPI1_RX.0.Direction=DMA_PERIPH_TO_MEMORY
+Dma.SPI1_RX.0.Instance=DMA1_Channel2
+Dma.SPI1_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE
+Dma.SPI1_RX.0.MemInc=DMA_MINC_ENABLE
+Dma.SPI1_RX.0.Mode=DMA_NORMAL
+Dma.SPI1_RX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
+Dma.SPI1_RX.0.PeriphInc=DMA_PINC_DISABLE
+Dma.SPI1_RX.0.Priority=DMA_PRIORITY_LOW
+Dma.SPI1_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
+Dma.SPI1_TX.1.Direction=DMA_MEMORY_TO_PERIPH
+Dma.SPI1_TX.1.Instance=DMA1_Channel3
+Dma.SPI1_TX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE
+Dma.SPI1_TX.1.MemInc=DMA_MINC_ENABLE
+Dma.SPI1_TX.1.Mode=DMA_NORMAL
+Dma.SPI1_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
Dma.SPI1_TX.1.PeriphInc=DMA_PINC_DISABLE
-RCC.ADCFreqValue=12000000
-PA6.GPIO_Label=MAX_DOUT
-USART1.IPParameters=VirtualMode
-PB13.GPIO_Label=TLC_SCLK
-PB13.Signal=SPI2_SCK
-PB15.Signal=SPI2_MOSI
-PinOutPanel.RotationAngle=0
-RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
-ProjectManager.StackSize=0x200
-RCC.PLLSource=RCC_PLLSOURCE_HSE
-PD1-OSC_OUT.Signal=RCC_OSC_OUT
-NVIC.DMA1_Channel3_IRQn=true\:0\:0\:false\:false\:true\:true\:true
-Mcu.IP4=SPI2
-RCC.FCLKCortexFreq_Value=24000000
-Mcu.IP5=SYS
-NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:true\:false
-Mcu.IP2=RCC
-Mcu.IP3=SPI1
+Dma.SPI1_TX.1.Priority=DMA_PRIORITY_LOW
+Dma.SPI1_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
+File.Version=6
+GPIO.groupedBy=Group By Peripherals
+KeepUserPlacement=false
+Mcu.Family=STM32F1
Mcu.IP0=DMA
Mcu.IP1=NVIC
-TIM1.Channel-Output\ Compare2\ CH2=TIM_CHANNEL_2
-Mcu.UserConstants=
-Dma.SPI1_RX.0.Direction=DMA_PERIPH_TO_MEMORY
-Mcu.ThirdPartyNb=0
-SPI1.Direction=SPI_DIRECTION_2LINES
-RCC.HCLKFreq_Value=24000000
+Mcu.IP2=RCC
+Mcu.IP3=SPI1
+Mcu.IP4=SPI2
+Mcu.IP5=SYS
+Mcu.IP6=TIM1
+Mcu.IP7=USART1
Mcu.IPNb=8
-ProjectManager.PreviousToolchain=
-RCC.APB2TimFreq_Value=24000000
-PB6.Signal=USART1_TX
-Dma.SPI2_TX.2.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
-SPI1.CalculateBaudRate=12.0 MBits/s
-PB6.Mode=Multiprocessor_communication
-PA8.GPIOParameters=GPIO_Label
-Mcu.Pin6=PB12
-Mcu.Pin7=PB13
-Mcu.Pin8=PB14
-Mcu.Pin9=PB15
-Dma.SPI2_TX.2.Instance=DMA1_Channel5
-RCC.AHBFreq_Value=24000000
-SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_2
+Mcu.Name=STM32F100C(8-B)Tx
+Mcu.Package=LQFP48
Mcu.Pin0=PD0-OSC_IN
Mcu.Pin1=PD1-OSC_OUT
+Mcu.Pin10=PA8
+Mcu.Pin11=PA9
+Mcu.Pin12=PA10
+Mcu.Pin13=PA11
+Mcu.Pin14=PA13
+Mcu.Pin15=PA14
+Mcu.Pin16=PB6
+Mcu.Pin17=PB7
+Mcu.Pin18=VP_SYS_VS_Systick
+Mcu.Pin19=VP_TIM1_VS_ClockSourceINT
Mcu.Pin2=PA4
Mcu.Pin3=PA5
Mcu.Pin4=PA6
Mcu.Pin5=PA7
-Dma.SPI1_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
-ProjectManager.ProjectBuild=false
-NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:true\:false
+Mcu.Pin6=PB12
+Mcu.Pin7=PB13
+Mcu.Pin8=PB14
+Mcu.Pin9=PB15
+Mcu.PinsNb=20
+Mcu.ThirdPartyNb=0
+Mcu.UserConstants=
+Mcu.UserName=STM32F100CBTx
+MxCube.Version=6.1.1
+MxDb.Version=DB.6.0.10
+NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:true\:false
+NVIC.DMA1_Channel2_IRQn=true\:0\:0\:false\:false\:true\:true\:true
+NVIC.DMA1_Channel3_IRQn=true\:0\:0\:false\:false\:true\:true\:true
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:true\:false
-PA8.Locked=true
-PA4.Locked=true
+NVIC.ForceEnableDMAVector=true
+NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:true\:false
+NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:true\:false
+NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:true\:false
+NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:false\:true\:false
+NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
+NVIC.SPI2_IRQn=true\:0\:0\:false\:false\:true\:true\:true
+NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:true\:false
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:true\:true
-RCC.PLLMUL=RCC_PLL_MUL3
-PB12.GPIO_Label=TLC_BLANK
-Dma.SPI1_RX.0.PeriphInc=DMA_PINC_DISABLE
-ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.4.0
-MxDb.Version=DB.4.0.160
-ProjectManager.BackupPrevious=false
-Dma.SPI1_TX.1.Mode=DMA_NORMAL
-PA14.Mode=Serial_Wire
-PB14.Mode=Full_Duplex_Master
-File.Version=6
+NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true
+NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:true\:false
+PA10.GPIOParameters=GPIO_Label
PA10.GPIO_Label=TLC_XLAT
-SPI2.CalculateBaudRate=12.0 MBits/s
-PB7.Signal=USART1_RX
-PA8.Signal=GPIO_Output
-NVIC.SPI2_IRQn=true\:0\:0\:false\:false\:true\:true\:true
-NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:false\:true\:false
-Dma.SPI2_TX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE
-Dma.RequestsNb=3
-ProjectManager.HalAssertFull=true
-VP_TIM1_VS_ClockSourceINT.Mode=Internal
-ProjectManager.ProjectName=Expander
-PA13.GPIOParameters=GPIO_Label
-RCC.PLLMCOFreq_Value=12000000
-Dma.SPI1_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
-Mcu.Package=LQFP48
-PA6.Signal=SPI1_MISO
-PB12.Mode=NSS_Signal_Hard_Output
-SPI2.Mode=SPI_MODE_MASTER
-Dma.SPI2_TX.2.Priority=DMA_PRIORITY_LOW
-ProjectManager.ToolChainLocation=
-Dma.SPI2_TX.2.Mode=DMA_NORMAL
-VP_SYS_VS_Systick.Signal=SYS_VS_Systick
+PA10.Locked=true
PA10.Signal=GPIO_Output
-PA5.GPIOParameters=GPIO_Label
-PB14.GPIOParameters=GPIO_Label
-Dma.Request2=SPI2_TX
-Dma.Request1=SPI1_TX
-RCC.APB1TimFreq_Value=24000000
-NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:true\:false
-SPI2.Direction=SPI_DIRECTION_2LINES
-PB13.Mode=Full_Duplex_Master
-NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true
-Dma.SPI2_TX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
-Dma.SPI1_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
-Dma.Request0=SPI1_RX
-SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_2
+PA11.GPIOParameters=GPIO_Label
+PA11.GPIO_Label=TLC_XERR
+PA11.Locked=true
+PA11.Signal=GPIO_Input
+PA13.GPIOParameters=GPIO_Label
+PA13.GPIO_Label=SWDIO
+PA13.Mode=Serial_Wire
+PA13.Signal=SYS_JTMS-SWDIO
+PA14.GPIOParameters=GPIO_Label
+PA14.GPIO_Label=SWCLK
+PA14.Mode=Serial_Wire
+PA14.Signal=SYS_JTCK-SWCLK
+PA4.GPIOParameters=GPIO_Label
PA4.GPIO_Label=MAX_nCS
-ProjectManager.CustomerFirmwarePackage=
-Dma.SPI1_TX.1.Instance=DMA1_Channel3
+PA4.Locked=true
+PA4.Signal=GPIO_Output
+PA5.GPIOParameters=GPIO_Label
+PA5.GPIO_Label=MAX_SCLK
PA5.Mode=Full_Duplex_Master
+PA5.Signal=SPI1_SCK
PA6.GPIOParameters=GPIO_Label
-Dma.SPI1_TX.1.MemInc=DMA_MINC_ENABLE
-ProjectManager.ProjectFileName=Expander.ioc
+PA6.GPIO_Label=MAX_DOUT
+PA6.Mode=Full_Duplex_Master
+PA6.Signal=SPI1_MISO
+PA7.GPIOParameters=GPIO_Label
+PA7.GPIO_Label=MAX_DIN
PA7.Mode=Full_Duplex_Master
-PD1-OSC_OUT.Mode=HSE-External-Oscillator
-Mcu.PinsNb=20
-ProjectManager.NoMain=false
-SPI1.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction
-PA9.GPIO_Label=TLC_GSCLK
-TIM1.OCMode_2=TIM_OCMODE_TOGGLE
-PA11.GPIO_Label=TLC_XERR
-ProjectManager.DefaultFWLocation=true
-PD0-OSC_IN.Signal=RCC_OSC_IN
-ProjectManager.DeletePrevious=true
-Dma.SPI1_RX.0.Mode=DMA_NORMAL
-Dma.SPI1_TX.1.Direction=DMA_MEMORY_TO_PERIPH
-RCC.FamilyName=M
-PA13.Signal=SYS_JTMS-SWDIO
-Dma.SPI1_TX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE
-PA11.Locked=true
+PA7.Signal=SPI1_MOSI
+PA8.GPIOParameters=GPIO_Label
PA8.GPIO_Label=TLC_MODE
-NVIC.DMA1_Channel2_IRQn=true\:0\:0\:false\:false\:true\:true\:true
-ProjectManager.TargetToolchain=Other Toolchains (GPDSC)
-Dma.SPI2_TX.2.Direction=DMA_MEMORY_TO_PERIPH
+PA8.Locked=true
+PA8.Signal=GPIO_Output
+PA9.GPIOParameters=GPIO_Speed,GPIO_Label
+PA9.GPIO_Label=TLC_GSCLK
+PA9.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PA9.Signal=S_TIM1_CH2
-VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT
-SPI2.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualNSS,VirtualType,Direction
-ProjectManager.RegisterCallBack=
-SH.S_TIM1_CH2.ConfNb=1
-PD0-OSC_IN.Mode=HSE-External-Oscillator
+PB12.GPIOParameters=GPIO_Label
+PB12.GPIO_Label=TLC_BLANK
+PB12.Mode=NSS_Signal_Hard_Output
+PB12.Signal=SPI2_NSS
+PB13.GPIOParameters=GPIO_Label
+PB13.GPIO_Label=TLC_SCLK
+PB13.Mode=Full_Duplex_Master
+PB13.Signal=SPI2_SCK
+PB14.GPIOParameters=GPIO_Label
+PB14.GPIO_Label=TLC_SOUT
+PB14.Mode=Full_Duplex_Master
PB14.Signal=SPI2_MISO
-PA5.Signal=SPI1_SCK
-board=Expander
-ProjectManager.LastFirmware=true
-PB15.Mode=Full_Duplex_Master
-RCC.VCOOutput2Freq_Value=8000000
-RCC.APB2Freq_Value=24000000
-MxCube.Version=4.16.0
-SH.S_TIM1_CH2.0=TIM1_CH2,Output Compare2 CH2
-PB15.GPIO_Label=TLC_SIN
-SPI1.Mode=SPI_MODE_MASTER
-Dma.SPI1_RX.0.Instance=DMA1_Channel2
-PA10.GPIOParameters=GPIO_Label
-VP_SYS_VS_Systick.Mode=SysTick
-Dma.SPI1_RX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
-Dma.SPI1_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE
-NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:true\:false
-PA4.GPIOParameters=GPIO_Label
PB15.GPIOParameters=GPIO_Label
-PA13.Mode=Serial_Wire
-ProjectManager.FreePins=true
-RCC.IPParameters=ADCFreqValue,AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,MCOFreq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,PLLMUL,PLLSource,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,VCOOutput2Freq_Value
+PB15.GPIO_Label=TLC_SIN
+PB15.Mode=Full_Duplex_Master
+PB15.Signal=SPI2_MOSI
+PB6.Mode=Asynchronous
+PB6.Signal=USART1_TX
+PB7.Mode=Asynchronous
+PB7.Signal=USART1_RX
+PD0-OSC_IN.Mode=HSE-External-Oscillator
+PD0-OSC_IN.Signal=RCC_OSC_IN
+PD1-OSC_OUT.Mode=HSE-External-Oscillator
+PD1-OSC_OUT.Signal=RCC_OSC_OUT
+PinOutPanel.RotationAngle=0
ProjectManager.AskForMigrate=true
-Mcu.Name=STM32F100C(8-B)Tx
-Dma.SPI1_RX.0.MemInc=DMA_MINC_ENABLE
-PA13.GPIO_Label=SWDIO
-ProjectManager.UnderRoot=false
-Mcu.IP6=TIM1
-Mcu.IP7=USART1
-ProjectManager.CoupleFile=false
-PA4.Signal=GPIO_Output
-RCC.SYSCLKFreq_VALUE=24000000
-TIM1.Pulse-Output\ Compare2\ CH2=32765
-RCC.TimSysFreq_Value=24000000
-PA7.GPIO_Label=MAX_DIN
-PA10.Locked=true
-PA5.GPIO_Label=MAX_SCLK
-NVIC.ForceEnableDMAVector=true
-KeepUserPlacement=false
-PA14.GPIOParameters=GPIO_Label
-NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:true\:false
-USART1.VirtualMode=VM_ASYNC
+ProjectManager.BackupPrevious=false
ProjectManager.CompilerOptimize=2
-PB7.Mode=Multiprocessor_communication
-PA11.Signal=GPIO_Input
-PA14.Signal=SYS_JTCK-SWCLK
-ProjectManager.HeapSize=0x400
-Mcu.Pin15=PA14
-NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:true\:false
-Mcu.Pin16=PB6
-Mcu.Pin13=PA11
-Mcu.Pin14=PA13
-Mcu.Pin19=VP_TIM1_VS_ClockSourceINT
-Dma.SPI1_RX.0.Priority=DMA_PRIORITY_LOW
ProjectManager.ComputerToolchain=false
-Mcu.Pin17=PB7
-Mcu.Pin18=VP_SYS_VS_Systick
-NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
-Mcu.Pin11=PA9
-Mcu.Pin12=PA10
-Mcu.Pin10=PA8
-PA9.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
-RCC.APB1Freq_Value=24000000
-PA7.GPIOParameters=GPIO_Label
+ProjectManager.CoupleFile=false
+ProjectManager.CustomerFirmwarePackage=
+ProjectManager.DefaultFWLocation=true
+ProjectManager.DeletePrevious=true
ProjectManager.DeviceId=STM32F100CBTx
-PB12.GPIOParameters=GPIO_Label
-PB12.Signal=SPI2_NSS
+ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.8.3
+ProjectManager.FreePins=true
+ProjectManager.HalAssertFull=true
+ProjectManager.HeapSize=0x400
+ProjectManager.KeepUserCode=true
+ProjectManager.LastFirmware=true
ProjectManager.LibraryCopy=1
-PA7.Signal=SPI1_MOSI
+ProjectManager.MainLocation=Src
+ProjectManager.NoMain=false
+ProjectManager.PreviousToolchain=
+ProjectManager.ProjectBuild=false
+ProjectManager.ProjectFileName=Expander.ioc
+ProjectManager.ProjectName=Expander
+ProjectManager.RegisterCallBack=
+ProjectManager.StackSize=0x200
+ProjectManager.TargetToolchain=Other Toolchains (GPDSC)
+ProjectManager.ToolChainLocation=
+ProjectManager.UnderRoot=false
+ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_SPI1_Init-SPI1-false-HAL-true,5-MX_SPI2_Init-SPI2-false-HAL-true,6-MX_TIM1_Init-TIM1-false-HAL-true,7-MX_USART1_UART_Init-USART1-false-HAL-true
+RCC.ADCFreqValue=12000000
+RCC.AHBFreq_Value=24000000
+RCC.APB1Freq_Value=24000000
+RCC.APB1TimFreq_Value=24000000
+RCC.APB2Freq_Value=24000000
+RCC.APB2TimFreq_Value=24000000
+RCC.FCLKCortexFreq_Value=24000000
+RCC.FamilyName=M
+RCC.HCLKFreq_Value=24000000
+RCC.IPParameters=ADCFreqValue,AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,MCOFreq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,PLLMUL,PLLSource,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,VCOOutput2Freq_Value
+RCC.MCOFreq_Value=24000000
+RCC.PLLCLKFreq_Value=24000000
+RCC.PLLMCOFreq_Value=12000000
+RCC.PLLMUL=RCC_PLL_MUL3
+RCC.PLLSource=RCC_PLLSOURCE_HSE
+RCC.SYSCLKFreq_VALUE=24000000
+RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
+RCC.TimSysFreq_Value=24000000
+RCC.VCOOutput2Freq_Value=8000000
+SH.S_TIM1_CH2.0=TIM1_CH2,Output Compare2 CH2
+SH.S_TIM1_CH2.ConfNb=1
+SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_2
+SPI1.CalculateBaudRate=12.0 MBits/s
+SPI1.Direction=SPI_DIRECTION_2LINES
+SPI1.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction
+SPI1.Mode=SPI_MODE_MASTER
+SPI1.VirtualType=VM_MASTER
+SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_2
+SPI2.CalculateBaudRate=12.0 MBits/s
+SPI2.Direction=SPI_DIRECTION_2LINES
+SPI2.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualNSS,VirtualType,Direction
+SPI2.Mode=SPI_MODE_MASTER
+SPI2.VirtualNSS=VM_NSSHARD
+SPI2.VirtualType=VM_MASTER
+TIM1.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_DISABLE
+TIM1.Channel-Output\ Compare2\ CH2=TIM_CHANNEL_2
+TIM1.IPParameters=Channel-Output Compare2 CH2,Pulse-Output Compare2 CH2,OCMode_2,Period,AutoReloadPreload
+TIM1.OCMode_2=TIM_OCMODE_TOGGLE
+TIM1.Period=2
+TIM1.Pulse-Output\ Compare2\ CH2=32765
+USART1.IPParameters=VirtualMode
+USART1.VirtualMode=VM_ASYNC
+VP_SYS_VS_Systick.Mode=SysTick
+VP_SYS_VS_Systick.Signal=SYS_VS_Systick
+VP_TIM1_VS_ClockSourceINT.Mode=Internal
+VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT
+board=Expander
diff --git a/Expander/Inc/HAL_TLC5946.h b/Expander/Inc/HAL_TLC5946.h
index 7aee71ef..f0812535 100644
--- a/Expander/Inc/HAL_TLC5946.h
+++ b/Expander/Inc/HAL_TLC5946.h
@@ -5,7 +5,7 @@
extern "C" {
#endif
-#include "stm32f1xx_hal.h"
+#include "device.h"
// LED Mapping
#define LED_1 15
diff --git a/Expander/Inc/main.h b/Expander/Inc/main.h
new file mode 100644
index 00000000..c27c0eb0
--- /dev/null
+++ b/Expander/Inc/main.h
@@ -0,0 +1,104 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file : main.h
+ * @brief : Header for main.c file.
+ * This file contains the common defines of the application.
+ ******************************************************************************
+ * @attention
+ *
+ *
© Copyright (c) 2021 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __MAIN_H
+#define __MAIN_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f1xx_hal.h"
+
+/* Private includes ----------------------------------------------------------*/
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+/* Exported types ------------------------------------------------------------*/
+/* USER CODE BEGIN ET */
+
+/* USER CODE END ET */
+
+/* Exported constants --------------------------------------------------------*/
+/* USER CODE BEGIN EC */
+
+/* USER CODE END EC */
+
+/* Exported macro ------------------------------------------------------------*/
+/* USER CODE BEGIN EM */
+
+/* USER CODE END EM */
+
+void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
+
+/* Exported functions prototypes ---------------------------------------------*/
+void Error_Handler(void);
+
+/* USER CODE BEGIN EFP */
+
+/* USER CODE END EFP */
+
+/* Private defines -----------------------------------------------------------*/
+#define MAX_nCS_Pin GPIO_PIN_4
+#define MAX_nCS_GPIO_Port GPIOA
+#define MAX_SCLK_Pin GPIO_PIN_5
+#define MAX_SCLK_GPIO_Port GPIOA
+#define MAX_DOUT_Pin GPIO_PIN_6
+#define MAX_DOUT_GPIO_Port GPIOA
+#define MAX_DIN_Pin GPIO_PIN_7
+#define MAX_DIN_GPIO_Port GPIOA
+#define TLC_BLANK_Pin GPIO_PIN_12
+#define TLC_BLANK_GPIO_Port GPIOB
+#define TLC_SCLK_Pin GPIO_PIN_13
+#define TLC_SCLK_GPIO_Port GPIOB
+#define TLC_SOUT_Pin GPIO_PIN_14
+#define TLC_SOUT_GPIO_Port GPIOB
+#define TLC_SIN_Pin GPIO_PIN_15
+#define TLC_SIN_GPIO_Port GPIOB
+#define TLC_MODE_Pin GPIO_PIN_8
+#define TLC_MODE_GPIO_Port GPIOA
+#define TLC_GSCLK_Pin GPIO_PIN_9
+#define TLC_GSCLK_GPIO_Port GPIOA
+#define TLC_XLAT_Pin GPIO_PIN_10
+#define TLC_XLAT_GPIO_Port GPIOA
+#define TLC_XERR_Pin GPIO_PIN_11
+#define TLC_XERR_GPIO_Port GPIOA
+#define SWDIO_Pin GPIO_PIN_13
+#define SWDIO_GPIO_Port GPIOA
+#define SWCLK_Pin GPIO_PIN_14
+#define SWCLK_GPIO_Port GPIOA
+/* USER CODE BEGIN Private defines */
+
+#define MAX_CS_GPIO_Port MAX_nCS_GPIO_Port
+#define MAX_CS_Pin MAX_nCS_Pin
+
+/* USER CODE END Private defines */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MAIN_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Expander/Inc/mxconstants.h b/Expander/Inc/mxconstants.h
deleted file mode 100644
index 7dd92720..00000000
--- a/Expander/Inc/mxconstants.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- ******************************************************************************
- * File Name : mxconstants.h
- * Description : This file contains the common defines of the application
- ******************************************************************************
- *
- * COPYRIGHT(c) 2020 STMicroelectronics
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __MXCONSTANT_H
-#define __MXCONSTANT_H
- /* Includes ------------------------------------------------------------------*/
-
-/* USER CODE BEGIN Includes */
-
-/* USER CODE END Includes */
-
-/* Private define ------------------------------------------------------------*/
-
-#define MAX_nCS_Pin GPIO_PIN_4
-#define MAX_nCS_GPIO_Port GPIOA
-#define MAX_SCLK_Pin GPIO_PIN_5
-#define MAX_SCLK_GPIO_Port GPIOA
-#define MAX_DOUT_Pin GPIO_PIN_6
-#define MAX_DOUT_GPIO_Port GPIOA
-#define MAX_DIN_Pin GPIO_PIN_7
-#define MAX_DIN_GPIO_Port GPIOA
-#define TLC_BLANK_Pin GPIO_PIN_12
-#define TLC_BLANK_GPIO_Port GPIOB
-#define TLC_SCLK_Pin GPIO_PIN_13
-#define TLC_SCLK_GPIO_Port GPIOB
-#define TLC_SOUT_Pin GPIO_PIN_14
-#define TLC_SOUT_GPIO_Port GPIOB
-#define TLC_SIN_Pin GPIO_PIN_15
-#define TLC_SIN_GPIO_Port GPIOB
-#define TLC_MODE_Pin GPIO_PIN_8
-#define TLC_MODE_GPIO_Port GPIOA
-#define TLC_GSCLK_Pin GPIO_PIN_9
-#define TLC_GSCLK_GPIO_Port GPIOA
-#define TLC_XLAT_Pin GPIO_PIN_10
-#define TLC_XLAT_GPIO_Port GPIOA
-#define TLC_XERR_Pin GPIO_PIN_11
-#define TLC_XERR_GPIO_Port GPIOA
-#define SWDIO_Pin GPIO_PIN_13
-#define SWDIO_GPIO_Port GPIOA
-#define SWCLK_Pin GPIO_PIN_14
-#define SWCLK_GPIO_Port GPIOA
-/* USER CODE BEGIN Private defines */
-
-#define MAX_CS_GPIO_Port MAX_nCS_GPIO_Port
-#define MAX_CS_Pin MAX_nCS_Pin
-
-/* USER CODE END Private defines */
-
-/**
- * @}
- */
-
-/**
- * @}
-*/
-
-#endif /* __MXCONSTANT_H */
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Expander/Inc/stm32f1xx_hal_conf.h b/Expander/Inc/stm32f1xx_hal_conf.h
index 6064cb51..a688c432 100644
--- a/Expander/Inc/stm32f1xx_hal_conf.h
+++ b/Expander/Inc/stm32f1xx_hal_conf.h
@@ -5,29 +5,13 @@
******************************************************************************
* @attention
*
- * © COPYRIGHT(c) 2020 STMicroelectronics
+ * © Copyright (c) 2017 STMicroelectronics.
+ * All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
@@ -40,8 +24,6 @@
extern "C" {
#endif
-#include "mxconstants.h"
-
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
@@ -49,9 +31,12 @@
/**
* @brief This is the list of modules to be used in the HAL driver
*/
+
#define HAL_MODULE_ENABLED
-/*#define HAL_ADC_MODULE_ENABLED */
+ /*#define HAL_ADC_MODULE_ENABLED */
+/*#define HAL_CRYP_MODULE_ENABLED */
/*#define HAL_CAN_MODULE_ENABLED */
+/*#define HAL_CAN_LEGACY_MODULE_ENABLED */
/*#define HAL_CEC_MODULE_ENABLED */
/*#define HAL_CORTEX_MODULE_ENABLED */
/*#define HAL_CRC_MODULE_ENABLED */
@@ -73,6 +58,7 @@
/*#define HAL_RCC_MODULE_ENABLED */
/*#define HAL_RTC_MODULE_ENABLED */
/*#define HAL_SD_MODULE_ENABLED */
+/*#define HAL_MMC_MODULE_ENABLED */
/*#define HAL_SDRAM_MODULE_ENABLED */
/*#define HAL_SMARTCARD_MODULE_ENABLED */
#define HAL_SPI_MODULE_ENABLED
@@ -85,6 +71,7 @@
#define HAL_CORTEX_MODULE_ENABLED
#define HAL_DMA_MODULE_ENABLED
#define HAL_FLASH_MODULE_ENABLED
+#define HAL_EXTI_MODULE_ENABLED
#define HAL_GPIO_MODULE_ENABLED
#define HAL_PWR_MODULE_ENABLED
#define HAL_RCC_MODULE_ENABLED
@@ -96,11 +83,11 @@
* (when HSE is used as system clock source, directly or through the PLL).
*/
#if !defined (HSE_VALUE)
- #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
+ #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */
#if !defined (HSE_STARTUP_TIMEOUT)
- #define HSE_STARTUP_TIMEOUT ((uint32_t)100) /*!< Time out for HSE start up, in ms */
+ #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */
/**
@@ -109,19 +96,28 @@
* (when HSI is used as system clock source, directly or through the PLL).
*/
#if !defined (HSI_VALUE)
- #define HSI_VALUE ((uint32_t)8000000) /*!< Value of the Internal oscillator in Hz*/
+ #define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz*/
#endif /* HSI_VALUE */
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature. */
+
/**
* @brief External Low Speed oscillator (LSE) value.
* This value is used by the UART, RTC HAL module to compute the system frequency
*/
#if !defined (LSE_VALUE)
- #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External oscillator in Hz*/
+ #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/
#endif /* LSE_VALUE */
#if !defined (LSE_STARTUP_TIMEOUT)
- #define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */
+ #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
#endif /* LSE_STARTUP_TIMEOUT */
/* Tip: To avoid modifying this file each time you need to use different HSE,
@@ -131,47 +127,71 @@
/**
* @brief This is the HAL system configuration section
*/
-#define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */
-#define TICK_INT_PRIORITY ((uint32_t)0) /*!< tick interrupt priority (lowest by default) */
-#define USE_RTOS 0
-#define PREFETCH_ENABLE 1
+#define VDD_VALUE 3300U /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY 0U /*!< tick interrupt priority (lowest by default) */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+
+#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
+#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
+#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
+#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
+#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
+#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
+#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
+#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
+#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
+#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
+#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
+#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
+#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
+#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
+#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
+#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
+#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
+#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
+#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
+#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
+#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
+#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
+#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
/* ########################## Assert Selection ############################## */
/**
* @brief Uncomment the line below to expanse the "assert_param" macro in the
* HAL drivers code
*/
- #define USE_FULL_ASSERT 1
+ #define USE_FULL_ASSERT 1U
/* ################## Ethernet peripheral configuration ##################### */
/* Section 1 : Ethernet peripheral configuration */
/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
-#define MAC_ADDR0 2
-#define MAC_ADDR1 0
-#define MAC_ADDR2 0
-#define MAC_ADDR3 0
-#define MAC_ADDR4 0
-#define MAC_ADDR5 0
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
/* Definition of the Ethernet driver buffers size and count */
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
-#define ETH_RXBUFNB ((uint32_t)8) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
-#define ETH_TXBUFNB ((uint32_t)4) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
+#define ETH_RXBUFNB 8U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
/* Section 2: PHY configuration section */
/* DP83848_PHY_ADDRESS Address*/
#define DP83848_PHY_ADDRESS 0x01U
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
-#define PHY_RESET_DELAY ((uint32_t)0x000000FF)
+#define PHY_RESET_DELAY 0x000000FFU
/* PHY Configuration delay */
-#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFF)
+#define PHY_CONFIG_DELAY 0x00000FFFU
-#define PHY_READ_TO ((uint32_t)0x0000FFFF)
-#define PHY_WRITE_TO ((uint32_t)0x0000FFFF)
+#define PHY_READ_TO 0x0000FFFFU
+#define PHY_WRITE_TO 0x0000FFFFU
/* Section 3: Common PHY Registers */
@@ -194,20 +214,19 @@
#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
/* Section 4: Extended PHY Registers */
+#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */
-#define PHY_SR ((uint16_t)0x10) /*!< PHY status register Offset */
-#define PHY_MICR ((uint16_t)0x11) /*!< MII Interrupt Control Register */
-#define PHY_MISR ((uint16_t)0x12) /*!< MII Interrupt Status and Misc. Control Register */
+#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */
-#define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */
-#define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */
-#define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */
+/* ################## SPI peripheral configuration ########################## */
-#define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */
-#define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
-#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */
-#define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */
+#define USE_SPI_CRC 0U
/* Includes ------------------------------------------------------------------*/
/**
@@ -215,140 +234,152 @@
*/
#ifdef HAL_RCC_MODULE_ENABLED
- #include "stm32f1xx_hal_rcc.h"
+#include "stm32f1xx_hal_rcc.h"
#endif /* HAL_RCC_MODULE_ENABLED */
#ifdef HAL_GPIO_MODULE_ENABLED
- #include "stm32f1xx_hal_gpio.h"
+#include "stm32f1xx_hal_gpio.h"
#endif /* HAL_GPIO_MODULE_ENABLED */
+#ifdef HAL_EXTI_MODULE_ENABLED
+#include "stm32f1xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
#ifdef HAL_DMA_MODULE_ENABLED
- #include "stm32f1xx_hal_dma.h"
+#include "stm32f1xx_hal_dma.h"
#endif /* HAL_DMA_MODULE_ENABLED */
#ifdef HAL_ETH_MODULE_ENABLED
- #include "stm32f1xx_hal_eth.h"
+#include "stm32f1xx_hal_eth.h"
#endif /* HAL_ETH_MODULE_ENABLED */
#ifdef HAL_CAN_MODULE_ENABLED
- #include "stm32f1xx_hal_can.h"
+#include "stm32f1xx_hal_can.h"
#endif /* HAL_CAN_MODULE_ENABLED */
+#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
+ #include "Legacy/stm32f1xx_hal_can_legacy.h"
+#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
+
#ifdef HAL_CEC_MODULE_ENABLED
- #include "stm32f1xx_hal_cec.h"
+#include "stm32f1xx_hal_cec.h"
#endif /* HAL_CEC_MODULE_ENABLED */
#ifdef HAL_CORTEX_MODULE_ENABLED
- #include "stm32f1xx_hal_cortex.h"
+#include "stm32f1xx_hal_cortex.h"
#endif /* HAL_CORTEX_MODULE_ENABLED */
#ifdef HAL_ADC_MODULE_ENABLED
- #include "stm32f1xx_hal_adc.h"
+#include "stm32f1xx_hal_adc.h"
#endif /* HAL_ADC_MODULE_ENABLED */
#ifdef HAL_CRC_MODULE_ENABLED
- #include "stm32f1xx_hal_crc.h"
+#include "stm32f1xx_hal_crc.h"
#endif /* HAL_CRC_MODULE_ENABLED */
#ifdef HAL_DAC_MODULE_ENABLED
- #include "stm32f1xx_hal_dac.h"
+#include "stm32f1xx_hal_dac.h"
#endif /* HAL_DAC_MODULE_ENABLED */
#ifdef HAL_FLASH_MODULE_ENABLED
- #include "stm32f1xx_hal_flash.h"
+#include "stm32f1xx_hal_flash.h"
#endif /* HAL_FLASH_MODULE_ENABLED */
#ifdef HAL_SRAM_MODULE_ENABLED
- #include "stm32f1xx_hal_sram.h"
+#include "stm32f1xx_hal_sram.h"
#endif /* HAL_SRAM_MODULE_ENABLED */
#ifdef HAL_NOR_MODULE_ENABLED
- #include "stm32f1xx_hal_nor.h"
+#include "stm32f1xx_hal_nor.h"
#endif /* HAL_NOR_MODULE_ENABLED */
#ifdef HAL_I2C_MODULE_ENABLED
- #include "stm32f1xx_hal_i2c.h"
+#include "stm32f1xx_hal_i2c.h"
#endif /* HAL_I2C_MODULE_ENABLED */
#ifdef HAL_I2S_MODULE_ENABLED
- #include "stm32f1xx_hal_i2s.h"
+#include "stm32f1xx_hal_i2s.h"
#endif /* HAL_I2S_MODULE_ENABLED */
#ifdef HAL_IWDG_MODULE_ENABLED
- #include "stm32f1xx_hal_iwdg.h"
+#include "stm32f1xx_hal_iwdg.h"
#endif /* HAL_IWDG_MODULE_ENABLED */
#ifdef HAL_PWR_MODULE_ENABLED
- #include "stm32f1xx_hal_pwr.h"
+#include "stm32f1xx_hal_pwr.h"
#endif /* HAL_PWR_MODULE_ENABLED */
#ifdef HAL_RTC_MODULE_ENABLED
- #include "stm32f1xx_hal_rtc.h"
+#include "stm32f1xx_hal_rtc.h"
#endif /* HAL_RTC_MODULE_ENABLED */
#ifdef HAL_PCCARD_MODULE_ENABLED
- #include "stm32f1xx_hal_pccard.h"
+#include "stm32f1xx_hal_pccard.h"
#endif /* HAL_PCCARD_MODULE_ENABLED */
#ifdef HAL_SD_MODULE_ENABLED
- #include "stm32f1xx_hal_sd.h"
+#include "stm32f1xx_hal_sd.h"
#endif /* HAL_SD_MODULE_ENABLED */
#ifdef HAL_NAND_MODULE_ENABLED
- #include "stm32f1xx_hal_nand.h"
+#include "stm32f1xx_hal_nand.h"
#endif /* HAL_NAND_MODULE_ENABLED */
#ifdef HAL_SPI_MODULE_ENABLED
- #include "stm32f1xx_hal_spi.h"
+#include "stm32f1xx_hal_spi.h"
#endif /* HAL_SPI_MODULE_ENABLED */
#ifdef HAL_TIM_MODULE_ENABLED
- #include "stm32f1xx_hal_tim.h"
+#include "stm32f1xx_hal_tim.h"
#endif /* HAL_TIM_MODULE_ENABLED */
#ifdef HAL_UART_MODULE_ENABLED
- #include "stm32f1xx_hal_uart.h"
+#include "stm32f1xx_hal_uart.h"
#endif /* HAL_UART_MODULE_ENABLED */
#ifdef HAL_USART_MODULE_ENABLED
- #include "stm32f1xx_hal_usart.h"
+#include "stm32f1xx_hal_usart.h"
#endif /* HAL_USART_MODULE_ENABLED */
#ifdef HAL_IRDA_MODULE_ENABLED
- #include "stm32f1xx_hal_irda.h"
+#include "stm32f1xx_hal_irda.h"
#endif /* HAL_IRDA_MODULE_ENABLED */
#ifdef HAL_SMARTCARD_MODULE_ENABLED
- #include "stm32f1xx_hal_smartcard.h"
+#include "stm32f1xx_hal_smartcard.h"
#endif /* HAL_SMARTCARD_MODULE_ENABLED */
#ifdef HAL_WWDG_MODULE_ENABLED
- #include "stm32f1xx_hal_wwdg.h"
+#include "stm32f1xx_hal_wwdg.h"
#endif /* HAL_WWDG_MODULE_ENABLED */
#ifdef HAL_PCD_MODULE_ENABLED
- #include "stm32f1xx_hal_pcd.h"
+#include "stm32f1xx_hal_pcd.h"
#endif /* HAL_PCD_MODULE_ENABLED */
#ifdef HAL_HCD_MODULE_ENABLED
- #include "stm32f1xx_hal_hcd.h"
+#include "stm32f1xx_hal_hcd.h"
#endif /* HAL_HCD_MODULE_ENABLED */
+#ifdef HAL_MMC_MODULE_ENABLED
+#include "stm32f1xx_hal_mmc.h"
+#endif /* HAL_MMC_MODULE_ENABLED */
+
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
- * @param expr: If expr is false, it calls assert_failed function
+ * @param expr If expr is false, it calls assert_failed function
* which reports the name of the source file and the source
* line number of the call that failed.
* If expr is true, it returns no value.
* @retval None
*/
- #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
+#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
- void assert_failed(uint8_t* file, uint32_t line);
+void assert_failed(uint8_t* file, uint32_t line);
#else
- #define assert_param(expr) ((void)0)
+#define assert_param(expr) ((void)0U)
#endif /* USE_FULL_ASSERT */
#ifdef __cplusplus
diff --git a/Expander/Inc/stm32f1xx_it.h b/Expander/Inc/stm32f1xx_it.h
index d9cd75e8..de9f0f34 100644
--- a/Expander/Inc/stm32f1xx_it.h
+++ b/Expander/Inc/stm32f1xx_it.h
@@ -1,35 +1,22 @@
+/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f1xx_it.h
* @brief This file contains the headers of the interrupt handlers.
******************************************************************************
+ * @attention
*
- * COPYRIGHT(c) 2020 STMicroelectronics
+ * © Copyright (c) 2021 STMicroelectronics.
+ * All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
+ ******************************************************************************
*/
+/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F1xx_IT_H
@@ -39,18 +26,35 @@
extern "C" {
#endif
-/* Includes ------------------------------------------------------------------*/
+/* Private includes ----------------------------------------------------------*/
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
/* Exported types ------------------------------------------------------------*/
+/* USER CODE BEGIN ET */
+
+/* USER CODE END ET */
+
/* Exported constants --------------------------------------------------------*/
+/* USER CODE BEGIN EC */
+
+/* USER CODE END EC */
+
/* Exported macro ------------------------------------------------------------*/
-/* Exported functions ------------------------------------------------------- */
+/* USER CODE BEGIN EM */
+/* USER CODE END EM */
+
+/* Exported functions prototypes ---------------------------------------------*/
void SysTick_Handler(void);
void DMA1_Channel2_IRQHandler(void);
void DMA1_Channel3_IRQHandler(void);
-void DMA1_Channel5_IRQHandler(void);
void SPI2_IRQHandler(void);
void USART1_IRQHandler(void);
+/* USER CODE BEGIN EFP */
+
+/* USER CODE END EFP */
#ifdef __cplusplus
}
diff --git a/Expander/MDK-ARM/test.c b/Expander/MDK-ARM/test.c
deleted file mode 100644
index 351687e4..00000000
--- a/Expander/MDK-ARM/test.c
+++ /dev/null
@@ -1,78 +0,0 @@
-#include "stm32f1xx_hal.h"
-#include "HAL_MAX11300.h"
-#include "HAL_TLC5946.h"
-
-void setup(void);
-void run(void);
-
-uint16_t rgADCValues[20];
-uint16_t rgDACValues[20];
-
-void setup()
-{
- MAX11300_setDeviceControl(DCR_DACCTL_ImmUpdate|DCR_DACREF_Int|DCR_ADCCTL_ContSweep/*|DCR_BRST_Contextual*/);
-
-/*
- MAX11300_setPortMode(PORT_1, PCR_Range_ADC_0_P10|PCR_Mode_ADC_SgEn_PosIn|PCR_ADCSamples_16|PCR_ADCref_INT);
- MAX11300_setPortMode(PORT_3, PCR_Range_ADC_0_P10|PCR_Mode_ADC_SgEn_PosIn|PCR_ADCSamples_16|PCR_ADCref_INT);
- MAX11300_setPortMode(PORT_7, PCR_Range_ADC_0_P10|PCR_Mode_ADC_SgEn_PosIn|PCR_ADCSamples_16|PCR_ADCref_INT);
- MAX11300_setPortMode(PORT_9, PCR_Range_ADC_0_P10|PCR_Mode_ADC_SgEn_PosIn|PCR_ADCSamples_16|PCR_ADCref_INT);
- MAX11300_setPortMode(PORT_10, PCR_Range_ADC_0_P10|PCR_Mode_ADC_SgEn_PosIn|PCR_ADCSamples_16|PCR_ADCref_INT);
- MAX11300_setPortMode(PORT_11, PCR_Range_ADC_0_P10|PCR_Mode_ADC_SgEn_PosIn|PCR_ADCSamples_16|PCR_ADCref_INT);
- MAX11300_setPortMode(PORT_12, PCR_Range_ADC_0_P10|PCR_Mode_ADC_SgEn_PosIn|PCR_ADCSamples_16|PCR_ADCref_INT);
- MAX11300_setPortMode(PORT_13, PCR_Range_ADC_0_P10|PCR_Mode_ADC_SgEn_PosIn|PCR_ADCSamples_16|PCR_ADCref_INT);
- MAX11300_setPortMode(PORT_14, PCR_Range_ADC_0_P10|PCR_Mode_ADC_SgEn_PosIn|PCR_ADCSamples_16|PCR_ADCref_INT);
- MAX11300_setPortMode(PORT_15, PCR_Range_ADC_0_P10|PCR_Mode_ADC_SgEn_PosIn|PCR_ADCSamples_16|PCR_ADCref_INT);
-*/
-
- MAX11300_setPortMode(PORT_1, PCR_Range_DAC_0_P10|PCR_Mode_DAC);
- MAX11300_setPortMode(PORT_3, PCR_Range_DAC_0_P10|PCR_Mode_DAC);
- MAX11300_setPortMode(PORT_5, PCR_Range_DAC_0_P10|PCR_Mode_DAC);
- MAX11300_setPortMode(PORT_7, PCR_Range_DAC_0_P10|PCR_Mode_DAC);
- MAX11300_setPortMode(PORT_9, PCR_Range_DAC_0_P10|PCR_Mode_DAC);
- MAX11300_setPortMode(PORT_10, PCR_Range_DAC_0_P10|PCR_Mode_DAC);
- MAX11300_setPortMode(PORT_11, PCR_Range_DAC_0_P10|PCR_Mode_DAC);
- MAX11300_setPortMode(PORT_12, PCR_Range_DAC_0_P10|PCR_Mode_DAC);
- MAX11300_setPortMode(PORT_13, PCR_Range_DAC_0_P10|PCR_Mode_DAC);
- MAX11300_setPortMode(PORT_14, PCR_Range_DAC_0_P10|PCR_Mode_DAC);
- MAX11300_setPortMode(PORT_15, PCR_Range_DAC_0_P10|PCR_Mode_DAC);
-
- rgDACValues[PORT_1] = 244;
- rgDACValues[PORT_3] = 2048;
- rgDACValues[PORT_5] = 1024;
- rgDACValues[PORT_7] = 1024;
- rgDACValues[PORT_9] = 512;
- rgDACValues[PORT_10] = 1024;
- rgDACValues[PORT_11] = 1024;
- rgDACValues[PORT_12] = 1024;
- rgDACValues[PORT_13] = 1024;
- rgDACValues[PORT_14] = 4095;
- rgDACValues[PORT_15] = 4095;
- rgDACValues[PORT_16] = 4095;
-
-/*
- rgDACValues[PORT_1] = 0;
- rgDACValues[PORT_3] = 0;
- rgDACValues[PORT_5] = 0;
- rgDACValues[PORT_7] = 0;
- rgDACValues[PORT_9] = 0;
- rgDACValues[PORT_10] = 0;
- rgDACValues[PORT_11] = 0;
- rgDACValues[PORT_12] = 0;
- rgDACValues[PORT_13] = 0;
- rgDACValues[PORT_14] = 0;
- rgDACValues[PORT_15] = 0;
- rgDACValues[PORT_16] = 0;
-*/
-
- MAX11300_setBuffers(rgADCValues, rgDACValues);
- MAX11300_startContinuous();
-}
-
-void run(){
-// Nop_delay(10000000);
-// MAX11300_bulksetDAC();
-
- Nop_delay(10000000);
-// MAX11300_bulkreadADC();
-}
diff --git a/Expander/Makefile b/Expander/Makefile
index 77a124f2..d89fbedc 100644
--- a/Expander/Makefile
+++ b/Expander/Makefile
@@ -1,44 +1,14 @@
-TEMPLATEROOT = .
+PROJECT = Expander
+BUILDROOT = .
+OPENWARE ?= $(BUILDROOT)/..
+OPENOCD ?= openocd -f openocd.cfg
-ifndef CONFIG
- CONFIG = Debug
-endif
+include $(BUILDROOT)/STM32F100CB.mk
-ifeq ($(CONFIG),Debug)
- CPPFLAGS = -g -Wall -Wcpp -Wunused-function -DDEBUG -DUSE_FULL_ASSERT
- ASFLAGS = -g
- CFLAGS = -g
-endif
+C_SRC = $(wildcard Src/*.c)
+#C_SRC = $(filter-out Src/test.c, $(wildcard Src/*.c))
+C_SRC += $(wildcard Source/*.c)
+CPP_SRC = $(wildcard Src/*.cpp)
+CPP_SRC += $(wildcard Source/*.cpp)
-ifeq ($(CONFIG),Release)
- CPPFLAGS = -O2
- ASFLAGS = -O2
- CFLAGS = -O2
-endif
-
-LDFLAGS += -Wl,--gc-sections
-LDSCRIPT ?= $(TEMPLATEROOT)/Source/stm32_flash.ld
-
-CPPFLAGS += --specs=nano.specs
-# CPPFLAGS += -DEXTERNAL_SRAM -DARM_CORTEX
-# CPPFLAGS += -fpic -fpie
-CPPFLAGS += -fdata-sections
-CPPFLAGS += -ffunction-sections
-#CPPFLAGS += -mno-unaligned-access
-#CPPFLAGS += -fno-omit-frame-pointer
-CPPFLAGS += -nostdlib -nostartfiles -fno-builtin -ffreestanding
-CPPFLAGS += -mtune=cortex-m7
-CXXFLAGS = -fno-rtti -fno-exceptions -std=gnu++11
-CFLAGS += -std=gnu99
-
-C_SRC = $(notdir $(wildcard Src/*.c)) $(notdir $(wildcard Source/*.c)) # $(notdir $(wildcard MDK-ARM/*.c))
-# Libraries/STM32Cube_FW_F1_V1.4.0/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c
-
-CPP_SRC = $(notdir $(wildcard Src/*.cpp)) $(notdir $(wildcard Source/*.cpp)) #$ (notdir $(wildcard MDK-ARM/*.cpp))
-
-OBJS = $(C_SRC:%.c=Build/%.o) $(CPP_SRC:%.cpp=Build/%.o)
-# OBJS += $(BUILD)/startup_stm32f756xx.o
-OBJS += $(BUILD)/startup_stm32f10x_md_vl.o # medium density value line
-
-include $(TEMPLATEROOT)/libs.mk
-include $(TEMPLATEROOT)/f1.mk
+include $(BUILDROOT)/f1.mk
diff --git a/Expander/STM32F100CB.mk b/Expander/STM32F100CB.mk
new file mode 100644
index 00000000..68e81678
--- /dev/null
+++ b/Expander/STM32F100CB.mk
@@ -0,0 +1,31 @@
+# Debug / Release
+CONFIG ?= Release
+ifeq ($(CONFIG),Debug)
+ CPPFLAGS = -g3 -Wall -Wcpp -Wunused-function -DDEBUG # -DUSE_FULL_ASSERT
+ ASFLAGS = -g3
+ CFLAGS = -g3
+endif
+ifeq ($(CONFIG),Release)
+ CPPFLAGS = -O2
+ ASFLAGS = -O2
+ CFLAGS = -O2
+endif
+
+# Compilation Flags
+LDFLAGS += -Wl,--gc-sections
+LDSCRIPT = $(BUILDROOT)/STM32F100CB_FLASH.ld
+CPPFLAGS += --specs=nano.specs
+CPPFLAGS += -DEXTERNAL_SRAM -DARM_CORTEX
+# CPPFLAGS += -fpic -fpie
+CPPFLAGS += -fdata-sections
+CPPFLAGS += -ffunction-sections
+#CPPFLAGS += -mno-unaligned-access
+#CPPFLAGS += -fno-omit-frame-pointer
+CPPFLAGS += -nostdlib -nostartfiles -fno-builtin -ffreestanding
+CXXFLAGS = -fno-rtti -fno-exceptions -std=gnu++11
+CFLAGS += -std=gnu99
+ARCH_FLAGS = -mcpu=cortex-m0 -mthumb # -mfloat-abi=hard -mfpu=fpv4-sp-d16
+ARCH_FLAGS += -fsingle-precision-constant
+DEF_FLAGS = -DSTM32F100xB -DARM_MATH_CM0
+DEF_FLAGS += -D__FPU_PRESENT=0U
+S_SRC = $(BUILDROOT)/Src/startup_stm32f100xb.s
diff --git a/Expander/STM32F100CBTx_FLASH.ld b/Expander/STM32F100CB_FLASH.ld
similarity index 100%
rename from Expander/STM32F100CBTx_FLASH.ld
rename to Expander/STM32F100CB_FLASH.ld
diff --git a/Expander/Source/Expander.cpp b/Expander/Source/Expander.cpp
index 57a569b5..3ccdb634 100644
--- a/Expander/Source/Expander.cpp
+++ b/Expander/Source/Expander.cpp
@@ -1,26 +1,17 @@
#include
-#include "stm32f1xx_hal.h"
+#include "device.h"
#include "HAL_TLC5946.h"
#include "bus.h"
#include "gpio.h"
#include "clock.h"
#include "message.h"
#include "OpenWareMidiControl.h"
-#include "device.h"
#include "basicmaths.h"
#include "SmoothValue.h"
-// #define USE_PIXI
-// #define USE_MAX
-#define USE_MAX_DMA
-#define TLC_CONTINUOUS
-// #define MAX_CONTINUOUS
-
-#ifdef USE_PIXI
-#include "Pixi.h"
-Pixi pixi;
-#elif defined USE_MAX || defined USE_MAX_DMA
+#if defined USE_MAX || defined USE_MAX_DMA
#include "HAL_MAX11300.h"
+extern SPI_HandleTypeDef MAX11300_SPI;
#endif
/**
@@ -28,10 +19,9 @@ Pixi pixi;
* LED channel index is the inverse of MAX channel index.
*/
-#define USE_TLC
-
extern "C" {
#ifdef USE_TLC
+ extern SPI_HandleTypeDef TLC5946_SPI;
#endif
void setup(void);
void run(void);
@@ -52,7 +42,7 @@ enum ChannelMode {
CHANNEL_MODES
};
-#define TLC5940_CHANNELS 20
+#define TLC5940_CHANNELS 16
#define MAX11300_CHANNELS 20
uint8_t cc_values[MAX11300_CHANNELS] = {0};
@@ -72,6 +62,9 @@ void setADC(uint8_t ch, int16_t value);
uint8_t getChannelIndex(uint8_t ch);
void setup(){
+ MAX11300_init(&MAX11300_SPI);
+ TLC5946_init(&TLC5946_SPI);
+
// setPin(TLC_BLANK_GPIO_Port, TLC_BLANK_Pin); // bring BLANK high to turn LEDs off
for(int ch=0; ch> 5;
if(abs(cc - cc_values[ch]) > HYSTERESIS_DELTA){
- bus_tx_parameter(getChannelIndex(PARAMETER_AA+ch), adc[ch]);
- cc_values[ch] = cc;
+ bus_tx_parameter(getChannelIndex(PARAMETER_AA+ch), adc[ch]);
+ cc_values[ch] = cc;
}
}
}
diff --git a/Expander/Source/MidiReader.h b/Expander/Source/MidiReader.h
index 75e29683..d3b6fda7 100644
--- a/Expander/Source/MidiReader.h
+++ b/Expander/Source/MidiReader.h
@@ -4,6 +4,7 @@
#include
#include "MidiStatus.h"
#include "MidiHandler.h"
+#include "device.h"
#ifndef MIDI_MAX_MESSAGE_SIZE
#define MIDI_MAX_MESSAGE_SIZE 64 // also used for bus messages and bus data
diff --git a/Expander/Source/Pixi.cpp b/Expander/Source/Pixi.cpp
deleted file mode 100644
index 5a3327f8..00000000
--- a/Expander/Source/Pixi.cpp
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- Pixi.cpp - Library for Analog shield with Maxim PIXI A/D chip.
- Created by Wolfgang Friedrich, July 29. 2014.
- Will be released into the public domain.
-*/
-
-#include "Pixi.h"
-#include "stm32f1xx_hal.h"
-#include "device.h"
-#include "gpio.h"
-
-#define MAX_SOFT_CS
-// #define MAX_BITBANG
-// #define MAX_HAL
-#define MAX_TIMEOUT 100
-extern "C"{
- extern SPI_HandleTypeDef hspi1;
-}
-
-#ifdef MAX_SOFT_CS
-#define setCS() setPin(MAX_CS_GPIO_Port, MAX_CS_Pin)
-#define clearCS() clearPin(MAX_CS_GPIO_Port, MAX_CS_Pin)
-#else
-#define setCS()
-#define clearCS()
-#endif
-
-#define MAX_SPI SPI1
-#define MAX_DUMMY_BYTE 0x00
-
-void delay(uint32_t ms){
- // spin
- // for(uint32_t i=0; iState != HAL_SPI_STATE_READY);
-// // clearPin(OLED_SCK_GPIO_Port, OLED_SCK_Pin);
-// // clearCS();
-// HAL_StatusTypeDef ret = HAL_SPI_Transmit(hspi, (uint8_t*)data, size, OLED_TIMEOUT);
-// assert_param(ret == HAL_OK);
-// // setCS();
-// }
-
-// Config SPI for communication witht the PIXI
-Pixi::Pixi(){}
-
-#ifndef MAX_BITBANG
-#define __HAL_RCC_SPI1_CLK_ENABLE() do { \
- __IO uint32_t tmpreg; \
- SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN);\
- /* Delay after an RCC peripheral clock enabling */\
- tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN);\
- /* UNUSED(tmpreg); */ \
- } while(0)
-#endif
-
-void Pixi::begin(){
-#ifdef MAX_SOFT_CS
- /*Configure GPIO pin : MAX_CS_Pin */
- GPIO_InitTypeDef GPIO_InitStruct;
- GPIO_InitStruct.Pin = MAX_CS_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
- HAL_GPIO_Init(MAX_CS_GPIO_Port, &GPIO_InitStruct);
-#endif
-
-#if 0
-#ifndef MAX_BITBANG
- __HAL_RCC_SPI1_CLK_ENABLE();
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
-#endif
-
-#ifdef MAX_SOFT_CS
- configureDigitalOutput(MAX_CS_GPIO_Port, MAX_CS_Pin);
-#endif
-
-#ifdef MAX_BITBANG
- configureDigitalOutput(MAX_CS_GPIO_Port, MAX_CS_Pin);
- configureDigitalOutput(MAX_SCLK_GPIO_Port, MAX_SCLK_Pin);
- configureDigitalOutput(MAX_DIN_GPIO_Port, MAX_DIN_Pin);
- configureDigitalInput(MAX_DOUT_GPIO_Port, MAX_DOUT_Pin, false);
-#else
- GPIO_InitTypeDef GPIO_InitStruct;
-#ifdef MAX_SOFT_CS
- GPIO_InitStruct.GPIO_Pin = MAX_SCLK_Pin|MAX_DIN_Pin;
-#else
- GPIO_InitStruct.GPIO_Pin = MAX_CS_Pin|MAX_SCLK_Pin|MAX_DIN_Pin;
-#endif
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
- GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- GPIO_InitStruct.GPIO_Pin = MAX_DOUT_Pin;
- // GPIO_InitStruct.GPIO_Pull = GPIO_NOPULL;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
- GPIO_Init(MAX_DOUT_GPIO_Port, &GPIO_InitStruct);
-
- SPI_InitTypeDef SPI_InitStructure;
- SPI_StructInit(&SPI_InitStructure);
- SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
- SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
- SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
- // SPI_InitStructure.SPI_DataSize = SPI_DataSize_16b;
- SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
- SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
- SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
- SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8;
- SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
- SPI_InitStructure.SPI_CRCPolynomial = 7; // SPI_CRCCALCULATION_DISABLED;
- SPI_Init(MAX_SPI, &SPI_InitStructure);
-
- SPI_Cmd(MAX_SPI, ENABLE);
-#endif
-#endif /* 0 */
-}
-
-/*
-Read register and return value
-if the debug parameter is set to TRUE, the register value is printed in format
-SPI read adress: 0x0 : h 0x4 : l 0x24
-SPI read result 0x424
-*/
-uint16_t Pixi::ReadRegister(uint8_t address, bool debug = false)
-{
- uint16_t result;
- // uint8_t read1 = 0;
- // uint8_t read2 = 0;
-
-// if (debug) {
-// Serial.print("SPI read adress: 0x");
-// Serial.print(address,HEX);
-// Serial.print(" : h 0x");
-// };
-
- // take the SS pin low to select the chip:
- // digitalWrite(slaveSelectPin,LOW);
- clearCS();
- // send in the address and return value via SPI:
-
- uint8_t data[2] = { (address << 1) | PIXI_READ };
- spiwrite(data, 1); // write 8-bit register id
- spiread(data, 2); // read 16-bit value
- result = (data[0]<<8) | data[1];
- // SPI_Write( (address << 0x01) | PIXI_READ );
- // result = SPI_Read();
- // read1 = SPI_Read();
- // if (debug) {
- // Serial.print(read1,HEX);
- // };
- // read2 = SPI_Read();
- // if (debug) {
- // Serial.print(" : l 0x");
- // Serial.println(read2,HEX);
- // };
-
- // result = (read1 << 8) | read2;
- // take the SS pin high to de-select the chip:
- // digitalWrite(slaveSelectPin,HIGH);
- setCS();
-
-// if (debug) {
-// Serial.print("SPI read result 0x");
-// Serial.println(result,HEX);
-// }
- return result;
-}
-
-
-/*
-write value into register
-Address needs to be shifted up 1 bit, LSB is read/write flag
-hi data byte is sent first, lo data byte last.
-*/
-void Pixi::WriteRegister(uint8_t address, uint16_t value)
-{
-// uint16_t result = 0;
- // int8_t value_hi =0;
-
- // take the SS pin low to select the chip:
- // digitalWrite(slaveSelectPin,LOW);
- clearCS();
- // send in the address and value via SPI:
- uint8_t data[3];
- data[0] = (address << 0x01) | PIXI_WRITE;
- data[1] = value >> 8;
- data[2] = value & 0xFF;
- spiwrite(data, 3);
- // SPI_Write( (address << 0x01) | PIXI_WRITE );
- // SPI_Write( uint8_t( value >> 8));
- // SPI_Write( uint8_t( value & 0xFF));
-
- // take the SS pin high to de-select the chip:
- setCS();
- // digitalWrite(slaveSelectPin,HIGH);
-
- return; // (result);
-}
-
-
-/*
-General Config for the PixiShield
-Read ID register to make sure the shield is connected.
-*/
-uint16_t Pixi::config()
-{
- uint16_t result = 0;
- uint16_t info = 0;
-
- result = ReadRegister( PIXI_DEVICE_ID, true );
-
- // if (result == 0x0424) {
-// enable default burst, thermal shutdown, leave conversion rate at 200k
- WriteRegister (PIXI_DEVICE_CTRL, (!BRST) | THSHDN ); // ADCCONV = 00 default.
-// enable internal temp sensor
- // disable series resistor cancelation
- info = ReadRegister ( PIXI_DEVICE_CTRL, false );
- WriteRegister (PIXI_DEVICE_CTRL, info | !RS_CANCEL );
- // keep TMPINTMONCFG at default 4 samples
-
- // Set int temp hi threshold
- WriteRegister (PIXI_TEMP_INT_HIGH_THRESHOLD, 0x0230 ); // 70 deg C in .125 steps
- // Keep int temp lo threshold at 0 deg C, negative values need function to write a two's complement number.
- // enable internal and both external temp sensors
- info = ReadRegister ( PIXI_DEVICE_CTRL, false );
- WriteRegister (PIXI_DEVICE_CTRL, info | TMPCTLINT | TMPCTLEXT1 | TMPCTLEXT2 );
- // }
- return (result);
-}
-
-
-
-/*
-Channel Config
-Parameters that are not used for the selected channel are ignored.
-*/
-
-uint16_t Pixi::configChannel( int channel, int channel_mode, uint16_t dac_dat, uint16_t range, uint8_t adc_ctl )
-{
- uint16_t result = 0;
- uint16_t info = 0;
-
-if ( ( channel <= 19 ) && ( channel_mode <= 12 ) )
-{
-
-if (channel_mode == CH_MODE_1 ||
- channel_mode == CH_MODE_3 ||
- channel_mode == CH_MODE_4 ||
- channel_mode == CH_MODE_5 ||
- channel_mode == CH_MODE_6 ||
- channel_mode == CH_MODE_10 )
- {
- // config DACREF (internal reference),DACCTL (sequential update)
- info = ReadRegister ( PIXI_DEVICE_CTRL, true );
- WriteRegister (PIXI_DEVICE_CTRL, info | DACREF | !DACCTL );
- delay (1);
- info = ReadRegister ( PIXI_DEVICE_CTRL, true );
- // Enter DACDAT
- WriteRegister ( PIXI_DAC_DATA + channel, dac_dat);
- // Mode1: config FUNCID, FUNCPRM (non-inverted default)
- if (channel_mode == CH_MODE_1)
- {
- WriteRegister ( PIXI_PORT_CONFIG + channel, ( ( (CH_MODE_1 << 12 ) & FUNCID ) |
- ( (range << 8 ) & FUNCPRM_RANGE ) ) );
-
- };
- delay (1);
- // Mode3: config GPO_DAT, leave channel at logic level 0
- if (channel_mode == CH_MODE_3)
- {
- if ( channel <= 15 )
- {
- WriteRegister ( PIXI_GPO_DATA_0_15, 0x00);
- }
- else if (channel >= 16 )
- {
- WriteRegister ( PIXI_GPO_DATA_16_19, ( 0x00 ) );
- };
- }
- // Mode3,4,5,6,10: config FUNCID, FUNCPRM (non-inverted default)
- if (channel_mode == CH_MODE_3 ||
- channel_mode == CH_MODE_5 ||
- channel_mode == CH_MODE_6 ||
- channel_mode == CH_MODE_10)
- {
- WriteRegister ( PIXI_PORT_CONFIG + channel, ( ( (channel_mode << 12 ) & FUNCID ) |
- ( (range << 8 ) & FUNCPRM_RANGE ) ) );
-
- }
- else if (channel_mode == CH_MODE_4 )
- {
- WriteRegister ( PIXI_PORT_CONFIG + channel, ( ( (channel_mode << 12 ) & FUNCID ) |
- ( (range << 8 ) & FUNCPRM_RANGE )
- // assoc port & FUNCPRM_ASSOCIATED_PORT
- ) );
-
- }
- delay (1);
- // Mode1: config GPIMD (leave at default INT never asserted
- if (channel_mode == CH_MODE_1)
- {
-// WriteRegister ( PIXI_GPI_IRQ_MODE_0_7, 0 );
-
- }
- delay (1);
-
- }
-
-else if (channel_mode == CH_MODE_7 ||
- channel_mode == CH_MODE_8 ||
- channel_mode == CH_MODE_9 ){
-
- // Mode9: config FUNCID, FUNCPRM
- if (channel_mode == CH_MODE_9)
- {
- WriteRegister ( PIXI_PORT_CONFIG + channel, ( ( (channel_mode << 12 ) & FUNCID ) |
- ( (range << 8 ) & FUNCPRM_RANGE )
- ) );
- }
- delay (1);
- if (channel_mode == CH_MODE_7 ||
- channel_mode == CH_MODE_8)
- {
- WriteRegister ( PIXI_PORT_CONFIG + channel, ( ( (channel_mode << 12 ) & FUNCID ) |
- ( (range << 8 ) & FUNCPRM_RANGE )
- ) );
- }
- delay (1);
-
- // config ADCCTL
- info = ReadRegister ( PIXI_DEVICE_CTRL, false );
- WriteRegister (PIXI_DEVICE_CTRL, info | ( adc_ctl & ADCCTL ) );
- delay (1);
-
-}
-else if (channel_mode == CH_MODE_2 ||
- channel_mode == CH_MODE_11 ||
- channel_mode == CH_MODE_12 ){
-
- WriteRegister ( PIXI_PORT_CONFIG + channel, ( ( (channel_mode << 12 ) & FUNCID ) |
- ( (range << 8 ) & FUNCPRM_RANGE )
- ) );
-
-
-
-};
-
-}
- return (result);
-};
-
-
-/*
-void Pixi::configTempChannel()
-{
-
-}
-*/
-
-/*
-void Pixi::configInterrupt()
-{
-
-}
-*/
-
-/*
-Readout of raw register value for given temperature channel
-*/
-uint16_t Pixi::readRawTemperature(int temp_channel)
-{
- uint16_t result = 0;
-
- result = ReadRegister( PIXI_INT_TEMP_DATA + temp_channel, false ); // INT_TEMP_DATA is the lowest temp data adress, channel runs from 0 to 2.
-
- return (result);
-
-}
-
-/*
-Readout of given temperature channel and conversion into degC float return value
-*/
-float Pixi::readTemperature(int temp_channel)
-{
- float result = 0;
- uint16_t rawresult = 0;
- bool sign = 0;
-
- rawresult = ReadRegister( PIXI_INT_TEMP_DATA + temp_channel, false ); // INT_TEMP_DATA is the lowest temp data adress, channel runs from 0 to 2.
-
- sign = ( rawresult & 0x0800 ) >> 11;
-
- if (sign == 1){
- rawresult = ( ( rawresult & 0x07FF ) xor 0x07FF ) + 1; // calc absolut value from 2's comnplement
- }
-
- result = 0.125 * ( rawresult & 0x0007 ) ; // pick only lowest 3 bit for value left of decimal point
- // One LSB is 0.125 deg C
- result = result + ( ( rawresult >> 3) & 0x01FF ) ;
-
- if (sign == 1)
- result = result * -1; // fix sign
- return (result);
-}
-
-uint16_t Pixi::readAnalog(int ch){
- return ReadRegister( PIXI_ADC_DATA+CHANNEL_0+ch, false);
-}
-
-/*
- * output analog value when channel is configured in mode 5
- */
-uint16_t Pixi::writeAnalog(int channel, uint16_t value){
- uint16_t result = 0;
- uint16_t channel_func = 0;
- channel += CHANNEL_0;
-
- channel_func = ReadRegister ( PIXI_PORT_CONFIG + channel, false );
- channel_func = ( channel_func & FUNCID ) >> 12 ;
-
- if(channel_func == 5){
- WriteRegister ( PIXI_DAC_DATA + channel, value );
- result = ReadRegister ( PIXI_DAC_DATA + channel, false );
- }
- return result;
-}
-
diff --git a/Expander/Source/Pixi.h b/Expander/Source/Pixi.h
deleted file mode 100644
index dbafb2f4..00000000
--- a/Expander/Source/Pixi.h
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- Pixi.h - Library for Analog shield with Maxim PIXI A/D chip.
- Created by Wolfgang Friedrich, July 29. 2014.
- Will be released into the public domain.
-*/
-
-#ifndef PIXI_H
-#define PIXI_H
-
-#include
-
-//#include "WProgram.h"
-
-//#define PIXI_
-
-// R/WB bit
-#define PIXI_READ 0x01
-#define PIXI_WRITE 0x00
-// Register Table (each register is 16 bit wide)
-#define PIXI_DEVICE_ID 0x00
-#define PIXI_INTERRUPT 0x01
-#define PIXI_ADC_DATA_STATUS_0_15 0x02
-#define PIXI_ADC_DATA_STATUS_16_19 0x03
-#define PIXI_OVERCURRENT_STATUS_0_15 0x04
-#define PIXI_OVERCURRENT_STATUS_16_19 0x05
-#define PIXI_GPI_STATUS_0_15 0x06
-#define PIXI_GPI_STATUS_16_19 0x07
-#define PIXI_INT_TEMP_DATA 0x08
-#define PIXI_EXT1_TEMP_DATA 0x09
-#define PIXI_EXT2_TEMP_DATA 0x0A
-#define PIXI_GPI_DATA_0_15 0x0B
-#define PIXI_GPI_DATA_16_19 0x0C
-#define PIXI_GPO_DATA_0_15 0x0D
-#define PIXI_GPO_DATA_16_19 0x0E
-#define PIXI_DEVICE_CTRL 0x10
-#define PIXI_INTERRUPT_MASK 0x11
-#define PIXI_GPI_IRQ_MODE_0_7 0x12
-#define PIXI_GPI_IRQ_MODE_8_15 0x13
-#define PIXI_GPI_IRQ_MODE_16_19 0x14
-#define PIXI_DAC_PRESET_DATA1 0x16
-#define PIXI_DAC_PRESET_DATA2 0x17
-#define PIXI_TEMP_MON_CONFIG 0x18
-#define PIXI_TEMP_INT_HIGH_THRESHOLD 0x19
-#define PIXI_TEMP_INT_LOW_THRESHOLD 0x1A
-#define PIXI_TEMP_EXT1_HIGH_THRESHOLD 0x1B
-#define PIXI_TEMP_EXT1_LOW_THRESHOLD 0x1C
-#define PIXI_TEMP_EXT2_HIGH_THRESHOLD 0x1D
-#define PIXI_TEMP_EXT2_LOW_THRESHOLD 0x1E
-
-#define PIXI_PORT_CONFIG 0x20
-#define PIXI_PORT0_CONFIG 0x20
-#define PIXI_PORT1_CONFIG 0x21
-#define PIXI_PORT2_CONFIG 0x22
-#define PIXI_PORT3_CONFIG 0x23
-#define PIXI_PORT4_CONFIG 0x24
-#define PIXI_PORT5_CONFIG 0x25
-#define PIXI_PORT6_CONFIG 0x26
-#define PIXI_PORT7_CONFIG 0x27
-#define PIXI_PORT8_CONFIG 0x28
-#define PIXI_PORT9_CONFIG 0x29
-#define PIXI_PORT10_CONFIG 0x2A
-#define PIXI_PORT11_CONFIG 0x2B
-#define PIXI_PORT12_CONFIG 0x2C
-#define PIXI_PORT13_CONFIG 0x2D
-#define PIXI_PORT14_CONFIG 0x2E
-#define PIXI_PORT15_CONFIG 0x2F
-#define PIXI_PORT16_CONFIG 0x30
-#define PIXI_PORT17_CONFIG 0x31
-#define PIXI_PORT18_CONFIG 0x32
-#define PIXI_PORT19_CONFIG 0x33
-
-#define PIXI_ADC_DATA 0x40
-#define PIXI_PORT0_ADC_DATA 0x40
-#define PIXI_PORT1_ADC_DATA 0x41
-#define PIXI_PORT2_ADC_DATA 0x42
-#define PIXI_PORT3_ADC_DATA 0x43
-#define PIXI_PORT4_ADC_DATA 0x44
-#define PIXI_PORT5_ADC_DATA 0x45
-#define PIXI_PORT6_ADC_DATA 0x46
-#define PIXI_PORT7_ADC_DATA 0x47
-#define PIXI_PORT8_ADC_DATA 0x48
-#define PIXI_PORT9_ADC_DATA 0x49
-#define PIXI_PORT10_ADC_DATA 0x4A
-#define PIXI_PORT11_ADC_DATA 0x4B
-#define PIXI_PORT12_ADC_DATA 0x4C
-#define PIXI_PORT13_ADC_DATA 0x4D
-#define PIXI_PORT14_ADC_DATA 0x4E
-#define PIXI_PORT15_ADC_DATA 0x4F
-#define PIXI_PORT16_ADC_DATA 0x50
-#define PIXI_PORT17_ADC_DATA 0x51
-#define PIXI_PORT18_ADC_DATA 0x52
-#define PIXI_PORT19_ADC_DATA 0x53
-
-#define PIXI_DAC_DATA 0x60
-#define PIXI_PORT0_DAC_DATA 0x60
-#define PIXI_PORT1_DAC_DATA 0x61
-#define PIXI_PORT2_DAC_DATA 0x62
-#define PIXI_PORT3_DAC_DATA 0x63
-#define PIXI_PORT4_DAC_DATA 0x64
-#define PIXI_PORT5_DAC_DATA 0x65
-#define PIXI_PORT6_DAC_DATA 0x66
-#define PIXI_PORT7_DAC_DATA 0x67
-#define PIXI_PORT8_DAC_DATA 0x68
-#define PIXI_PORT9_DAC_DATA 0x69
-#define PIXI_PORT10_DAC_DATA 0x6A
-#define PIXI_PORT11_DAC_DATA 0x6B
-#define PIXI_PORT12_DAC_DATA 0x6C
-#define PIXI_PORT13_DAC_DATA 0x6D
-#define PIXI_PORT14_DAC_DATA 0x6E
-#define PIXI_PORT15_DAC_DATA 0x6F
-#define PIXI_PORT16_DAC_DATA 0x70
-#define PIXI_PORT17_DAC_DATA 0x71
-#define PIXI_PORT18_DAC_DATA 0x72
-#define PIXI_PORT19_DAC_DATA 0x73
-
-// Detailed register content map
-// reg 0x00 Device ID
-/* #define DEVID 0xFFFF */
-// reg00x10 Device control
-#define ADCCTL 0x0003
-#define DACCTL 0x000C
-#define ADCCONV 0x0030
-#define DACREF 0x0040
-#define THSHDN 0x0080
-#define TMPCTL 0x0700
-#define TMPCTLINT 0x0100
-#define TMPCTLEXT1 0x0200
-#define TMPCTLEXT2 0x0400
-#define TMPPER 0x0800
-#define RS_CANCEL 0x1000
-#define LPEN 0x2000
-#define BRST 0x4000
-#define PIXI_RESET 0x8000
-//ADCCTL values
-#define ADC_MODE_IDLE 0x0
-#define ADC_MODE_SWEEP 0x1
-#define ADC_MODE_CONV 0x2
-#define ADC_MODE_CONT 0x3
-
-// reg 0x18 Temperature monitor config
-#define TMPINTMONCFG 0x0003
-#define TMPEXT1MONCFG 0x000C
-#define TMPEXT2MONCFG 0x0030
-// reg 0x19-1E Temperature monitor threshold high and low
-#define TMPINTHI 0x0FFF
-#define TMPINTLO 0x0FFF
-#define TMPEXT1HI 0x0FFF
-#define TMPEXT1LO 0x0FFF
-#define TMPEXT2HI 0x0FFF
-#define TMPEXT2LO 0x0FFF
-
-// reg 0x20-33 Port Configuration
-#define FUNCPRM 0x0FFF
-#define FUNCID 0xF000
-// Port Configuration register bits
-#define FUNCPRM_ASSOCIATED_PORT 0x001F
-#define FUNCPRM_NR_OF_SAMPLES 0x00E0
-#define FUNCPRM_RANGE 0x0700
-#define FUNCPRM_AVR_INV 0x0800
-#define FUNCID_MODE0_HIGHZ 0x0000
-
-
-
-// reg 0x40-53 ADC data
-#define ADCDAT 0x0FFF
-// reg 0x60-73 DAC data
-#define DACDAT 0x0FFF
-
-// Channel placeholder
-#define CHANNEL_0 0x00
-#define CHANNEL_1 0x01
-#define CHANNEL_2 0x02
-#define CHANNEL_3 0x03
-#define CHANNEL_4 0x04
-#define CHANNEL_5 0x05
-#define CHANNEL_6 0x06
-#define CHANNEL_7 0x07
-#define CHANNEL_8 0x08
-#define CHANNEL_9 0x09
-#define CHANNEL_10 0x0a
-#define CHANNEL_11 0x0b
-#define CHANNEL_12 0x0c
-#define CHANNEL_13 0x0d
-#define CHANNEL_14 0x0e
-#define CHANNEL_15 0x0f
-#define CHANNEL_16 0x10
-#define CHANNEL_17 0x11
-#define CHANNEL_18 0x12
-#define CHANNEL_19 0x13
-
-// Channel mode placeholder
-#define CH_MODE_0 0x00
-#define CH_MODE_HIZ 0x00
-#define CH_MODE_1 0x01
-#define CH_MODE_GPI 0x01
-#define CH_MODE_2 0x02
-#define CH_MODE_DIDIR_LT_TERM 0x02
-#define CH_MODE_3 0x03
-#define CH_MODE_GPO_REG 0x03
-#define CH_MODE_4 0x04
-#define CH_MODE_GPO_UNI 0x04
-#define CH_MODE_5 0x05
-#define CH_MODE_DAC 0x05
-#define CH_MODE_6 0x06
-#define CH_MODE_DAC_ADC_MON 0x06
-#define CH_MODE_7 0x07
-#define CH_MODE_ADC_P 0x07
-#define CH_MODE_8 0x08
-#define CH_MODE_ADC_DIFF_P 0x08
-#define CH_MODE_9 0x09
-#define CH_MODE_ADC_DIFF_N 0x09
-#define CH_MODE_10 0x0a
-#define CH_MODE_DAC_ADC_DIFF_N 0x0a
-#define CH_MODE_11 0x0b
-#define CH_MODE_TERM_GPI_SW 0x0b
-#define CH_MODE_12 0x0c
-#define CH_MODE_TERM_REG_SW 0x0c
-
-// Channel range
-#define CH_NO_RANGE 0x0000
-#define CH_0_TO_10P 0x0001
-#define CH_5N_TO_5P 0x0002
-#define CH_10N_TO_0 0x0003
-#define CH_0_TO_2P5_5N_TO_5P 0x0004
-/* #define CH_RES 0x0005 */
-#define CH_0_TO_2P5_0_TO_10P 0x0006
-/* #define CH_RES 0x0007 */
-
-
-#define TEMP_CHANNEL_INT 0x0
-#define TEMP_CHANNEL_EXT0 0x1
-#define TEMP_CHANNEL_EXT1 0x2
-
-class Pixi
-{
- public:
- Pixi();
- void begin();
- uint16_t ReadRegister (uint8_t address, bool debug);
- void WriteRegister (uint8_t address, uint16_t value);
- uint16_t config();
- uint16_t configChannel(int channel, int channel_mode, uint16_t dac_dat, uint16_t range, uint8_t adc_ctl );
-// void configTempChannel(int channel);
-// void configInterrupt();
-// void readInterrupt();
- uint16_t readRawTemperature(int temp_channel);
- float readTemperature(int temp_channel);
- uint16_t readAnalog(int channel);
- uint16_t writeAnalog(int channel, uint16_t value);
- private:
- int _channel;
- int _temp_channel;
-};
-
-#endif // PIXI_H
diff --git a/Expander/Source/bus.cpp b/Expander/Source/bus.cpp
index a611dc64..2ad7c0ba 100644
--- a/Expander/Source/bus.cpp
+++ b/Expander/Source/bus.cpp
@@ -1,10 +1,9 @@
-#include "stm32f1xx_hal.h"
#include "bus.h"
#include "message.h"
#include "serial.h"
#include "clock.h"
#include "DigitalBusStreamReader.h"
-#include "mxconstants.h"
+#include "device.h"
#include "SerialBuffer.hpp"
static DigitalBusStreamReader bus;
@@ -17,16 +16,6 @@ extern "C" {
uint8_t serial_tx_available();
uint8_t serial_tx_pull();
-#define NO_ERROR 0x00
-#define HARDFAULT_ERROR 0x10
-#define BUS_ERROR 0x20
-#define MEM_ERROR 0x30
-#define NMI_ERROR 0x40
-#define USAGE_ERROR 0x50
-#define PROGRAM_ERROR 0x60
-#define CONFIG_ERROR 0x70
-#define UART_ERROR 0x80
-
void setErrorMessage(int8_t err, const char* msg){
debug << "Error " << (int)err << ": " << msg << ".";
}
diff --git a/Expander/Source/device.h b/Expander/Source/device.h
index dde69679..890723e7 100644
--- a/Expander/Source/device.h
+++ b/Expander/Source/device.h
@@ -1,15 +1,22 @@
#include
-#include "mxconstants.h"
+#include "main.h"
#define FIRMWARE_VERSION "002"
#define HARDWARE_VERSION "Expander Rev01"
#define MIDI_MAX_MESSAGE_SIZE 256
+// #define USE_MAX
+#define USE_MAX_DMA
+#define USE_TLC
+#define TLC_CONTINUOUS
+// #define MAX_CONTINUOUS
+
+#define MAX11300_SPI hspi1
+#define TLC5946_SPI hspi2
+
/**
- * MAX11300 on SPI1
- * TLC5946 on SPI2
* Digital Bus on USART1
*/
/* #define USART_BAUDRATE 115200 */
@@ -23,5 +30,5 @@
#ifdef __cplusplus
}
#endif
-#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
+//#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
#endif
diff --git a/Expander/Source/errorhandlers.c b/Expander/Source/errorhandlers.c
new file mode 100644
index 00000000..4fa9e8c4
--- /dev/null
+++ b/Expander/Source/errorhandlers.c
@@ -0,0 +1,229 @@
+#include "device.h"
+#include "errorhandlers.h"
+
+#ifdef DEBUG
+#include
+#endif
+
+volatile int8_t errorcode = 0;
+const char* errormsg = 0;
+
+/* exception handlers - so we know what's failing */
+void NMI_Handler(void){
+ errorcode = NMI_ERROR;
+ assert_failed(0, 0);
+}
+
+void MemManage_Handler(void){
+ errorcode = MEM_ERROR;
+#ifdef DEBUG
+ volatile unsigned int hfsr = SCB->MMFAR;
+ volatile unsigned int cfsr = SCB->CFSR;
+ volatile unsigned int msp = __get_MSP();
+ volatile unsigned int psp = __get_PSP();
+ (void)hfsr;
+ (void)cfsr;
+ (void)msp;
+ (void)psp;
+#endif
+ assert_failed(0, 0);
+}
+
+void BusFault_Handler(void){
+ errorcode = BUS_ERROR;
+#ifdef DEBUG
+ volatile unsigned int hfsr = SCB->BFAR;
+ volatile unsigned int cfsr = SCB->CFSR;
+ volatile unsigned int msp = __get_MSP();
+ volatile unsigned int psp = __get_PSP();
+ (void)hfsr;
+ (void)cfsr;
+ (void)msp;
+ (void)psp;
+#endif
+ assert_failed(0, 0);
+}
+
+void UsageFault_Handler(void){
+ errorcode = USAGE_ERROR;
+#ifdef DEBUG
+ volatile unsigned int cfsr = SCB->CFSR;
+ volatile unsigned int msp = __get_MSP();
+ volatile unsigned int psp = __get_PSP();
+ (void)cfsr;
+ (void)msp;
+ (void)psp;
+#endif
+ assert_failed(0, 0);
+}
+
+void DebugMon_Handler(void){
+ for(;;);
+}
+
+/**
+ * @see http://www.freertos.org/Debugging-Hard-Faults-On-Cortex-M-Microcontrollers.html
+ */
+#if 0
+void prvGetRegistersFromStack(uint32_t *pulFaultStackAddress) {
+/* These are volatile to try and prevent the compiler/linker optimising them
+away as the variables never actually get used. If the debugger won't show the
+values of the variables, make them global my moving their declaration outside
+of this function. */
+ volatile uint32_t r0;
+ volatile uint32_t r1;
+ volatile uint32_t r2;
+ volatile uint32_t r3;
+ volatile uint32_t r12;
+ volatile uint32_t lr; /* Link register. */
+ volatile uint32_t pc; /* Program counter. */
+ volatile uint32_t psr;/* Program status register. */
+
+ r0 = pulFaultStackAddress[0];
+ r1 = pulFaultStackAddress[1];
+ r2 = pulFaultStackAddress[2];
+ r3 = pulFaultStackAddress[3];
+
+ r12 = pulFaultStackAddress[4];
+ lr = pulFaultStackAddress[5];
+ pc = pulFaultStackAddress[6];
+ psr = pulFaultStackAddress[7];
+
+ /* When the following line is hit, the variables contain the register values. */
+ for (;;);
+}
+
+The fault handler implementation calls a function called
+ prvGetRegistersFromStack().
+static void HardFault_Handler(void) {
+ __asm volatile (
+ " tst lr, #4 \n"
+ " ite eq \n"
+ " mrseq r0, msp \n"
+ " mrsne r0, psp \n"
+ " ldr r1, [r0, #24] \n"
+ " ldr r2, handler2_address_const \n"
+ " bx r2 \n"
+ " handler2_address_const: .word prvGetRegistersFromStack \n"
+ );
+}
+#endif
+
+/*
+ HardFault_Handler from http://blog.frankvh.com/2011/12/07/cortex-m3-m4-hard-fault-handler/
+*/
+#if 0
+void HardFault_Handler(void) __attribute__((naked));
+
+void HardFault_Handler(void) {
+/* HardFault_Handler: */
+ __asm("TST LR, #4");
+ __asm("ITE EQ");
+ __asm("MRSEQ R0, MSP");
+ __asm("MRSNE R0, PSP");
+ __asm("B hard_fault_handler_c");
+}
+
+void hard_fault_handler_c (unsigned int * hardfault_args){
+ volatile unsigned int stacked_r0;
+ volatile unsigned int stacked_r1;
+ volatile unsigned int stacked_r2;
+ volatile unsigned int stacked_r3;
+ volatile unsigned int stacked_r12;
+ volatile unsigned int stacked_lr;
+ volatile unsigned int stacked_pc;
+ volatile unsigned int stacked_psr;
+
+ stacked_r0 = ((unsigned long) hardfault_args[0]);
+ stacked_r1 = ((unsigned long) hardfault_args[1]);
+ stacked_r2 = ((unsigned long) hardfault_args[2]);
+ stacked_r3 = ((unsigned long) hardfault_args[3]);
+
+ stacked_r12 = ((unsigned long) hardfault_args[4]);
+ stacked_lr = ((unsigned long) hardfault_args[5]);
+ stacked_pc = ((unsigned long) hardfault_args[6]);
+ stacked_psr = ((unsigned long) hardfault_args[7]);
+}
+#endif
+
+/*
+see
+https://blog.feabhas.com/2013/02/developing-a-generic-hard-fault-handler-for-arm-cortex-m3cortex-m4/
+*/
+void HardFault_Handler(void){
+ errorcode = HARDFAULT_ERROR;
+#ifdef DEBUG
+ volatile unsigned int hfsr = SCB->HFSR;
+ volatile unsigned int cfsr = SCB->CFSR;
+ volatile unsigned int msp = __get_MSP();
+ volatile unsigned int psp = __get_PSP();
+ (void)hfsr;
+ (void)cfsr;
+ (void)msp;
+ (void)psp;
+#endif
+ assert_failed(0, 0);
+}
+
+/* defined by FreeRTOS
+void SVC_Handler(void){
+ for(;;);
+}
+
+void PendSV_Handler(void){
+ for(;;);
+}
+*/
+
+void WWDG_IRQHandler(void) {
+ assert_failed(0, 0);
+}
+
+void PVD_IRQHandler(void) {
+ assert_failed(0, 0);
+}
+
+void FPU_IRQHandler(void){
+ assert_failed(0, 0);
+}
+
+/*
+
+void UART4_IRQHandler(void){
+ assert_failed(0, 0);
+}
+
+void UART5_IRQHandler(void){
+ assert_failed(0, 0);
+}
+
+void USART6_IRQHandler(void){
+ assert_failed(0, 0);
+}
+
+void USART3_IRQHandler(void){
+ assert_failed(0, 0);
+}
+void USART2_IRQHandler(void){
+ assert_failed(0, 0);
+}
+void USART1_IRQHandler(void){
+ assert_failed(0, 0);
+}
+
+void FLASH_IRQHandler(void){
+ assert_failed(0, 0);
+}
+
+void TIM8_UP_TIM13_IRQHandler(void){
+ assert_failed(0, 0);
+}
+
+void TIM8_TRG_COM_TIM14_IRQHandler(void){
+ assert_failed(0, 0);
+}
+
+void TIM8_CC_IRQHandler(void){
+ assert_failed(0, 0);
+}
+*/
diff --git a/Expander/Source/errorhandlers.h b/Expander/Source/errorhandlers.h
new file mode 100644
index 00000000..afca210b
--- /dev/null
+++ b/Expander/Source/errorhandlers.h
@@ -0,0 +1,34 @@
+#ifndef __ERRORHANDLERS_H__
+#define __ERRORHANDLERS_H__
+#include
+
+#define ASSERT(cond, msg) do{if(!(cond))error(RUNTIME_ERROR, msg);}while(0)
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+ void error(int8_t code, const char* reason);
+ int8_t getErrorStatus();
+ const char* getErrorMessage();
+ void setErrorStatus(int8_t err);
+ void setErrorMessage(int8_t err, const char* msg);
+ void setParameterValues(uint16_t* values, int size);
+
+#define NO_ERROR 0x00
+#define HARDFAULT_ERROR 0x10
+#define BUS_ERROR 0x20
+#define MEM_ERROR 0x30
+#define NMI_ERROR 0x40
+#define USAGE_ERROR 0x50
+#define PROGRAM_ERROR 0x60
+#define CONFIG_ERROR 0x70
+#define FLASH_ERROR 0x80
+#define USB_ERROR 0x90
+#define RUNTIME_ERROR 0xa0
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ERRORHANDLERS_H__ */
diff --git a/Expander/Source/serial.c b/Expander/Source/serial.c
index 69fdda67..9d5ccc5f 100644
--- a/Expander/Source/serial.c
+++ b/Expander/Source/serial.c
@@ -1,10 +1,6 @@
-#include "stm32f1xx_hal.h"
-#include "device.h"
#include "serial.h"
#include "device.h"
-#include "mxconstants.h"
-
extern UART_HandleTypeDef huart1;
#define ASSERT(cond, msg) assert_param(cond)
diff --git a/Expander/Source/startup_stm32f10x_md_vl.s b/Expander/Source/startup_stm32f10x_md_vl.s
deleted file mode 100644
index 4ac1230d..00000000
--- a/Expander/Source/startup_stm32f10x_md_vl.s
+++ /dev/null
@@ -1,408 +0,0 @@
-/**
- ******************************************************************************
- * @file startup_stm32f10x_md_vl.s
- * @author MCD Application Team
- * @version V3.5.0
- * @date 11-March-2011
- * @brief STM32F10x Medium Density Value Line Devices vector table for Atollic
- * toolchain.
- * This module performs:
- * - Set the initial SP
- * - Set the initial PC == Reset_Handler,
- * - Set the vector table entries with the exceptions ISR address
- * - Configure the clock system
- * - Branches to main in the C library (which eventually
- * calls main()).
- * After Reset the Cortex-M3 processor is in Thread mode,
- * priority is Privileged, and the Stack is set to Main.
- ******************************************************************************
- * @attention
- *
- * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
- * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
- * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
- * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
- * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
- * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
- *
- * © COPYRIGHT 2011 STMicroelectronics
- ******************************************************************************
- */
-
- .syntax unified
- .cpu cortex-m3
- .fpu softvfp
- .thumb
-
-.global g_pfnVectors
-.global Default_Handler
-
-/* start address for the initialization values of the .data section.
-defined in linker script */
-.word _sidata
-/* start address for the .data section. defined in linker script */
-.word _sdata
-/* end address for the .data section. defined in linker script */
-.word _edata
-/* start address for the .bss section. defined in linker script */
-.word _sbss
-/* end address for the .bss section. defined in linker script */
-.word _ebss
-
-.equ BootRAM, 0xF108F85F
-/**
- * @brief This is the code that gets called when the processor first
- * starts execution following a reset event. Only the absolutely
- * necessary set is performed, after which the application
- * supplied main() routine is called.
- * @param None
- * @retval : None
-*/
-
- .section .text.Reset_Handler
- .weak Reset_Handler
- .type Reset_Handler, %function
-Reset_Handler:
-
-/* Copy the data segment initializers from flash to SRAM */
- movs r1, #0
- b LoopCopyDataInit
-
-CopyDataInit:
- ldr r3, =_sidata
- ldr r3, [r3, r1]
- str r3, [r0, r1]
- adds r1, r1, #4
-
-LoopCopyDataInit:
- ldr r0, =_sdata
- ldr r3, =_edata
- adds r2, r0, r1
- cmp r2, r3
- bcc CopyDataInit
- ldr r2, =_sbss
- b LoopFillZerobss
-/* Zero fill the bss segment. */
-FillZerobss:
- movs r3, #0
- str r3, [r2], #4
-
-LoopFillZerobss:
- ldr r3, = _ebss
- cmp r2, r3
- bcc FillZerobss
-
-/* Call the clock system intitialization function.*/
- bl SystemInit
-/* Call static constructors */
- bl __libc_init_array
-/* Call the application's entry point.*/
- bl main
- bx lr
-.size Reset_Handler, .-Reset_Handler
-
-/**
- * @brief This is the code that gets called when the processor receives an
- * unexpected interrupt. This simply enters an infinite loop, preserving
- * the system state for examination by a debugger.
- *
- * @param None
- * @retval : None
-*/
- .section .text.Default_Handler,"ax",%progbits
-Default_Handler:
-Infinite_Loop:
- b Infinite_Loop
- .size Default_Handler, .-Default_Handler
-/******************************************************************************
-*
-* The minimal vector table for a Cortex M3. Note that the proper constructs
-* must be placed on this to ensure that it ends up at physical address
-* 0x0000.0000.
-*
-******************************************************************************/
- .section .isr_vector,"a",%progbits
- .type g_pfnVectors, %object
- .size g_pfnVectors, .-g_pfnVectors
-
-
-g_pfnVectors:
- .word _estack
- .word Reset_Handler
- .word NMI_Handler
- .word HardFault_Handler
- .word MemManage_Handler
- .word BusFault_Handler
- .word UsageFault_Handler
- .word 0
- .word 0
- .word 0
- .word 0
- .word SVC_Handler
- .word DebugMon_Handler
- .word 0
- .word PendSV_Handler
- .word SysTick_Handler
- .word WWDG_IRQHandler
- .word PVD_IRQHandler
- .word TAMPER_IRQHandler
- .word RTC_IRQHandler
- .word FLASH_IRQHandler
- .word RCC_IRQHandler
- .word EXTI0_IRQHandler
- .word EXTI1_IRQHandler
- .word EXTI2_IRQHandler
- .word EXTI3_IRQHandler
- .word EXTI4_IRQHandler
- .word DMA1_Channel1_IRQHandler
- .word DMA1_Channel2_IRQHandler
- .word DMA1_Channel3_IRQHandler
- .word DMA1_Channel4_IRQHandler
- .word DMA1_Channel5_IRQHandler
- .word DMA1_Channel6_IRQHandler
- .word DMA1_Channel7_IRQHandler
- .word ADC1_IRQHandler
- .word 0
- .word 0
- .word 0
- .word 0
- .word EXTI9_5_IRQHandler
- .word TIM1_BRK_TIM15_IRQHandler
- .word TIM1_UP_TIM16_IRQHandler
- .word TIM1_TRG_COM_TIM17_IRQHandler
- .word TIM1_CC_IRQHandler
- .word TIM2_IRQHandler
- .word TIM3_IRQHandler
- .word TIM4_IRQHandler
- .word I2C1_EV_IRQHandler
- .word I2C1_ER_IRQHandler
- .word I2C2_EV_IRQHandler
- .word I2C2_ER_IRQHandler
- .word SPI1_IRQHandler
- .word SPI2_IRQHandler
- .word USART1_IRQHandler
- .word USART2_IRQHandler
- .word USART3_IRQHandler
- .word EXTI15_10_IRQHandler
- .word RTCAlarm_IRQHandler
- .word CEC_IRQHandler
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word TIM6_DAC_IRQHandler
- .word TIM7_IRQHandler
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word BootRAM /* @0x01CC. This is for boot in RAM mode for
- STM32F10x Medium Value Line Density devices. */
-
-/*******************************************************************************
-*
-* Provide weak aliases for each Exception handler to the Default_Handler.
-* As they are weak aliases, any function with the same name will override
-* this definition.
-*
-*******************************************************************************/
-
-
- .weak NMI_Handler
- .thumb_set NMI_Handler,Default_Handler
-
- .weak HardFault_Handler
- .thumb_set HardFault_Handler,Default_Handler
-
- .weak MemManage_Handler
- .thumb_set MemManage_Handler,Default_Handler
-
- .weak BusFault_Handler
- .thumb_set BusFault_Handler,Default_Handler
-
- .weak UsageFault_Handler
- .thumb_set UsageFault_Handler,Default_Handler
-
- .weak SVC_Handler
- .thumb_set SVC_Handler,Default_Handler
-
- .weak DebugMon_Handler
- .thumb_set DebugMon_Handler,Default_Handler
-
- .weak PendSV_Handler
- .thumb_set PendSV_Handler,Default_Handler
-
- .weak SysTick_Handler
- .thumb_set SysTick_Handler,Default_Handler
-
- .weak WWDG_IRQHandler
- .thumb_set WWDG_IRQHandler,Default_Handler
-
- .weak PVD_IRQHandler
- .thumb_set PVD_IRQHandler,Default_Handler
-
- .weak TAMPER_IRQHandler
- .thumb_set TAMPER_IRQHandler,Default_Handler
-
- .weak RTC_IRQHandler
- .thumb_set RTC_IRQHandler,Default_Handler
-
- .weak FLASH_IRQHandler
- .thumb_set FLASH_IRQHandler,Default_Handler
-
- .weak RCC_IRQHandler
- .thumb_set RCC_IRQHandler,Default_Handler
-
- .weak EXTI0_IRQHandler
- .thumb_set EXTI0_IRQHandler,Default_Handler
-
- .weak EXTI1_IRQHandler
- .thumb_set EXTI1_IRQHandler,Default_Handler
-
- .weak EXTI2_IRQHandler
- .thumb_set EXTI2_IRQHandler,Default_Handler
-
- .weak EXTI3_IRQHandler
- .thumb_set EXTI3_IRQHandler,Default_Handler
-
- .weak EXTI4_IRQHandler
- .thumb_set EXTI4_IRQHandler,Default_Handler
-
- .weak DMA1_Channel1_IRQHandler
- .thumb_set DMA1_Channel1_IRQHandler,Default_Handler
-
- .weak DMA1_Channel2_IRQHandler
- .thumb_set DMA1_Channel2_IRQHandler,Default_Handler
-
- .weak DMA1_Channel3_IRQHandler
- .thumb_set DMA1_Channel3_IRQHandler,Default_Handler
-
- .weak DMA1_Channel4_IRQHandler
- .thumb_set DMA1_Channel4_IRQHandler,Default_Handler
-
- .weak DMA1_Channel5_IRQHandler
- .thumb_set DMA1_Channel5_IRQHandler,Default_Handler
-
- .weak DMA1_Channel6_IRQHandler
- .thumb_set DMA1_Channel6_IRQHandler,Default_Handler
-
- .weak DMA1_Channel7_IRQHandler
- .thumb_set DMA1_Channel7_IRQHandler,Default_Handler
-
- .weak ADC1_IRQHandler
- .thumb_set ADC1_IRQHandler,Default_Handler
-
- .weak EXTI9_5_IRQHandler
- .thumb_set EXTI9_5_IRQHandler,Default_Handler
-
- .weak TIM1_BRK_TIM15_IRQHandler
- .thumb_set TIM1_BRK_TIM15_IRQHandler,Default_Handler
-
- .weak TIM1_UP_TIM16_IRQHandler
- .thumb_set TIM1_UP_TIM16_IRQHandler,Default_Handler
-
- .weak TIM1_TRG_COM_TIM17_IRQHandler
- .thumb_set TIM1_TRG_COM_TIM17_IRQHandler,Default_Handler
-
- .weak TIM1_CC_IRQHandler
- .thumb_set TIM1_CC_IRQHandler,Default_Handler
-
- .weak TIM2_IRQHandler
- .thumb_set TIM2_IRQHandler,Default_Handler
-
- .weak TIM3_IRQHandler
- .thumb_set TIM3_IRQHandler,Default_Handler
-
- .weak TIM4_IRQHandler
- .thumb_set TIM4_IRQHandler,Default_Handler
-
- .weak I2C1_EV_IRQHandler
- .thumb_set I2C1_EV_IRQHandler,Default_Handler
-
- .weak I2C1_ER_IRQHandler
- .thumb_set I2C1_ER_IRQHandler,Default_Handler
-
- .weak I2C2_EV_IRQHandler
- .thumb_set I2C2_EV_IRQHandler,Default_Handler
-
- .weak I2C2_ER_IRQHandler
- .thumb_set I2C2_ER_IRQHandler,Default_Handler
-
- .weak SPI1_IRQHandler
- .thumb_set SPI1_IRQHandler,Default_Handler
-
- .weak SPI2_IRQHandler
- .thumb_set SPI2_IRQHandler,Default_Handler
-
- .weak USART1_IRQHandler
- .thumb_set USART1_IRQHandler,Default_Handler
-
- .weak USART2_IRQHandler
- .thumb_set USART2_IRQHandler,Default_Handler
-
- .weak USART3_IRQHandler
- .thumb_set USART3_IRQHandler,Default_Handler
-
- .weak EXTI15_10_IRQHandler
- .thumb_set EXTI15_10_IRQHandler,Default_Handler
-
- .weak RTCAlarm_IRQHandler
- .thumb_set RTCAlarm_IRQHandler,Default_Handler
-
- .weak CEC_IRQHandler
- .thumb_set CEC_IRQHandler,Default_Handler
-
- .weak TIM6_DAC_IRQHandler
- .thumb_set TIM6_DAC_IRQHandler,Default_Handler
-
- .weak TIM7_IRQHandler
- .thumb_set TIM7_IRQHandler,Default_Handler
-
-/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
-
diff --git a/Expander/Src/HAL_MAX11300.c b/Expander/Src/HAL_MAX11300.c
index 1aece33c..7567a3a1 100644
--- a/Expander/Src/HAL_MAX11300.c
+++ b/Expander/Src/HAL_MAX11300.c
@@ -1,5 +1,4 @@
-#include "stm32f1xx_hal.h"
-#include "mxconstants.h"
+#include "device.h"
#include "HAL_MAX11300.h"
#include
diff --git a/Expander/Src/HAL_TLC5946.c b/Expander/Src/HAL_TLC5946.c
index 8fe31814..df008265 100644
--- a/Expander/Src/HAL_TLC5946.c
+++ b/Expander/Src/HAL_TLC5946.c
@@ -1,8 +1,6 @@
-
-#include "stm32f1xx_hal.h"
+#include "device.h"
#include "HAL_TLC5946.h"
-#define TLC_CONTINUOUS
uint8_t rgGSbuf[24] = {0};
uint8_t rgDCbuf[12] = {255,255,255,255,255,255,255,255,255,255,255,255};
@@ -12,13 +10,13 @@ SPI_HandleTypeDef* TLC5946_SPIConfig;
void TLC5946_SetOutput_GS (unsigned char LED_ID, unsigned short value)
{
unsigned char temp;
- unsigned char ucBuffLoc = (unsigned char)(LED_ID*1.5);
+ uint8_t ucBuffLoc = LED_ID + (LED_ID>>1); // (uint8_t)(LED_ID*1.5);
if (value < 4095)
{
if(LED_ID & 0x01) // bbbbaaaa aaaaaaaa
{
- temp = rgGSbuf[ucBuffLoc];
+ temp = rgGSbuf[ucBuffLoc];
rgGSbuf[ucBuffLoc] = (value&0xF00)>>8;
rgGSbuf[ucBuffLoc] |= (temp&0xF0);
rgGSbuf[ucBuffLoc+1] = (value&0x0FF);
@@ -26,7 +24,7 @@ void TLC5946_SetOutput_GS (unsigned char LED_ID, unsigned short value)
else // aaaaaaaa aaaabbbb
{
rgGSbuf[ucBuffLoc] = (value&0xFF0)>>4;
- temp = rgGSbuf[ucBuffLoc+1];
+ temp = rgGSbuf[ucBuffLoc+1];
rgGSbuf[ucBuffLoc+1] = (value&0x00F)<<4;
rgGSbuf[ucBuffLoc+1] |= (temp&0x0F);
}
diff --git a/Expander/Src/main.c b/Expander/Src/main.c
index 01c983fb..84a3bd3e 100644
--- a/Expander/Src/main.c
+++ b/Expander/Src/main.c
@@ -1,49 +1,50 @@
+/* USER CODE BEGIN Header */
/**
******************************************************************************
- * File Name : main.c
- * Description : Main program body
+ * @file : main.c
+ * @brief : Main program body
******************************************************************************
+ * @attention
*
- * COPYRIGHT(c) 2020 STMicroelectronics
+ * © Copyright (c) 2021 STMicroelectronics.
+ * All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
+/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
-#include "stm32f1xx_hal.h"
+#include "main.h"
+/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "HAL_MAX11300.h"
#include "HAL_TLC5946.h"
/* USER CODE END Includes */
+/* Private typedef -----------------------------------------------------------*/
+/* USER CODE BEGIN PTD */
+
+/* USER CODE END PTD */
+
+/* Private define ------------------------------------------------------------*/
+/* USER CODE BEGIN PD */
+/* USER CODE END PD */
+
+/* Private macro -------------------------------------------------------------*/
+/* USER CODE BEGIN PM */
+
+/* USER CODE END PM */
+
/* Private variables ---------------------------------------------------------*/
SPI_HandleTypeDef hspi1;
SPI_HandleTypeDef hspi2;
DMA_HandleTypeDef hdma_spi1_rx;
DMA_HandleTypeDef hdma_spi1_tx;
-DMA_HandleTypeDef hdma_spi2_tx;
TIM_HandleTypeDef htim1;
@@ -56,16 +57,12 @@ UART_HandleTypeDef huart1;
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
-void Error_Handler(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_SPI1_Init(void);
static void MX_SPI2_Init(void);
static void MX_TIM1_Init(void);
static void MX_USART1_UART_Init(void);
-
-void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
-
/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
void setup(void);
@@ -73,25 +70,37 @@ void run(void);
/* USER CODE END PFP */
+/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
+/**
+ * @brief The application entry point.
+ * @retval int
+ */
int main(void)
{
-
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
- /* MCU Configuration----------------------------------------------------------*/
+ /* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
+ /* USER CODE BEGIN Init */
+
+ /* USER CODE END Init */
+
/* Configure the system clock */
SystemClock_Config();
+ /* USER CODE BEGIN SysInit */
+
+ /* USER CODE END SysInit */
+
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
@@ -99,11 +108,8 @@ int main(void)
MX_SPI2_Init();
MX_TIM1_Init();
MX_USART1_UART_Init();
-
/* USER CODE BEGIN 2 */
- MAX11300_init(&hspi1);
- TLC5946_init(&hspi2);
setup();
/* USER CODE END 2 */
@@ -112,24 +118,27 @@ int main(void)
/* USER CODE BEGIN WHILE */
while (1)
{
- /* USER CODE END WHILE */
+ /* USER CODE END WHILE */
- /* USER CODE BEGIN 3 */
+ /* USER CODE BEGIN 3 */
run();
}
/* USER CODE END 3 */
-
}
-/** System Clock Configuration
-*/
+/**
+ * @brief System Clock Configuration
+ * @retval None
+ */
void SystemClock_Config(void)
{
+ RCC_OscInitTypeDef RCC_OscInitStruct = {0};
+ RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
- RCC_OscInitTypeDef RCC_OscInitStruct;
- RCC_ClkInitTypeDef RCC_ClkInitStruct;
-
+ /** Initializes the RCC Oscillators according to the specified parameters
+ * in the RCC_OscInitTypeDef structure.
+ */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
@@ -140,30 +149,37 @@ void SystemClock_Config(void)
{
Error_Handler();
}
-
+ /** Initializes the CPU, AHB and APB buses clocks
+ */
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
+
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
{
Error_Handler();
}
-
- HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
-
- HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
-
- /* SysTick_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
}
-/* SPI1 init function */
+/**
+ * @brief SPI1 Initialization Function
+ * @param None
+ * @retval None
+ */
static void MX_SPI1_Init(void)
{
+ /* USER CODE BEGIN SPI1_Init 0 */
+
+ /* USER CODE END SPI1_Init 0 */
+
+ /* USER CODE BEGIN SPI1_Init 1 */
+
+ /* USER CODE END SPI1_Init 1 */
+ /* SPI1 parameter configuration*/
hspi1.Instance = SPI1;
hspi1.Init.Mode = SPI_MODE_MASTER;
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
@@ -180,13 +196,28 @@ static void MX_SPI1_Init(void)
{
Error_Handler();
}
+ /* USER CODE BEGIN SPI1_Init 2 */
+
+ /* USER CODE END SPI1_Init 2 */
}
-/* SPI2 init function */
+/**
+ * @brief SPI2 Initialization Function
+ * @param None
+ * @retval None
+ */
static void MX_SPI2_Init(void)
{
+ /* USER CODE BEGIN SPI2_Init 0 */
+
+ /* USER CODE END SPI2_Init 0 */
+
+ /* USER CODE BEGIN SPI2_Init 1 */
+
+ /* USER CODE END SPI2_Init 1 */
+ /* SPI2 parameter configuration*/
hspi2.Instance = SPI2;
hspi2.Init.Mode = SPI_MODE_MASTER;
hspi2.Init.Direction = SPI_DIRECTION_2LINES;
@@ -203,47 +234,58 @@ static void MX_SPI2_Init(void)
{
Error_Handler();
}
+ /* USER CODE BEGIN SPI2_Init 2 */
+
+ /* USER CODE END SPI2_Init 2 */
}
-/* TIM1 init function */
+/**
+ * @brief TIM1 Initialization Function
+ * @param None
+ * @retval None
+ */
static void MX_TIM1_Init(void)
{
- TIM_ClockConfigTypeDef sClockSourceConfig;
- TIM_MasterConfigTypeDef sMasterConfig;
- TIM_OC_InitTypeDef sConfigOC;
- TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig;
+ /* USER CODE BEGIN TIM1_Init 0 */
+
+ /* USER CODE END TIM1_Init 0 */
+
+ TIM_ClockConfigTypeDef sClockSourceConfig = {0};
+ TIM_MasterConfigTypeDef sMasterConfig = {0};
+ TIM_OC_InitTypeDef sConfigOC = {0};
+ TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0};
+ /* USER CODE BEGIN TIM1_Init 1 */
+
+ /* USER CODE END TIM1_Init 1 */
htim1.Instance = TIM1;
htim1.Init.Prescaler = 0;
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
htim1.Init.Period = 2;
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim1.Init.RepetitionCounter = 0;
+ htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
if (HAL_TIM_Base_Init(&htim1) != HAL_OK)
{
Error_Handler();
}
-
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK)
{
Error_Handler();
}
-
if (HAL_TIM_OC_Init(&htim1) != HAL_OK)
{
Error_Handler();
}
-
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
-
sConfigOC.OCMode = TIM_OCMODE_TOGGLE;
sConfigOC.Pulse = 32765;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
@@ -255,7 +297,6 @@ static void MX_TIM1_Init(void)
{
Error_Handler();
}
-
sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;
sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;
@@ -267,15 +308,28 @@ static void MX_TIM1_Init(void)
{
Error_Handler();
}
+ /* USER CODE BEGIN TIM1_Init 2 */
+ /* USER CODE END TIM1_Init 2 */
HAL_TIM_MspPostInit(&htim1);
}
-/* USART1 init function */
+/**
+ * @brief USART1 Initialization Function
+ * @param None
+ * @retval None
+ */
static void MX_USART1_UART_Init(void)
{
+ /* USER CODE BEGIN USART1_Init 0 */
+
+ /* USER CODE END USART1_Init 0 */
+
+ /* USER CODE BEGIN USART1_Init 1 */
+
+ /* USER CODE END USART1_Init 1 */
huart1.Instance = USART1;
huart1.Init.BaudRate = 115200;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
@@ -284,10 +338,13 @@ static void MX_USART1_UART_Init(void)
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
- if (HAL_MultiProcessor_Init(&huart1, 0, UART_WAKEUPMETHOD_IDLELINE) != HAL_OK)
+ if (HAL_UART_Init(&huart1) != HAL_OK)
{
Error_Handler();
}
+ /* USER CODE BEGIN USART1_Init 2 */
+
+ /* USER CODE END USART1_Init 2 */
}
@@ -296,6 +353,7 @@ static void MX_USART1_UART_Init(void)
*/
static void MX_DMA_Init(void)
{
+
/* DMA controller clock enable */
__HAL_RCC_DMA1_CLK_ENABLE();
@@ -306,25 +364,17 @@ static void MX_DMA_Init(void)
/* DMA1_Channel3_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Channel3_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Channel3_IRQn);
- /* DMA1_Channel5_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 0, 0);
- HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn);
}
-/** Configure pins as
- * Analog
- * Input
- * Output
- * EVENT_OUT
- * EXTI
- * Free pins are configured automatically as Analog (this feature is enabled through
- * the Code Generation settings)
-*/
+/**
+ * @brief GPIO Initialization Function
+ * @param None
+ * @retval None
+ */
static void MX_GPIO_Init(void)
{
-
- GPIO_InitTypeDef GPIO_InitStruct;
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
@@ -350,6 +400,7 @@ static void MX_GPIO_Init(void)
/*Configure GPIO pins : MAX_nCS_Pin TLC_MODE_Pin TLC_XLAT_Pin */
GPIO_InitStruct.Pin = MAX_nCS_Pin|TLC_MODE_Pin|TLC_XLAT_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
@@ -393,45 +444,34 @@ void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi){
/**
* @brief This function is executed in case of error occurrence.
- * @param None
* @retval None
*/
void Error_Handler(void)
{
- /* USER CODE BEGIN Error_Handler */
+ /* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
- while(1)
+ __disable_irq();
+ while (1)
{
}
- /* USER CODE END Error_Handler */
+ /* USER CODE END Error_Handler_Debug */
}
-#ifdef USE_FULL_ASSERT
-
+#ifdef USE_FULL_ASSERT
/**
- * @brief Reports the name of the source file and the source line number
- * where the assert_param error has occurred.
- * @param file: pointer to the source file name
- * @param line: assert_param error line source number
- * @retval None
- */
-void assert_failed(uint8_t* file, uint32_t line)
+ * @brief Reports the name of the source file and the source line number
+ * where the assert_param error has occurred.
+ * @param file: pointer to the source file name
+ * @param line: assert_param error line source number
+ * @retval None
+ */
+void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */
-
}
-
-#endif
-
-/**
- * @}
- */
-
-/**
- * @}
-*/
+#endif /* USE_FULL_ASSERT */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Expander/startup_stm32f100xb.s b/Expander/Src/startup_stm32f100xb.s
similarity index 96%
rename from Expander/startup_stm32f100xb.s
rename to Expander/Src/startup_stm32f100xb.s
index 599ed3fe..517eeb36 100644
--- a/Expander/startup_stm32f100xb.s
+++ b/Expander/Src/startup_stm32f100xb.s
@@ -391,7 +391,7 @@ g_pfnVectors:
.weak SPI1_IRQHandler
.thumb_set SPI1_IRQHandler,Default_Handler
- .weak SPI1_IRQHandler
+ .weak SPI2_IRQHandler
.thumb_set SPI2_IRQHandler,Default_Handler
.weak USART1_IRQHandler
diff --git a/Expander/Src/stm32f1xx_hal_msp.c b/Expander/Src/stm32f1xx_hal_msp.c
index 91a59662..b3a1a7d8 100644
--- a/Expander/Src/stm32f1xx_hal_msp.c
+++ b/Expander/Src/stm32f1xx_hal_msp.c
@@ -1,51 +1,69 @@
+/* USER CODE BEGIN Header */
/**
******************************************************************************
- * File Name : stm32f1xx_hal_msp.c
- * Description : This file provides code for the MSP Initialization
- * and de-Initialization codes.
+ * @file stm32f1xx_hal_msp.c
+ * @brief This file provides code for the MSP Initialization
+ * and de-Initialization codes.
******************************************************************************
+ * @attention
*
- * COPYRIGHT(c) 2020 STMicroelectronics
+ * © Copyright (c) 2021 STMicroelectronics.
+ * All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
+/* USER CODE END Header */
+
/* Includes ------------------------------------------------------------------*/
-#include "stm32f1xx_hal.h"
+#include "main.h"
+/* USER CODE BEGIN Includes */
+/* USER CODE END Includes */
extern DMA_HandleTypeDef hdma_spi1_rx;
extern DMA_HandleTypeDef hdma_spi1_tx;
-extern DMA_HandleTypeDef hdma_spi2_tx;
+/* Private typedef -----------------------------------------------------------*/
+/* USER CODE BEGIN TD */
+
+/* USER CODE END TD */
+
+/* Private define ------------------------------------------------------------*/
+/* USER CODE BEGIN Define */
+
+/* USER CODE END Define */
+
+/* Private macro -------------------------------------------------------------*/
+/* USER CODE BEGIN Macro */
+
+/* USER CODE END Macro */
+
+/* Private variables ---------------------------------------------------------*/
+/* USER CODE BEGIN PV */
+
+/* USER CODE END PV */
+
+/* Private function prototypes -----------------------------------------------*/
+/* USER CODE BEGIN PFP */
+
+/* USER CODE END PFP */
+
+/* External functions --------------------------------------------------------*/
+/* USER CODE BEGIN ExternalFunctions */
+
+/* USER CODE END ExternalFunctions */
-extern void Error_Handler(void);
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
-/**
+void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
+ /**
* Initializes the Global MSP.
*/
void HAL_MspInit(void)
@@ -55,27 +73,12 @@ void HAL_MspInit(void)
/* USER CODE END MspInit 0 */
__HAL_RCC_AFIO_CLK_ENABLE();
-
- HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
+ __HAL_RCC_PWR_CLK_ENABLE();
/* System interrupt init*/
- /* MemoryManagement_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0);
- /* BusFault_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0);
- /* UsageFault_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0);
- /* SVCall_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0);
- /* DebugMonitor_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0);
- /* PendSV_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0);
- /* SysTick_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
-
- /**NOJTAG: JTAG-DP Disabled and SW-DP Enabled
- */
+
+ /** NOJTAG: JTAG-DP Disabled and SW-DP Enabled
+ */
__HAL_AFIO_REMAP_SWJ_NOJTAG();
/* USER CODE BEGIN MspInit 1 */
@@ -83,10 +86,15 @@ void HAL_MspInit(void)
/* USER CODE END MspInit 1 */
}
+/**
+* @brief SPI MSP Initialization
+* This function configures the hardware resources used in this example
+* @param hspi: SPI handle pointer
+* @retval None
+*/
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
{
-
- GPIO_InitTypeDef GPIO_InitStruct;
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hspi->Instance==SPI1)
{
/* USER CODE BEGIN SPI1_MspInit 0 */
@@ -95,6 +103,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
/* Peripheral clock enable */
__HAL_RCC_SPI1_CLK_ENABLE();
+ __HAL_RCC_GPIOA_CLK_ENABLE();
/**SPI1 GPIO Configuration
PA5 ------> SPI1_SCK
PA6 ------> SPI1_MISO
@@ -110,8 +119,8 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(MAX_DOUT_GPIO_Port, &GPIO_InitStruct);
- /* Peripheral DMA init*/
-
+ /* SPI1 DMA Init */
+ /* SPI1_RX Init */
hdma_spi1_rx.Instance = DMA1_Channel2;
hdma_spi1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_spi1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
@@ -127,6 +136,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
__HAL_LINKDMA(hspi,hdmarx,hdma_spi1_rx);
+ /* SPI1_TX Init */
hdma_spi1_tx.Instance = DMA1_Channel3;
hdma_spi1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_spi1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
@@ -154,6 +164,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
/* Peripheral clock enable */
__HAL_RCC_SPI2_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
/**SPI2 GPIO Configuration
PB12 ------> SPI2_NSS
PB13 ------> SPI2_SCK
@@ -170,24 +181,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(TLC_SOUT_GPIO_Port, &GPIO_InitStruct);
- /* Peripheral DMA init*/
-
- hdma_spi2_tx.Instance = DMA1_Channel5;
- hdma_spi2_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
- hdma_spi2_tx.Init.PeriphInc = DMA_PINC_DISABLE;
- hdma_spi2_tx.Init.MemInc = DMA_MINC_ENABLE;
- hdma_spi2_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
- hdma_spi2_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
- hdma_spi2_tx.Init.Mode = DMA_NORMAL;
- hdma_spi2_tx.Init.Priority = DMA_PRIORITY_LOW;
- if (HAL_DMA_Init(&hdma_spi2_tx) != HAL_OK)
- {
- Error_Handler();
- }
-
- __HAL_LINKDMA(hspi,hdmatx,hdma_spi2_tx);
-
- /* Peripheral interrupt init */
+ /* SPI2 interrupt Init */
HAL_NVIC_SetPriority(SPI2_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(SPI2_IRQn);
/* USER CODE BEGIN SPI2_MspInit 1 */
@@ -197,9 +191,14 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
}
+/**
+* @brief SPI MSP De-Initialization
+* This function freeze the hardware resources used in this example
+* @param hspi: SPI handle pointer
+* @retval None
+*/
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
{
-
if(hspi->Instance==SPI1)
{
/* USER CODE BEGIN SPI1_MspDeInit 0 */
@@ -215,7 +214,7 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
*/
HAL_GPIO_DeInit(GPIOA, MAX_SCLK_Pin|MAX_DOUT_Pin|MAX_DIN_Pin);
- /* Peripheral DMA DeInit*/
+ /* SPI1 DMA DeInit */
HAL_DMA_DeInit(hspi->hdmarx);
HAL_DMA_DeInit(hspi->hdmatx);
/* USER CODE BEGIN SPI1_MspDeInit 1 */
@@ -238,12 +237,8 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
*/
HAL_GPIO_DeInit(GPIOB, TLC_BLANK_Pin|TLC_SCLK_Pin|TLC_SOUT_Pin|TLC_SIN_Pin);
- /* Peripheral DMA DeInit*/
- HAL_DMA_DeInit(hspi->hdmatx);
-
- /* Peripheral interrupt DeInit*/
+ /* SPI2 interrupt DeInit */
HAL_NVIC_DisableIRQ(SPI2_IRQn);
-
/* USER CODE BEGIN SPI2_MspDeInit 1 */
/* USER CODE END SPI2_MspDeInit 1 */
@@ -251,9 +246,14 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
}
+/**
+* @brief TIM_Base MSP Initialization
+* This function configures the hardware resources used in this example
+* @param htim_base: TIM_Base handle pointer
+* @retval None
+*/
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
{
-
if(htim_base->Instance==TIM1)
{
/* USER CODE BEGIN TIM1_MspInit 0 */
@@ -270,14 +270,14 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
{
-
- GPIO_InitTypeDef GPIO_InitStruct;
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
if(htim->Instance==TIM1)
{
/* USER CODE BEGIN TIM1_MspPostInit 0 */
/* USER CODE END TIM1_MspPostInit 0 */
+ __HAL_RCC_GPIOA_CLK_ENABLE();
/**TIM1 GPIO Configuration
PA9 ------> TIM1_CH2
*/
@@ -292,10 +292,14 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
}
}
-
+/**
+* @brief TIM_Base MSP De-Initialization
+* This function freeze the hardware resources used in this example
+* @param htim_base: TIM_Base handle pointer
+* @retval None
+*/
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
{
-
if(htim_base->Instance==TIM1)
{
/* USER CODE BEGIN TIM1_MspDeInit 0 */
@@ -303,17 +307,22 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
/* USER CODE END TIM1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM1_CLK_DISABLE();
- }
/* USER CODE BEGIN TIM1_MspDeInit 1 */
/* USER CODE END TIM1_MspDeInit 1 */
+ }
}
+/**
+* @brief UART MSP Initialization
+* This function configures the hardware resources used in this example
+* @param huart: UART handle pointer
+* @retval None
+*/
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
{
-
- GPIO_InitTypeDef GPIO_InitStruct;
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
if(huart->Instance==USART1)
{
/* USER CODE BEGIN USART1_MspInit 0 */
@@ -322,6 +331,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
/* Peripheral clock enable */
__HAL_RCC_USART1_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
/**USART1 GPIO Configuration
PB6 ------> USART1_TX
PB7 ------> USART1_RX
@@ -338,7 +348,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
__HAL_AFIO_REMAP_USART1_ENABLE();
- /* Peripheral interrupt init */
+ /* USART1 interrupt Init */
HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(USART1_IRQn);
/* USER CODE BEGIN USART1_MspInit 1 */
@@ -348,9 +358,14 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
}
+/**
+* @brief UART MSP De-Initialization
+* This function freeze the hardware resources used in this example
+* @param huart: UART handle pointer
+* @retval None
+*/
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
{
-
if(huart->Instance==USART1)
{
/* USER CODE BEGIN USART1_MspDeInit 0 */
@@ -365,13 +380,12 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
*/
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_7);
- /* Peripheral interrupt DeInit*/
+ /* USART1 interrupt DeInit */
HAL_NVIC_DisableIRQ(USART1_IRQn);
-
- }
/* USER CODE BEGIN USART1_MspDeInit 1 */
/* USER CODE END USART1_MspDeInit 1 */
+ }
}
@@ -379,12 +393,4 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
/* USER CODE END 1 */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Expander/Src/stm32f1xx_it.c b/Expander/Src/stm32f1xx_it.c
index bc1f43a1..1acc550d 100644
--- a/Expander/Src/stm32f1xx_it.c
+++ b/Expander/Src/stm32f1xx_it.c
@@ -1,40 +1,56 @@
+/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f1xx_it.c
* @brief Interrupt Service Routines.
******************************************************************************
+ * @attention
*
- * COPYRIGHT(c) 2016 STMicroelectronics
+ * © Copyright (c) 2021 STMicroelectronics.
+ * All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
+/* USER CODE END Header */
+
/* Includes ------------------------------------------------------------------*/
-#include "stm32f1xx_hal.h"
-#include "stm32f1xx.h"
+#include "main.h"
#include "stm32f1xx_it.h"
+/* Private includes ----------------------------------------------------------*/
+/* USER CODE BEGIN Includes */
+/* USER CODE END Includes */
+
+/* Private typedef -----------------------------------------------------------*/
+/* USER CODE BEGIN TD */
+
+/* USER CODE END TD */
+
+/* Private define ------------------------------------------------------------*/
+/* USER CODE BEGIN PD */
+
+/* USER CODE END PD */
+
+/* Private macro -------------------------------------------------------------*/
+/* USER CODE BEGIN PM */
+
+/* USER CODE END PM */
+
+/* Private variables ---------------------------------------------------------*/
+/* USER CODE BEGIN PV */
+/* USER CODE END PV */
+
+/* Private function prototypes -----------------------------------------------*/
+/* USER CODE BEGIN PFP */
+
+/* USER CODE END PFP */
+
+/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
void serial_rx_callback(uint8_t c);
uint8_t serial_tx_available();
@@ -55,25 +71,24 @@ void setErrorMessage(int8_t err, const char* msg);
/* External variables --------------------------------------------------------*/
extern DMA_HandleTypeDef hdma_spi1_rx;
extern DMA_HandleTypeDef hdma_spi1_tx;
-extern DMA_HandleTypeDef hdma_spi2_tx;
-extern SPI_HandleTypeDef hspi1;
extern SPI_HandleTypeDef hspi2;
extern UART_HandleTypeDef huart1;
+/* USER CODE BEGIN EV */
+
+/* USER CODE END EV */
/******************************************************************************/
-/* Cortex-M3 Processor Interruption and Exception Handlers */
+/* Cortex-M3 Processor Interruption and Exception Handlers */
/******************************************************************************/
-
/**
-* @brief This function handles System tick timer.
-*/
+ * @brief This function handles System tick timer.
+ */
void SysTick_Handler(void)
{
/* USER CODE BEGIN SysTick_IRQn 0 */
/* USER CODE END SysTick_IRQn 0 */
HAL_IncTick();
- HAL_SYSTICK_IRQHandler();
/* USER CODE BEGIN SysTick_IRQn 1 */
/* USER CODE END SysTick_IRQn 1 */
@@ -87,8 +102,8 @@ void SysTick_Handler(void)
/******************************************************************************/
/**
-* @brief This function handles DMA1 channel2 global interrupt.
-*/
+ * @brief This function handles DMA1 channel2 global interrupt.
+ */
void DMA1_Channel2_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Channel2_IRQn 0 */
@@ -101,8 +116,8 @@ void DMA1_Channel2_IRQHandler(void)
}
/**
-* @brief This function handles DMA1 channel3 global interrupt.
-*/
+ * @brief This function handles DMA1 channel3 global interrupt.
+ */
void DMA1_Channel3_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Channel3_IRQn 0 */
@@ -115,22 +130,8 @@ void DMA1_Channel3_IRQHandler(void)
}
/**
-* @brief This function handles DMA1 channel5 global interrupt.
-*/
-void DMA1_Channel5_IRQHandler(void)
-{
- /* USER CODE BEGIN DMA1_Channel5_IRQn 0 */
-
- /* USER CODE END DMA1_Channel5_IRQn 0 */
- HAL_DMA_IRQHandler(&hdma_spi2_tx);
- /* USER CODE BEGIN DMA1_Channel5_IRQn 1 */
-
- /* USER CODE END DMA1_Channel5_IRQn 1 */
-}
-
-/**
-* @brief This function handles SPI2 global interrupt.
-*/
+ * @brief This function handles SPI2 global interrupt.
+ */
void SPI2_IRQHandler(void)
{
/* USER CODE BEGIN SPI2_IRQn 0 */
@@ -142,20 +143,9 @@ void SPI2_IRQHandler(void)
/* USER CODE END SPI2_IRQn 1 */
}
-void SPI1_IRQHandler(void)
-{
- /* USER CODE BEGIN SPI2_IRQn 0 */
-
- /* USER CODE END SPI2_IRQn 0 */
- HAL_SPI_IRQHandler(&hspi1);
- /* USER CODE BEGIN SPI2_IRQn 1 */
-
- /* USER CODE END SPI2_IRQn 1 */
-}
-
/**
-* @brief This function handles USART1 global interrupt.
-*/
+ * @brief This function handles USART1 global interrupt.
+ */
void USART1_IRQHandler(void)
{
/* USER CODE BEGIN USART1_IRQn 0 */
@@ -216,10 +206,11 @@ void USART1_IRQHandler(void)
{
serial_rx_callback((uint8_t)(huart->Instance->DR & (uint8_t)0x00FF));
}
+#if 0
/* USER CODE END USART1_IRQn 0 */
- /* HAL_UART_IRQHandler(&huart1); */
+ HAL_UART_IRQHandler(&huart1);
/* USER CODE BEGIN USART1_IRQn 1 */
-
+#endif
/* USER CODE END USART1_IRQn 1 */
}
diff --git a/Expander/common.mk b/Expander/common.mk
index c6e33861..fd0c9723 100755
--- a/Expander/common.mk
+++ b/Expander/common.mk
@@ -1,6 +1,6 @@
# name of executable
-ELF=$(BUILD)/Expander.elf
-BIN=$(BUILD)/Expander.bin
+ELF=$(BUILD)/$(PROJECT).elf
+BIN=$(BUILD)/$(PROJECT).bin
# Tool path
TOOLROOT ?= ~/bin/gcc-arm-none-eabi-9-2020-q2-update/bin/
@@ -18,21 +18,12 @@ OBJDUMP=$(TOOLROOT)/arm-none-eabi-objdump
SIZE=$(TOOLROOT)/arm-none-eabi-size
# Set up search path
-vpath %.cpp $(TEMPLATEROOT)/Source
-vpath %.c $(TEMPLATEROOT)/Source
-vpath %.s $(TEMPLATEROOT)/Source
-vpath %.cpp $(TEMPLATEROOT)/MDK-ARM
-vpath %.c $(TEMPLATEROOT)/MDK-ARM
-vpath %.s $(TEMPLATEROOT)/MDK-ARM
-vpath %.cpp $(TEMPLATEROOT)/Src
-vpath %.c $(TEMPLATEROOT)/Src
-vpath %.s $(TEMPLATEROOT)/Src
-vpath %.c $(TEMPLATEROOT)/Libraries/syscalls
-vpath %.c $(PERIPH_FILE)/src
-vpath %.c $(PERIPH_FILE)/inc
-vpath %.c $(DEVICE)
-vpath %.c $(USB_DEVICE_FILE)/Core/src
-vpath %.c $(USB_OTG_FILE)/src/
+OBJS = $(addprefix $(BUILD)/,$(notdir $(C_SRC:.c=.o)))
+vpath %.c $(sort $(dir $(C_SRC)))
+OBJS += $(addprefix $(BUILD)/,$(notdir $(CPP_SRC:.cpp=.o)))
+vpath %.cpp $(sort $(dir $(CPP_SRC)))
+OBJS += $(addprefix $(BUILD)/,$(notdir $(S_SRC:.s=.o)))
+vpath %.s $(sort $(dir $(S_SRC)))
all: bin
@@ -67,6 +58,9 @@ clean:
flash:
$(OPENOCD) -c "program Build/$(PROJECT).elf verify reset exit"
+dump: # flash read_bank num filename [offset [length]]
+ $(OPENOCD) -c "init" -c "halt" -c "flash read_bank 0 dump.bin" -c "exit"
+
debug: $(ELF)
@$(GDB) -ex "target extended-remote localhost:3333" -ex "monitor reset hard" -ex "monitor arm semihosting enable" -ex "load" $(ELF)
diff --git a/Expander/f1.mk b/Expander/f1.mk
index 41682c7b..613e165c 100644
--- a/Expander/f1.mk
+++ b/Expander/f1.mk
@@ -1,13 +1,13 @@
# Library path
-LIBROOT=$(TEMPLATEROOT)/Drivers/
+LIBROOT=$(OPENWARE)/Libraries/Drivers/
# Build path
-BUILD=$(TEMPLATEROOT)/Build
+BUILD=$(BUILDROOT)/Build
# Code Paths
DEVICE=$(LIBROOT)/CMSIS/Device/ST/STM32F1xx
CMSIS=$(LIBROOT)/CMSIS/Include
-PERIPH_FILE=$(LIBROOT)/STM32F1xx_StdPeriph_Driver
+#PERIPH_FILE=$(LIBROOT)/STM32F1xx_StdPeriph_Driver
DSPLIB=$(LIBROOT)/CMSIS/DSP_Lib/Source
DRIVERS=$(LIBROOT)/STM32F1xx_HAL_Driver
@@ -29,12 +29,13 @@ ARCH_FLAGS += -fsingle-precision-constant -ffast-math
# DEF_FLAGS = -DUSE_STDPERIPH_DRIVER -DSTM32F10X_MD_VL
DEF_FLAGS = -DARM_MATH_CM3
DEF_FLAGS += -DUSE_HAL_DRIVER -DSTM32F100xB
-INC_FLAGS = -I$(TEMPLATEROOT)/Libraries -I$(CMSIS)
-INC_FLAGS += -I$(TEMPLATEROOT)/Source -I$(TEMPLATEROOT)/Inc -I$(TEMPLATEROOT)/MDK-ARM
+INC_FLAGS = -I$(OPENWARE)/Libraries -I$(CMSIS)
+INC_FLAGS += -I$(BUILDROOT)/Source -I$(BUILDROOT)/Inc -I$(BUILDROOT)/MDK-ARM
INC_FLAGS += -I$(DEVICE)/Include
INC_FLAGS += -I$(DRIVERS)/Inc
CFLAGS += $(ARCH_FLAGS) $(INC_FLAGS) $(DEF_FLAGS)
CXXFLAGS += $(ARCH_FLAGS) $(INC_FLAGS) $(DEF_FLAGS)
LDFLAGS += -T$(LDSCRIPT) $(ARCH_FLAGS)
-include $(TEMPLATEROOT)/common.mk
+include $(BUILDROOT)/libs.mk
+include $(BUILDROOT)/common.mk
diff --git a/Expander/libs.mk b/Expander/libs.mk
index f6480197..ec6b7ed4 100644
--- a/Expander/libs.mk
+++ b/Expander/libs.mk
@@ -1,64 +1,61 @@
-# object files
-OBJS += $(PERIPH)
+C_SRC += $(DRIVERS)/Src/stm32f1xx_hal.c
+C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_rcc.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_dac.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_i2c.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_i2c_ex.c
+C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_dma.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_dma_ex.c
+C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_gpio.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_adc.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_adc_ex.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_pwr_ex.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_rcc_ex.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_flash_ex.c
+C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_tim_ex.c
+C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_tim.c
+C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_cortex.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_sai.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_sai_ex.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_rng.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_qspi.c
+C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_uart.c
+C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_spi.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_dma2d.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_hcd.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_pcd.c # USB Device
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_pcd_ex.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_hal_sdram.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_ll_usb.c
+# C_SRC += $(DRIVERS)/Src/stm32f1xx_ll_fmc.c
-OBJS += $(DRIVERS)/Src/stm32f1xx_hal.o
-OBJS += $(DRIVERS)/Src/stm32f1xx_hal_rcc.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_hal_dac.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_hal_i2c.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_hal_i2c_ex.o
-OBJS += $(DRIVERS)/Src/stm32f1xx_hal_dma.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_hal_dma_ex.o
-OBJS += $(DRIVERS)/Src/stm32f1xx_hal_gpio.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_hal_adc.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_hal_adc_ex.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_hal_pwr_ex.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_hal_rcc_ex.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_hal_flash_ex.o
-OBJS += $(DRIVERS)/Src/stm32f1xx_hal_tim_ex.o
-OBJS += $(DRIVERS)/Src/stm32f1xx_hal_tim.o
-OBJS += $(DRIVERS)/Src/stm32f1xx_hal_cortex.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_hal_sai.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_hal_sai_ex.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_hal_rng.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_hal_qspi.o
-OBJS += $(DRIVERS)/Src/stm32f1xx_hal_uart.o
-OBJS += $(DRIVERS)/Src/stm32f1xx_hal_spi.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_hal_dma2d.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_hal_hcd.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_hal_pcd.o # USB Device
-# OBJS += $(DRIVERS)/Src/stm32f1xx_hal_pcd_ex.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_hal_sdram.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_ll_usb.o
-# OBJS += $(DRIVERS)/Src/stm32f1xx_ll_fmc.o
+# C_SRC += $(BUILD)/startup.c
+# C_SRC += $(BUILD)/libnosys_gnu.c
+# C_SRC += $(USB_DEVICE) $(USB_OTG)
+# C_SRC += $(DSPLIB)/FastMathFunctions/arm_sin_f32.c
+# C_SRC += $(DSPLIB)/FastMathFunctions/arm_cos_f32.c
+# C_SRC += $(DSPLIB)/CommonTables/arm_common_tables.c
-# OBJS += $(BUILD)/startup.o
-# OBJS += $(BUILD)/libnosys_gnu.o
-# OBJS += $(USB_DEVICE) $(USB_OTG)
-# OBJS += $(DSPLIB)/FastMathFunctions/arm_sin_f32.o
-# OBJS += $(DSPLIB)/FastMathFunctions/arm_cos_f32.o
-# OBJS += $(DSPLIB)/CommonTables/arm_common_tables.o
+# C_SRC += $(DSPLIB)/TransformFunctions/arm_cfft_f32.c
+# C_SRC += $(DSPLIB)/TransformFunctions/arm_cfft_radix8_f32.c
+# C_SRC += $(DSPLIB)/TransformFunctions/arm_bitreversal2.c
+# C_SRC += $(DSPLIB)/TransformFunctions/arm_rfft_fast_f32.c
+# C_SRC += $(DSPLIB)/TransformFunctions/arm_rfft_fast_init_f32.c
+# C_SRC += $(DSPLIB)/CommonTables/arm_const_structs.c
-# OBJS += $(DSPLIB)/TransformFunctions/arm_cfft_f32.o
-# OBJS += $(DSPLIB)/TransformFunctions/arm_cfft_radix8_f32.o
-# OBJS += $(DSPLIB)/TransformFunctions/arm_bitreversal2.o
-# OBJS += $(DSPLIB)/TransformFunctions/arm_rfft_fast_f32.o
-# OBJS += $(DSPLIB)/TransformFunctions/arm_rfft_fast_init_f32.o
-# OBJS += $(DSPLIB)/CommonTables/arm_const_structs.o
+# C_SRC += $(DSPLIB)/FilteringFunctions/arm_biquad_cascade_df1_init_f32.c
+# C_SRC += $(DSPLIB)/FilteringFunctions/arm_biquad_cascade_df1_f32.c
-# OBJS += $(DSPLIB)/FilteringFunctions/arm_biquad_cascade_df1_init_f32.o
-# OBJS += $(DSPLIB)/FilteringFunctions/arm_biquad_cascade_df1_f32.o
+# C_SRC += $(DSPLIB)/SupportFunctions/arm_copy_f32.c
+# C_SRC += $(DSPLIB)/SupportFunctions/arm_float_to_q31.c
+# C_SRC += $(DSPLIB)/SupportFunctions/arm_q31_to_float.c
+# C_SRC += $(DSPLIB)/SupportFunctions/arm_float_to_q15.c
+# C_SRC += $(DSPLIB)/SupportFunctions/arm_q15_to_float.c
-# OBJS += $(DSPLIB)/SupportFunctions/arm_copy_f32.o
-# OBJS += $(DSPLIB)/SupportFunctions/arm_float_to_q31.o
-# OBJS += $(DSPLIB)/SupportFunctions/arm_q31_to_float.o
-# OBJS += $(DSPLIB)/SupportFunctions/arm_float_to_q15.o
-# OBJS += $(DSPLIB)/SupportFunctions/arm_q15_to_float.o
-
-# OBJS += $(DSPLIB)/FastMathFunctions/arm_sin_f32.o
-# OBJS += $(DSPLIB)/FastMathFunctions/arm_cos_f32.o
-# OBJS += $(DSPLIB)/FilteringFunctions/arm_biquad_cascade_df1_f32.o
-# OBJS += $(DSPLIB)/FilteringFunctions/arm_biquad_cascade_df1_init_f32.o
-# OBJS += $(DSPLIB)/SupportFunctions/arm_float_to_q31.o
-# OBJS += $(DSPLIB)/SupportFunctions/arm_q31_to_float.o
-# OBJS += $(DSPLIB)/SupportFunctions/arm_float_to_q15.o
-# OBJS += $(DSPLIB)/SupportFunctions/arm_q15_to_float.o
+# C_SRC += $(DSPLIB)/FastMathFunctions/arm_sin_f32.c
+# C_SRC += $(DSPLIB)/FastMathFunctions/arm_cos_f32.c
+# C_SRC += $(DSPLIB)/FilteringFunctions/arm_biquad_cascade_df1_f32.c
+# C_SRC += $(DSPLIB)/FilteringFunctions/arm_biquad_cascade_df1_init_f32.c
+# C_SRC += $(DSPLIB)/SupportFunctions/arm_float_to_q31.c
+# C_SRC += $(DSPLIB)/SupportFunctions/arm_q31_to_float.c
+# C_SRC += $(DSPLIB)/SupportFunctions/arm_float_to_q15.c
+# C_SRC += $(DSPLIB)/SupportFunctions/arm_q15_to_float.c