| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\spi_flash\source\spi_flash.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\ChaletduinoV2Board.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\socket\source\socket.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\m2m_wifi.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\BootloaderProtocol.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\BootloaderInterface.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\nmspi.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\DigitalIO.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\BootloaderInterface.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\m2m_flash.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\m2m_ssl.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\nmasic.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\exceptions.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\system.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\m2m_wifi.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\interrupts.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\exceptions.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\Syslog.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\interrupts.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\socket\source\socket.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\m2m_flash.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\SPI_Flash.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\template.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\SPI.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\BootloaderProtocol.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\VolumeTransducer.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\nmspi.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\socket\source\inet_addr.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\socket\source\inet_ntop.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\m2m_ota.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\nmdrv.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\Watchdog.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\Util.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\timer.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\common\source\nm_common.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\template.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\m2m_periph.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\nmasic.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\WiFiCtrl.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\nmdrv.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\Terminal.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\Syslog.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\crc32.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\nmbus.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\Watchdog.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\NetworkProtocol.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\spi_flash\source\spi_flash.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\DigitalIO.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\nmbus.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\SPI_Flash.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\m2m_periph.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\main.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\socket\source\inet_addr.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\m2m_ota.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\m2m_hif.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\SPI.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\crc32.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\Util.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\WiFiCtrl.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\main.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\m2m_hif.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\common\source\nm_common.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\system.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\Terminal.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\socket\source\inet_ntop.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\timer.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\ChaletduinoV2Board.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\NetworkProtocol.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -fframe-base-loclist -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\VolumeTransducer.c | |||||
| @@ -0,0 +1 @@ | |||||
| $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -I"Source" -I"Source/winc3400_142" -I"Source/winc3400_142/bsp/include" -I"Source/winc3400_142/common/include" -I"Source/winc3400_142/driver/include" -I"Source/winc3400_142/socket/include" -I"Source/winc3400_142/spi_flash/include" -DCHALETDUINO_V2_BRD -D_SUPPRESS_PLIB_WARNING -DXPRJ_ChaletDuinoV2_795F512H_=$(CND_CONF) $(COMPARISON_BUILD) D:\Main\PicDev\Projets\AudioConsole\AudioConsole.X\Source\winc3400_142\driver\source\m2m_ssl.c | |||||
| @@ -0,0 +1,23 @@ | |||||
| /* | |||||
| * File: ATCmdInterpreter.h | |||||
| * Author: JF | |||||
| * | |||||
| * Created on December 28, 2024, 8:08 AM | |||||
| */ | |||||
| #ifndef ATCMDINTERPRETER_H | |||||
| #define ATCMDINTERPRETER_H | |||||
| #ifdef __cplusplus | |||||
| extern "C" { | |||||
| #endif | |||||
| #ifdef __cplusplus | |||||
| } | |||||
| #endif | |||||
| #endif /* ATCMDINTERPRETER_H */ | |||||
| @@ -0,0 +1,113 @@ | |||||
| # | |||||
| # There exist several targets which are by default empty and which can be | |||||
| # used for execution of your targets. These targets are usually executed | |||||
| # before and after some main targets. They are: | |||||
| # | |||||
| # .build-pre: called before 'build' target | |||||
| # .build-post: called after 'build' target | |||||
| # .clean-pre: called before 'clean' target | |||||
| # .clean-post: called after 'clean' target | |||||
| # .clobber-pre: called before 'clobber' target | |||||
| # .clobber-post: called after 'clobber' target | |||||
| # .all-pre: called before 'all' target | |||||
| # .all-post: called after 'all' target | |||||
| # .help-pre: called before 'help' target | |||||
| # .help-post: called after 'help' target | |||||
| # | |||||
| # Targets beginning with '.' are not intended to be called on their own. | |||||
| # | |||||
| # Main targets can be executed directly, and they are: | |||||
| # | |||||
| # build build a specific configuration | |||||
| # clean remove built files from a configuration | |||||
| # clobber remove all built files | |||||
| # all build all configurations | |||||
| # help print help mesage | |||||
| # | |||||
| # Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and | |||||
| # .help-impl are implemented in nbproject/makefile-impl.mk. | |||||
| # | |||||
| # Available make variables: | |||||
| # | |||||
| # CND_BASEDIR base directory for relative paths | |||||
| # CND_DISTDIR default top distribution directory (build artifacts) | |||||
| # CND_BUILDDIR default top build directory (object files, ...) | |||||
| # CONF name of current configuration | |||||
| # CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) | |||||
| # CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) | |||||
| # CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) | |||||
| # CND_PACKAGE_DIR_${CONF} directory of package (current configuration) | |||||
| # CND_PACKAGE_NAME_${CONF} name of package (current configuration) | |||||
| # CND_PACKAGE_PATH_${CONF} path to package (current configuration) | |||||
| # | |||||
| # NOCDDL | |||||
| # Environment | |||||
| MKDIR=mkdir | |||||
| CP=cp | |||||
| CCADMIN=CCadmin | |||||
| RANLIB=ranlib | |||||
| # build | |||||
| build: .build-post | |||||
| .build-pre: | |||||
| # Add your pre 'build' code here... | |||||
| .build-post: .build-impl | |||||
| # Add your post 'build' code here... | |||||
| # clean | |||||
| clean: .clean-post | |||||
| .clean-pre: | |||||
| # Add your pre 'clean' code here... | |||||
| # WARNING: the IDE does not call this target since it takes a long time to | |||||
| # simply run make. Instead, the IDE removes the configuration directories | |||||
| # under build and dist directly without calling make. | |||||
| # This target is left here so people can do a clean when running a clean | |||||
| # outside the IDE. | |||||
| .clean-post: .clean-impl | |||||
| # Add your post 'clean' code here... | |||||
| # clobber | |||||
| clobber: .clobber-post | |||||
| .clobber-pre: | |||||
| # Add your pre 'clobber' code here... | |||||
| .clobber-post: .clobber-impl | |||||
| # Add your post 'clobber' code here... | |||||
| # all | |||||
| all: .all-post | |||||
| .all-pre: | |||||
| # Add your pre 'all' code here... | |||||
| .all-post: .all-impl | |||||
| # Add your post 'all' code here... | |||||
| # help | |||||
| help: .help-post | |||||
| .help-pre: | |||||
| # Add your pre 'help' code here... | |||||
| .help-post: .help-impl | |||||
| # Add your post 'help' code here... | |||||
| # include project implementation makefile | |||||
| include nbproject/Makefile-impl.mk | |||||
| # include project make variables | |||||
| include nbproject/Makefile-variables.mk | |||||
| @@ -0,0 +1,265 @@ | |||||
| /******************************************************************************* | |||||
| * * | |||||
| * Copyright 2012 Rheinmetall Canada Inc. * | |||||
| * * | |||||
| * No part of this document may be reproduced, stored in * | |||||
| * a retrieval system, or transmitted, in any form or by any means, * | |||||
| * electronic, mechanical, photocopying, recording, or otherwise, * | |||||
| * without the prior written permission of Rheinmetall Canada Inc. * | |||||
| * * | |||||
| *******************************************************************************/ | |||||
| /* | |||||
| Description: | |||||
| This is a template file for standard C header file. | |||||
| */ | |||||
| /* ************************************************************************** */ | |||||
| /* Revision: | |||||
| ### 20120521 JFM | |||||
| Original version. | |||||
| ### YYYYMMDD Initial, Bug Identification | |||||
| Change description. | |||||
| */ | |||||
| /* ************************************************************************** */ | |||||
| /* Includes */ | |||||
| #include "define.h" | |||||
| #include "ADC.h" | |||||
| #include "HallAcquisition.h" | |||||
| #include "digitalio.h" | |||||
| #include "PAStatus.h" | |||||
| /* Globals */ | |||||
| unsigned int guiADCMode; | |||||
| unsigned short egADCMotPhaseA; | |||||
| unsigned short egADCMotPhaseB; | |||||
| unsigned short egADCMotPhaseC; | |||||
| /* Implementation */ | |||||
| //---------------------------------------------------------------------------- | |||||
| void InitADC(void) | |||||
| { | |||||
| //At boot, init ADC in normal mode... | |||||
| guiADCMode = ADC_NORMAL_MODE; | |||||
| //configure input pins as analog inputs. | |||||
| TRISBbits.TRISB3 = 1; | |||||
| AD1PCFGbits.PCFG3 = 0; | |||||
| TRISBbits.TRISB4 = 1; | |||||
| AD1PCFGbits.PCFG4 = 0; | |||||
| TRISBbits.TRISB5 = 1; | |||||
| AD1PCFGbits.PCFG5 = 0; | |||||
| TRISBbits.TRISB8 = 1; | |||||
| AD1PCFGbits.PCFG8 = 0; | |||||
| TRISBbits.TRISB9 = 1; | |||||
| AD1PCFGbits.PCFG9 = 0; | |||||
| TRISBbits.TRISB11 = 1; | |||||
| AD1PCFGbits.PCFG11 = 0; | |||||
| TRISBbits.TRISB12 = 1; | |||||
| AD1PCFGbits.PCFG12 = 0; | |||||
| TRISBbits.TRISB13 = 1; | |||||
| AD1PCFGbits.PCFG13 = 0; | |||||
| AD1CON1 = 0; | |||||
| AD1CON2 = 0; | |||||
| AD1CON3 = 0; | |||||
| //configure output format (unsigned int 16 bits) | |||||
| AD1CON1bits.FORM = 0b000; | |||||
| //configure clock source and prescaling | |||||
| AD1CON3bits.ADRC = 0; //Use Peripheral clock | |||||
| AD1CON3bits.ADCS = 4; //Acording to datasheet TAD must be min 83.33ns --> minimal prescaler applied to TPBclk = 8 --> Conversion time ~= 100ns | |||||
| //AD1CON3bits.SAMC = 1; //Used in automatic sampling mode (scan mode). Shall be augmented if results are not accurate. See datasheet. | |||||
| AD1CON3bits.SAMC = 30; //Used in automatic sampling mode (scan mode). Shall be augmented if results are not accurate. See datasheet. | |||||
| } | |||||
| //---------------------------------------------------------------------------- | |||||
| //---------------------------------------------------------------------------- | |||||
| int ADCEnterHallACQMode(void) | |||||
| { | |||||
| //configure ADC module | |||||
| AD1CON1bits.ON = 0; //stop ADC to reconfigure. | |||||
| IEC1bits.AD1IE = 0; //disable ADC interrupt for now | |||||
| AD1CHS = 0; //Reset channel source since input source is controlled by hardware in scan mode. | |||||
| AD1CON2 = 0; | |||||
| AD1CSSL = 0; | |||||
| AD1CON1bits.SSRC = 0b111; //manual conversion start. Clearing SAMP starts conversion. See AD1CON3bits.SAMC for sampling time. | |||||
| // AD1CON1bits.SSRC = 0b000; //manual conversion start. Clearing SAMP starts conversion. See AD1CON3bits.SAMC for sampling time. | |||||
| AD1CON1bits.CLRASAM = 1; | |||||
| AD1CON1bits.ASAM = 1; | |||||
| //configure scan mode | |||||
| AD1CON2bits.CSCNA = 1; //enable scan mode | |||||
| AD1CON2bits.SMPI = 2; //Generate interrupt after the 3rd conversion. | |||||
| AD1CSSLbits.CSSL11= 1; //select Phase A input in scan sequence | |||||
| AD1CSSLbits.CSSL12= 1; //select Phase B input in scan sequence | |||||
| AD1CSSLbits.CSSL13= 1; //select Phase C input in scan sequence | |||||
| AD1CON1bits.SAMP = 1 ; | |||||
| IPC6bits.AD1IP = 5; | |||||
| IPC6bits.AD1IS = 3; | |||||
| IFS1bits.AD1IF = 0; | |||||
| IEC1bits.AD1IE = 1; //enable ADC interrupt | |||||
| AD1CON1bits.ON = 1; //enable ADC. | |||||
| guiADCMode = ADC_HALL_ACQ_MODE; | |||||
| return 1; | |||||
| } | |||||
| //---------------------------------------------------------------------------- | |||||
| //---------------------------------------------------------------------------- | |||||
| int ADCEnterTracesMode(void) | |||||
| { | |||||
| //trick to reuse code but force the good mode :) | |||||
| ADCEnterHallACQMode(); | |||||
| guiADCMode = ADC_TRACE_MODE; | |||||
| return 1; | |||||
| } | |||||
| //---------------------------------------------------------------------------- | |||||
| //---------------------------------------------------------------------------- | |||||
| int ADCEnterCBITMode(void) | |||||
| { | |||||
| //configure ADC module | |||||
| AD1CON1bits.ON = 0; //stop ADC to reconfigure. | |||||
| IEC1bits.AD1IE = 0; //disable ADC interrupt for now | |||||
| AD1CHS = 0; //Reset channel source since input source is controlled by hardware in scan mode. | |||||
| AD1CON2 = 0; | |||||
| AD1CSSL = 0; | |||||
| AD1CON1bits.SSRC = 0b111; //manual conversion start. Clearing SAMP starts conversion. See AD1CON3bits.SAMC for sampling time. | |||||
| // AD1CON1bits.SSRC = 0b000; //manual conversion start. Clearing SAMP starts conversion. See AD1CON3bits.SAMC for sampling time. | |||||
| AD1CON1bits.CLRASAM = 1; | |||||
| AD1CON1bits.ASAM = 1; | |||||
| //configure scan mode | |||||
| AD1CON2bits.CSCNA = 1; //enable scan mode | |||||
| AD1CON2bits.SMPI = 4; //Generate interrupt after the 5th conversion. | |||||
| AD1CSSLbits.CSSL3= 1; //select Vref input in scan sequence | |||||
| AD1CSSLbits.CSSL4= 1; //select 5V input in scan sequence | |||||
| AD1CSSLbits.CSSL5= 1; //select 3.3V input in scan sequence | |||||
| AD1CSSLbits.CSSL8= 1; //select Motor Thermistor input in scan sequence | |||||
| AD1CSSLbits.CSSL9= 1; //select Drive Thermistor input in scan sequence | |||||
| AD1CON1bits.SAMP = 1; | |||||
| IPC6bits.AD1IP = 5; | |||||
| IPC6bits.AD1IS = 3; | |||||
| IFS1bits.AD1IF = 0; | |||||
| IEC1bits.AD1IE = 1; //enable ADC interrupt | |||||
| AD1CON1bits.ON = 1; //enable ADC. | |||||
| guiADCMode = ADC_CBIT_MODE; | |||||
| return 1; | |||||
| } | |||||
| //---------------------------------------------------------------------------- | |||||
| //---------------------------------------------------------------------------- | |||||
| // Starts acquistion and conversion of the 3 phases. The 3 inputs are scanned | |||||
| // automatically by hardware and an interrupt is triggered when finished. | |||||
| // | |||||
| int ADCStartHallACQConversion(void) | |||||
| { | |||||
| AD1CON1bits.ASAM = 1; | |||||
| AD1CON1bits.SAMP = 1; //start sampling and start conversion. Interrupt will be generated when data is ready | |||||
| return 1; | |||||
| } | |||||
| //---------------------------------------------------------------------------- | |||||
| //---------------------------------------------------------------------------- | |||||
| int ADCStartTracesConversion(void) | |||||
| { | |||||
| AD1CON1bits.ASAM = 1; | |||||
| AD1CON1bits.SAMP = 1; //start sampling and start conversion. Interrupt will be generated when data is ready | |||||
| return 1; | |||||
| } | |||||
| //---------------------------------------------------------------------------- | |||||
| //---------------------------------------------------------------------------- | |||||
| int ADCStartCBITConversion(void) | |||||
| { | |||||
| if(guiADCMode == ADC_CBIT_MODE) | |||||
| { | |||||
| AD1CON1bits.ASAM = 1; | |||||
| AD1CON1bits.SAMP = 1; //start sampling and start conversion. Interrupt will be generated when data is ready | |||||
| return 1; | |||||
| } | |||||
| return 0; | |||||
| } | |||||
| //---------------------------------------------------------------------------- | |||||
| //---------------------------------------------------------------------------- | |||||
| int ADCStopConversion(void) | |||||
| { | |||||
| return 1; | |||||
| } | |||||
| //---------------------------------------------------------------------------- | |||||
| int ADCGetMode(void) | |||||
| { | |||||
| return guiADCMode; | |||||
| } | |||||
| //---------------------------------------------------------------------------- | |||||
| void __ISR(_ADC_VECTOR, ipl5) ADCInterrupt(void) | |||||
| { | |||||
| switch(guiADCMode) | |||||
| { | |||||
| case ADC_NORMAL_MODE: | |||||
| { | |||||
| break; | |||||
| } | |||||
| case ADC_CBIT_MODE: | |||||
| { | |||||
| estPAStatus.gusVoltageVref = ADC1BUF0; | |||||
| estPAStatus.gusVoltage5V = ADC1BUF1; | |||||
| estPAStatus.gusVoltage33V = ADC1BUF2; | |||||
| estPAStatus.gusVoltageThermMot = ADC1BUF3; | |||||
| estPAStatus.gusVoltageThermDrv = ADC1BUF4; | |||||
| estPAStatus.IsDataReady = 1; | |||||
| break; | |||||
| } | |||||
| case ADC_TRACE_MODE: | |||||
| { | |||||
| egADCMotPhaseA = ADC1BUF0; | |||||
| egADCMotPhaseB = ADC1BUF1; | |||||
| egADCMotPhaseC = ADC1BUF2; | |||||
| break; | |||||
| } | |||||
| case ADC_HALL_ACQ_MODE: | |||||
| { | |||||
| //Update data structure. | |||||
| if(gpstHallAcqDataPtr != 0 && gpstHallAcqDataPtr <= gpstHallAcqDataPtrEND) | |||||
| { | |||||
| gpstHallAcqDataPtr->MotPhaseA = ADC1BUF0; | |||||
| gpstHallAcqDataPtr->MotPhaseB = ADC1BUF1; | |||||
| gpstHallAcqDataPtr->MotPhaseC = ADC1BUF2; | |||||
| gpstHallAcqDataPtr->AnalogDataUpToDate = 1; | |||||
| } | |||||
| break; | |||||
| } | |||||
| } | |||||
| IFS1bits.AD1IF = 0; | |||||
| } | |||||
| //---------------------------------------------------------------------------- | |||||
| //EOF | |||||
| @@ -0,0 +1,73 @@ | |||||
| /******************************************************************************* | |||||
| * * | |||||
| * Copyright 2012 Rheinmetall Canada Inc. * | |||||
| * * | |||||
| * No part of this document may be reproduced, stored in * | |||||
| * a retrieval system, or transmitted, in any form or by any means, * | |||||
| * electronic, mechanical, photocopying, recording, or otherwise, * | |||||
| * without the prior written permission of Rheinmetall Canada Inc. * | |||||
| * * | |||||
| *******************************************************************************/ | |||||
| /* | |||||
| Description: | |||||
| This is a template file for standard C header file. | |||||
| */ | |||||
| /* ************************************************************************** */ | |||||
| /* ¤Revision: | |||||
| 000 20120516 JFM, | |||||
| Original version. | |||||
| ### YYYYMMDD Initial, Bug Identification | |||||
| Change description. | |||||
| */ | |||||
| #ifndef ADC_H | |||||
| #define ADC_H | |||||
| /* ************************************************************************** */ | |||||
| /* Externs */ | |||||
| extern unsigned short egADCMotPhaseA; | |||||
| extern unsigned short egADCMotPhaseB; | |||||
| extern unsigned short egADCMotPhaseC; | |||||
| /* ************************************************************************** */ | |||||
| /* Defines */ | |||||
| #define ADC_VOLT_PER_BIT (float)0.003222656 | |||||
| /* ************************************************************************** */ | |||||
| /* Type definitions */ | |||||
| enum eADCModes | |||||
| { | |||||
| ADC_NORMAL_MODE, | |||||
| ADC_CBIT_MODE, | |||||
| ADC_TRACE_MODE, | |||||
| ADC_HALL_ACQ_MODE, | |||||
| ADC_MAX_MODE | |||||
| }; | |||||
| /* ************************************************************************** */ | |||||
| /* Prototypes */ | |||||
| void InitADC(void); | |||||
| int ADCStopConversion(void); | |||||
| //Hall Acquisition Mode | |||||
| int ADCEnterHallACQMode(void); | |||||
| int ADCStartHallACQConversion(void); | |||||
| //Traces Mode | |||||
| int ADCEnterTracesMode(void); | |||||
| int ADCStartTracesConversion(void); | |||||
| //CBIT Mode | |||||
| int ADCEnterCBITMode(void); | |||||
| int ADCStartCBITConversion(void); | |||||
| int ADCGetMode(void); | |||||
| #endif //#define ADC_H | |||||
| //EOF | |||||
| @@ -0,0 +1,221 @@ | |||||
| #include "ATCmdInterpreter.h" | |||||
| #include "SIM7080GInterface.h" | |||||
| #include "define.h" | |||||
| #include <string.h> | |||||
| #include <stdio.h> | |||||
| #include <stdlib.h> | |||||
| #include "SIM7080GInterface.h" | |||||
| bool mCAStateReceived; | |||||
| char mMasterData[100]; | |||||
| int mMasterDataSize; | |||||
| char mInputString[100]; | |||||
| void InitATCmdInterpreter() | |||||
| { | |||||
| mCAStateReceived = false; | |||||
| } | |||||
| int AnalyzeNewATString(char* Str, int StrLen, int CurCmd) | |||||
| { | |||||
| memset(mInputString,0,100); | |||||
| memcpy(mInputString,Str,StrLen); | |||||
| switch(CurCmd) | |||||
| { | |||||
| case LTE_MODULE_CONNECT_APN_CMD: //AT+CNACT=0,1 | |||||
| { | |||||
| if(strncmp(mInputString,"OK",2) == 0) //The command was executed | |||||
| { | |||||
| LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_OK); | |||||
| } | |||||
| else if(strncmp(mInputString,"ERROR",5) == 0) //The command was not executed | |||||
| { | |||||
| LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_ERROR); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case LTE_MODULE_DISCONNECT_APN_CMD: | |||||
| { | |||||
| if(strncmp(mInputString,"OK",2) == 0) //The command was executed | |||||
| { | |||||
| LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_OK); | |||||
| } | |||||
| else if(strncmp(mInputString,"ERROR",5) == 0) //The command was not executed | |||||
| { | |||||
| LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_ERROR); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case LTE_MODULE_CHECK_APN_CONNECTION_CMD: | |||||
| { | |||||
| if(strncmp("+CNACT:",mInputString,strlen("+CNACT:")) == 0) //+CNACT: 0,1,"10.177.232.192","2605:8D80:5C0:3EED:D90E:5B72:BC1B:281" | |||||
| { | |||||
| if(mInputString[8] == '0') //Only consider port 0 | |||||
| { | |||||
| if(mInputString[10] == '1' || mInputString[10] == '2') | |||||
| { | |||||
| LTEModuleAPNConnectionStatus(LTE_MODULE_APN_CONNECTED); | |||||
| } | |||||
| else | |||||
| { | |||||
| LTEModuleAPNConnectionStatus(LTE_MODULE_APN_DISCONNECTED); | |||||
| } | |||||
| } | |||||
| } | |||||
| else if(strncmp(mInputString,"OK",2) == 0) //The command was executed | |||||
| { | |||||
| LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_OK); | |||||
| } | |||||
| else if(strncmp(mInputString,"ERROR",5) == 0) //The command was not executed | |||||
| { | |||||
| LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_ERROR); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case LTE_MODULE_CONNECT_TO_MASTER_CMD: | |||||
| { | |||||
| if(strncmp("+CAOPEN:",mInputString,strlen("+CAOPEN:")) == 0) | |||||
| { | |||||
| int result = atoi(&mInputString[11]); | |||||
| if(StrLen == 12 && mInputString[11] == '0') //The connection on port 0 is established | |||||
| { | |||||
| LTEModuleMasterConnectionStatus(LTE_MODULE_MASTER_CONNECTED); | |||||
| } | |||||
| else if(result == 1) //socket error, probably caused by APN not connected.. | |||||
| { | |||||
| LTEModuleMasterConnectionStatus(LTE_MODULE_MASTER_SOCKET_ERROR); | |||||
| } | |||||
| else | |||||
| { | |||||
| LTEModuleMasterConnectionStatus(LTE_MODULE_MASTER_DISCONNECTED); | |||||
| } | |||||
| } | |||||
| else if(strncmp(mInputString,"OK",2) == 0) //The command was executed | |||||
| { | |||||
| LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_OK); | |||||
| } | |||||
| else if(strncmp(mInputString,"ERROR",5) == 0) //The command was not executed | |||||
| { | |||||
| LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_ERROR); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case LTE_MODULE_DISCONNECT_FROM_MASTER_CMD: | |||||
| { | |||||
| if(strncmp(mInputString,"OK",2) == 0) //The command was executed | |||||
| { | |||||
| LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_OK); | |||||
| } | |||||
| else if(strncmp(mInputString,"ERROR",5) == 0) //The command was not executed | |||||
| { | |||||
| LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_ERROR); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case LTE_MODULE_CHECK_MASTER_CONNECTION_CMD: | |||||
| { | |||||
| if(strncmp("+CASTATE:",mInputString,strlen("+CASTATE:")) == 0) //+CASTATE: 0,0 | |||||
| { | |||||
| mCAStateReceived = true; | |||||
| if(mInputString[12] == '1') //The connection is established | |||||
| { | |||||
| LTEModuleMasterConnectionStatus(LTE_MODULE_MASTER_CONNECTED); | |||||
| } | |||||
| else | |||||
| { | |||||
| LTEModuleMasterConnectionStatus(LTE_MODULE_MASTER_DISCONNECTED); | |||||
| } | |||||
| } | |||||
| else if(strncmp(mInputString,"OK",2) == 0) //The command was executed | |||||
| { | |||||
| if(mCAStateReceived == false) | |||||
| { | |||||
| LTEModuleMasterConnectionStatus(LTE_MODULE_MASTER_DISCONNECTED); | |||||
| } | |||||
| mCAStateReceived = false; | |||||
| LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_OK); | |||||
| } | |||||
| else if(strncmp(mInputString,"ERROR",5) == 0) //The command was not executed | |||||
| { | |||||
| mCAStateReceived = false; | |||||
| LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_ERROR); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case LTE_MODULE_RX_DATA_CMD: | |||||
| { | |||||
| if(strncmp("+CARECV:",mInputString,strlen("+CARECV:")) == 0) //+CARECV: 4,test | |||||
| { | |||||
| memset(mMasterData,0,100); | |||||
| mMasterDataSize = 0; | |||||
| char *token; | |||||
| // sscanf("%d,%s",&mInputString[9],&DataSize,Data); | |||||
| token = strtok(&mInputString[9],","); | |||||
| if(token != NULL) | |||||
| { | |||||
| mMasterDataSize = atoi(token); | |||||
| if(mMasterDataSize < 100) | |||||
| { | |||||
| token = strtok(NULL, ","); | |||||
| if(token != NULL) | |||||
| { | |||||
| memcpy(mMasterData,token,mMasterDataSize); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| if(strncmp(mInputString,"OK",2) == 0) //The command was executed | |||||
| { | |||||
| LTEModuleDataReceived(mMasterData,mMasterDataSize); | |||||
| // LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_OK); | |||||
| } | |||||
| else if(strncmp(mInputString,"ERROR",5) == 0) //The command was not executed | |||||
| { | |||||
| LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_ERROR); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case LTE_MODULE_TX_DATA_CMD: | |||||
| { | |||||
| if(strncmp(mInputString,"OK",2) == 0) //The command was executed | |||||
| { | |||||
| LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_OK); | |||||
| } | |||||
| else if(strncmp(mInputString,"ERROR",5) == 0) //The command was not executed | |||||
| { | |||||
| LTECmdResponseReceived(CurCmd,LTE_MODULE_RESULT_ERROR); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case LTE_MODULE_NO_CMD: //+CADATAIND: | |||||
| default: | |||||
| { | |||||
| if(strncmp("+CADATAIND:",mInputString,strlen("+CADATAIND:")) == 0) | |||||
| { | |||||
| LTEModuleNewDataReady(); | |||||
| } | |||||
| if(strncmp("+APP PDP:",mInputString,strlen("+APP PDP:")) == 0) | |||||
| { | |||||
| // LTEModuleNewDataReady(); | |||||
| } | |||||
| if(strncmp("+CASTATE:",mInputString,strlen("+CASTATE:")) == 0) //+CASTATE: 0,0 | |||||
| { | |||||
| if(mInputString[12] == '1') //The connection is established | |||||
| { | |||||
| LTEModuleMasterConnectionStatus(LTE_MODULE_MASTER_CONNECTED); | |||||
| } | |||||
| else | |||||
| { | |||||
| LTEModuleMasterConnectionStatus(LTE_MODULE_MASTER_DISCONNECTED); | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,15 @@ | |||||
| /* | |||||
| * File: ATCmdInterpreter.h | |||||
| * Author: JF | |||||
| * | |||||
| * Created on December 28, 2024, 8:08 AM | |||||
| */ | |||||
| #ifndef ATCMDINTERPRETER_H | |||||
| #define ATCMDINTERPRETER_H | |||||
| void InitATCmdInterpreter(); | |||||
| int AnalyzeNewATString(char* Str, int StrLen, int CurCmd); | |||||
| #endif /* ATCMDINTERPRETER_H */ | |||||
| @@ -0,0 +1,196 @@ | |||||
| //#include <proc/p32mx440f256h.h> | |||||
| #include "BatteryMonitor.h" | |||||
| #include "BoardCfg.h" | |||||
| #include "timer.h" | |||||
| #include "ina219.h" | |||||
| #include "WiFiCtrl.h" | |||||
| #include "I2C.h" | |||||
| float mBatteryVoltage; | |||||
| int mBatteryCurrent; | |||||
| int mBatterySOC; | |||||
| float mVoltageMeanSum; | |||||
| int mVoltageMeanCount; | |||||
| unsigned int mCurrentMeanSum; | |||||
| int mCurrentMeanCount; | |||||
| bool mCurrentModuleOK; | |||||
| void InitBatteryMonitor() | |||||
| { | |||||
| mBatteryVoltage = 0; | |||||
| mBatteryCurrent = 0; | |||||
| mBatterySOC = 0; | |||||
| mVoltageMeanCount = 0; | |||||
| mCurrentMeanCount = 0; | |||||
| mCurrentModuleOK = true; | |||||
| TimerStart(BATTERY_MONITOR_TIMER,100); | |||||
| //experimental stuff! | |||||
| mVoltageMeanSum = 0.0; | |||||
| mVoltageMeanCount = 0; | |||||
| // if(ina219Init() == RET_ERROR) | |||||
| // { | |||||
| // mCurrentModuleOK = false; | |||||
| // } | |||||
| //ina219SetCalibration_16V_500mA(); | |||||
| // ina219SetCalibration_16V_200mA(); | |||||
| } | |||||
| void BatteryMonitorTick() | |||||
| { | |||||
| static int NetworkSendCounter; //Every second (10 counts) we want to send the battery data. | |||||
| if(IsTimerExpired(BATTERY_MONITOR_TIMER)) | |||||
| { | |||||
| unsigned int adc; | |||||
| double conv, raw; | |||||
| AD1CHSbits.CH0SA = 1; //AN1 | |||||
| AD1CON1bits.SAMP = 0; | |||||
| while(AD1CON1bits.DONE == 0); | |||||
| adc = ADC1BUF0; | |||||
| AD1CON1bits.SAMP = 1; | |||||
| // adc &= 0xFFFE; | |||||
| conv = (float)adc / 1023; | |||||
| conv *= 3.36; | |||||
| raw = conv; | |||||
| conv *= 11; | |||||
| //avoid rollovers in case the LORA network gets disconnected. | |||||
| //This could go for a long time but 5000 samples is too much anyways. | |||||
| if(mVoltageMeanCount >= 5000) | |||||
| { | |||||
| mVoltageMeanCount = 0; | |||||
| mVoltageMeanSum = conv; | |||||
| } | |||||
| else | |||||
| { | |||||
| mVoltageMeanCount++; | |||||
| mVoltageMeanSum += conv; | |||||
| } | |||||
| mBatteryVoltage = conv; | |||||
| TimerStart(BATTERY_MONITOR_TIMER,100); | |||||
| if(mCurrentModuleOK == true) | |||||
| { | |||||
| // mBatteryCurrent = ina219GetCurrent_mA(); | |||||
| // if(I2CWasLastTransactionOK() == 0 ) | |||||
| // { | |||||
| // mCurrentModuleOK = false; | |||||
| // } | |||||
| } | |||||
| else | |||||
| { | |||||
| unsigned int Ref = 0; | |||||
| AD1CHSbits.CH0SA = 0; //AN0 | |||||
| AD1CON1bits.SAMP = 0; | |||||
| while(AD1CON1bits.DONE == 0); | |||||
| Ref = ADC1BUF0; | |||||
| AD1CON1bits.SAMP = 1; | |||||
| AD1CHSbits.CH0SA = 2; //AN2 | |||||
| AD1CON1bits.SAMP = 0; | |||||
| while(AD1CON1bits.DONE == 0); | |||||
| adc = ADC1BUF0; | |||||
| AD1CON1bits.SAMP = 1; | |||||
| // adc &= 0xFFFE; | |||||
| adc -= Ref; | |||||
| conv = (double)adc * 1.0; | |||||
| conv /= 1023; | |||||
| conv *= 3.3; //Volts | |||||
| conv /= 0.05; //Amps (50mV/A) | |||||
| raw = conv; | |||||
| //avoid rollovers in case the LORA network gets disconnected. | |||||
| //This could go for a long time but 5000 samples is too much anyways. | |||||
| if(mCurrentMeanCount >= 500) | |||||
| { | |||||
| mCurrentMeanCount = 1; | |||||
| mCurrentMeanSum = adc; | |||||
| } | |||||
| else | |||||
| { | |||||
| mCurrentMeanCount++; | |||||
| mCurrentMeanSum += adc; | |||||
| } | |||||
| mBatteryCurrent = adc; | |||||
| //mBatteryCurrent = mCurrentMeanSum / mCurrentMeanCount; | |||||
| } | |||||
| } | |||||
| } | |||||
| float GetBatteryVoltage(int Reset) | |||||
| { | |||||
| if(Reset == 1) | |||||
| { | |||||
| mBatteryVoltage = (mVoltageMeanSum/mVoltageMeanCount); | |||||
| mVoltageMeanSum = 0.0; | |||||
| mVoltageMeanCount = 0; | |||||
| } | |||||
| return mBatteryVoltage; | |||||
| } | |||||
| int GetSolarPanelCurrent() | |||||
| { | |||||
| //mBatteryCurrent = (mCurrentMeanSum/mCurrentMeanCount); | |||||
| //mVoltageMeanCount = 0; | |||||
| mCurrentMeanSum = 0.0; | |||||
| return mBatteryCurrent; | |||||
| } | |||||
| float GetConvertedSolarPanelCurrent() | |||||
| { | |||||
| float Cur = (mBatteryCurrent - 2) * (3.3/1023); | |||||
| return Cur; | |||||
| } | |||||
| int GetBatterySOC() | |||||
| { | |||||
| return mBatterySOC; | |||||
| } | |||||
| int SendNetworkBatteryData() | |||||
| { | |||||
| // int VoltageMilliVolts = (int)(mBatteryVoltage * 1000); | |||||
| // int BattCurrent = mBatteryCurrent; | |||||
| // | |||||
| // char BatData[10]; | |||||
| // BatData[0] = (char)(VoltageMilliVolts & 0x000000FF); //Battery Voltage 1 | |||||
| // VoltageMilliVolts >>= 8; | |||||
| // BatData[1] = (char)(VoltageMilliVolts & 0x000000FF); //Battery Voltage 2 | |||||
| // BatData[2] = (char)(BattCurrent & 0x000000FF); //Solar panel Current 1 | |||||
| // BattCurrent >>= 8; | |||||
| // BatData[3] = (char)(BattCurrent & 0x000000FF); //Solar panel Current 2 | |||||
| // | |||||
| // SendNetworkData(BatData,4); | |||||
| printf("Battery voltage: %f\n",mBatteryVoltage); | |||||
| } | |||||
| bool GetCurrentModuleOK() | |||||
| { | |||||
| return mCurrentModuleOK; | |||||
| } | |||||
| @@ -0,0 +1,27 @@ | |||||
| /* | |||||
| * File: ChaletPowerRelay.h | |||||
| * Author: JF | |||||
| * | |||||
| * Created on November 30, 2018, 7:33 PM | |||||
| */ | |||||
| #ifndef BATTERYMONITOR_H | |||||
| #define BATTERYMONITOR_H | |||||
| #include "define.h" | |||||
| void InitBatteryMonitor(); | |||||
| void BatteryMonitorTick(); | |||||
| float GetBatteryVoltage(int Reset); | |||||
| int GetSolarPanelCurrent(); | |||||
| int GetBatterySOC(); | |||||
| int SendNetworkBatteryData(); | |||||
| bool GetCurrentModuleOK(); | |||||
| float GetConvertedSolarPanelCurrent(); | |||||
| #endif /* BATTERYMONITOR_H */ | |||||
| @@ -0,0 +1,49 @@ | |||||
| /* | |||||
| * File: BoardCfg.h | |||||
| * Author: JF | |||||
| * | |||||
| * Created on November 26, 2018, 4:50 PM | |||||
| */ | |||||
| #ifndef BOARDCFG_H | |||||
| #define BOARDCFG_H | |||||
| #include "define.h" | |||||
| static inline __attribute__((always_inline)) unsigned char SPICalculateBRG(unsigned int pb_clk, unsigned int spi_clk) | |||||
| { | |||||
| unsigned int brg; | |||||
| brg = pb_clk / (2 * spi_clk); | |||||
| if(pb_clk % (2 * spi_clk)) | |||||
| brg++; | |||||
| if(brg > 0x100) | |||||
| brg = 0x100; | |||||
| if(brg) | |||||
| brg--; | |||||
| return (unsigned char) brg; | |||||
| } | |||||
| // | |||||
| #ifdef FUBARINO_BRD | |||||
| #include "BoardCfg_Fubarino.h" | |||||
| #endif | |||||
| //#ifdef PINGUINO_BRD | |||||
| //#include "BoardCfg_Pinguino.h" | |||||
| //#endif | |||||
| #ifdef CHALETDUINO_BRD | |||||
| #include "BoardCfg_Chaletduino.h" | |||||
| #endif | |||||
| #ifdef CHALETDUINO_V2_BRD | |||||
| #include "BoardCfg_ChaletduinoV2.h" | |||||
| #endif | |||||
| int InitBoard(); | |||||
| #endif /* BOARDCFG_H */ | |||||
| @@ -0,0 +1,120 @@ | |||||
| /* | |||||
| * File: DigitalIO_Chaletduino.h | |||||
| * Author: JF | |||||
| * | |||||
| * Created on November 24, 2018, 3:20 PM | |||||
| */ | |||||
| #ifndef DIGITALIO_CHALETDUINO_H | |||||
| #define DIGITALIO_CHALETDUINO_H | |||||
| #ifdef __cplusplus | |||||
| extern "C" { | |||||
| #endif | |||||
| /* ************************************************************************** */ | |||||
| /* Includes */ | |||||
| #include "define.h" | |||||
| /* ************************************************************************** */ | |||||
| /* Defines */ | |||||
| //#include <plib.h> | |||||
| #define SYS_FREQ (80000000L) //Clock period = 12.5 ns | |||||
| #define PERIPHERAL_FREQ (80000000L) | |||||
| //Output pins hardware definitions | |||||
| // | |||||
| #define HEARTBEAT_LED_2_PIN_DIR TRISEbits.TRISE6 | |||||
| #define HEARTBEAT_LED_2_PIN LATEbits.LATE6 | |||||
| #define HEARTBEAT_LED_2_TOGGLE_REG LATEINV | |||||
| #define HEARTBEAT_LED_2_SET_REG LATESET | |||||
| #define HEARTBEAT_LED_2_CLEAR_REG LATECLR | |||||
| #define HEARTBEAT_LED_2_TOGGLE_MASK _LATG_LATE6_MASK | |||||
| #define HEARTBEAT_LED_1_PIN_DIR TRISEbits.TRISE5 | |||||
| #define HEARTBEAT_LED_1_PIN LATEbits.LATE5 | |||||
| #define HEARTBEAT_LED_1_TOGGLE_REG LATEINV | |||||
| #define HEARTBEAT_LED_1_SET_REG LATESET | |||||
| #define HEARTBEAT_LED_1_CLEAR_REG LATECLR | |||||
| #define HEARTBEAT_LED_1_TOGGLE_MASK _LATE_LATE5_MASK | |||||
| #define LORA_ACTIVITY_LED_PIN_DIR TRISFbits.TRISF1 | |||||
| #define LORA_ACTIVITY_LED_PIN LATFbits.LATF1 | |||||
| #define LORA_ACTIVITY_LED_TOGGLE_REG LATFINV | |||||
| #define LORA_ACTIVITY_LED_SET_REG LATFSET | |||||
| #define LORA_ACTIVITY_LED_CLEAR_REG LATFCLR | |||||
| #define LORA_ACTIVITY_LED_TOGGLE_MASK _LATE_LATF1_MASK | |||||
| // #define GP_DEBUG_1_PIN_DIR TRISEbits.TRISE5 | |||||
| // #define GP_DEBUG_1_PIN LATEbits.LATE5 | |||||
| // #define GP_DEBUG_2_PIN_DIR TRISEbits.TRISE6 | |||||
| // #define GP_DEBUG_2_PIN LATEbits.LATE6 | |||||
| // #define SD_CARD_DETECT_PIN_DIR TRISDbits.TRISD8 | |||||
| // #define SD_CARD_DETECT_PIN LATDbits.LATD8 | |||||
| //SPI port defs | |||||
| #define SPI_SDO_PIN_DIR TRISGbits.TRISG8 | |||||
| #define SPI_SDI_PIN_DIR TRISGbits.TRISG7 | |||||
| #define SPI_SCK_PIN_DIR TRISGbits.TRISG6 | |||||
| //SD Card | |||||
| #define SD_SPI_SS_PIN_DIR TRISBbits.TRISB13 | |||||
| #define SD_SPI_SS_PIN LATBbits.LATB13 | |||||
| //SPI Flash | |||||
| #define FLASH_SS_PIN_DIR TRISEbits.TRISE3 | |||||
| #define FLASH_SS_PIN LATEbits.LATE3 | |||||
| //Wifi (WINC3400 module) | |||||
| #define WIFI_SPI_SS_PIN_DIR TRISEbits.TRISE0 | |||||
| #define WIFI_SPI_SS_PIN LATEbits.LATE0 | |||||
| #define WIFI_IRQ_PIN_DIR TRISDbits.TRISD0 | |||||
| #define WIFI_IRQ_PIN PORTDbits.RD0 | |||||
| // #define WIFI_SPI_CFG_PIN_DIR TRISEbits.TRISE1 | |||||
| // #define WIFI_SPI_CFG_PIN LATEbits.LATE1 | |||||
| #define WIFI_CHP_EN_PIN_DIR TRISEbits.TRISE2 | |||||
| #define WIFI_CHP_EN_PIN LATEbits.LATE2 | |||||
| #define WIFI_CHP_RST_PIN_DIR TRISEbits.TRISE4 | |||||
| #define WIFI_CHP_RST_PIN LATEbits.LATE4 | |||||
| //Chalet power relay | |||||
| #define POWER_RELAY_ON_PIN_DIR TRISEbits.TRISE7 | |||||
| #define POWER_RELAY_ON_PIN LATEbits.LATE7 //X2-3 | |||||
| #define POWER_RELAY_OFF_PIN_DIR TRISGbits.TRISG9 | |||||
| #define POWER_RELAY_OFF_PIN LATGbits.LATG9 //X3-5 | |||||
| //Harakiri relay | |||||
| #define HARAKIRI_RELAY_ON_PIN_DIR TRISBbits.TRISB0 | |||||
| #define HARAKIRI_RELAY_ON_PIN LATBbits.LATB0 //X2-3 | |||||
| //12V presence detection input | |||||
| #define CHALET_12V_PRESENCE_PIN_DIR TRISBbits.TRISB15 | |||||
| #define CHALET_12V_PRESENCE_PIN PORTBbits.RB15 //X2-3 | |||||
| //Battery voltage measurement (analog input) | |||||
| #define BATTERY_VOLTAGE_ANALOG_PIN_DIR TRISBbits.TRISB1 | |||||
| //Current sensor. Those pins tristate is controlled by the I2C module | |||||
| #define CURRENT_MODULE_I2C_SCL_PIN_DIR TRISDbits.TRISD3 | |||||
| #define CURRENT_MODULE_I2C_SDA_PIN_DIR TRISDbits.TRISD2 | |||||
| /* ************************************************************************** */ | |||||
| /* Prototypes */ | |||||
| void InitDigitalIO(void); | |||||
| #ifdef __cplusplus | |||||
| } | |||||
| #endif | |||||
| #endif /* DIGITALIO_PINGUINO_H */ | |||||
| @@ -0,0 +1,159 @@ | |||||
| /* | |||||
| * File: DigitalIO_Chaletduino.h | |||||
| * Author: JF | |||||
| * | |||||
| * Created on November 24, 2018, 3:20 PM | |||||
| */ | |||||
| #ifndef DIGITALIO_CHALETDUINO_H | |||||
| #define DIGITALIO_CHALETDUINO_H | |||||
| #ifdef __cplusplus | |||||
| extern "C" { | |||||
| #endif | |||||
| /* ************************************************************************** */ | |||||
| /* Includes */ | |||||
| #include "define.h" | |||||
| /* ************************************************************************** */ | |||||
| /* Defines */ | |||||
| //#include <plib.h> | |||||
| #define SYS_FREQ (80000000L) //Clock period = 12.5 ns | |||||
| #define PERIPHERAL_FREQ (80000000L) | |||||
| //Output pins hardware definitions | |||||
| // | |||||
| #define HEARTBEAT_LED_2_PIN_DIR TRISEbits.TRISE6 | |||||
| #define HEARTBEAT_LED_2_PIN LATEbits.LATE6 | |||||
| #define HEARTBEAT_LED_2_TOGGLE_REG LATEINV | |||||
| #define HEARTBEAT_LED_2_SET_REG LATESET | |||||
| #define HEARTBEAT_LED_2_CLEAR_REG LATECLR | |||||
| #define HEARTBEAT_LED_2_TOGGLE_MASK _LATG_LATE6_MASK | |||||
| #define HEARTBEAT_LED_1_PIN_DIR TRISEbits.TRISE5 | |||||
| #define HEARTBEAT_LED_1_PIN LATEbits.LATE5 | |||||
| #define HEARTBEAT_LED_1_TOGGLE_REG LATEINV | |||||
| #define HEARTBEAT_LED_1_SET_REG LATESET | |||||
| #define HEARTBEAT_LED_1_CLEAR_REG LATECLR | |||||
| #define HEARTBEAT_LED_1_TOGGLE_MASK _LATE_LATE5_MASK | |||||
| // #define GP_DEBUG_1_PIN_DIR TRISEbits.TRISE5 | |||||
| // #define GP_DEBUG_1_PIN LATEbits.LATE5 | |||||
| // #define GP_DEBUG_2_PIN_DIR TRISEbits.TRISE6 | |||||
| // #define GP_DEBUG_2_PIN LATEbits.LATE6 | |||||
| // #define SD_CARD_DETECT_PIN_DIR TRISDbits.TRISD8 | |||||
| // #define SD_CARD_DETECT_PIN LATDbits.LATD8 | |||||
| //SPI port defs | |||||
| #define SPI_SDO_PIN_DIR TRISGbits.TRISG8 | |||||
| #define SPI_SDI_PIN_DIR TRISGbits.TRISG7 | |||||
| #define SPI_SCK_PIN_DIR TRISGbits.TRISG6 | |||||
| //SD Card | |||||
| #define SD_SPI_SS_PIN_DIR TRISBbits.TRISB13 | |||||
| #define SD_SPI_SS_PIN LATBbits.LATB13 | |||||
| //SPI Flash | |||||
| #define FLASH_SS_PIN_DIR TRISEbits.TRISE3 | |||||
| #define FLASH_SS_PIN LATEbits.LATE3 | |||||
| //Wifi (WINC3400 module) | |||||
| #define WIFI_SPI_SS_PIN_DIR TRISEbits.TRISE0 | |||||
| #define WIFI_SPI_SS_PIN LATEbits.LATE0 | |||||
| #define WIFI_IRQ_PIN_DIR TRISDbits.TRISD0 | |||||
| #define WIFI_IRQ_PIN PORTDbits.RD0 | |||||
| // #define WIFI_SPI_CFG_PIN_DIR TRISEbits.TRISE1 | |||||
| // #define WIFI_SPI_CFG_PIN LATEbits.LATE1 | |||||
| #define WIFI_CHP_EN_PIN_DIR TRISEbits.TRISE2 | |||||
| #define WIFI_CHP_EN_PIN LATEbits.LATE2 | |||||
| #define WIFI_CHP_RST_PIN_DIR TRISEbits.TRISE4 | |||||
| #define WIFI_CHP_RST_PIN LATEbits.LATE4 | |||||
| #define ONBOARD_LED1_PIN_DIR TRISGbits.TRISG9 | |||||
| #define ONBOARD_LED1_PIN LATGbits.LATG9 | |||||
| #define ONBOARD_LED2_PIN_DIR TRISDbits.TRISD3 | |||||
| #define ONBOARD_LED2_PIN LATDbits.LATD3 | |||||
| #define ONBOARD_LED3_PIN_DIR TRISFbits.TRISF0 | |||||
| #define ONBOARD_LED3_PIN LATFbits.LATF0 | |||||
| #define ONBOARD_LED7_PIN_DIR TRISBbits.TRISB14 | |||||
| #define ONBOARD_LED7_PIN LATBbits.LATB14 | |||||
| #define PUSH_BUTTON_LED1_PIN_DIR TRISBbits.TRISB8 | |||||
| #define PUSH_BUTTON_LED1_PIN LATBbits.LATB8 | |||||
| #define PUSH_BUTTON_LED2_PIN_DIR TRISBbits.TRISB9 | |||||
| #define PUSH_BUTTON_LED2_PIN LATBbits.LATB9 | |||||
| #define PUSH_BUTTON_LED3_PIN_DIR TRISBbits.TRISB10 | |||||
| #define PUSH_BUTTON_LED3_PIN LATBbits.LATB10 | |||||
| #define PUSH_BUTTON_LED4_PIN_DIR TRISBbits.TRISB11 | |||||
| #define PUSH_BUTTON_LED4_PIN LATBbits.LATB11 | |||||
| #define PUSH_BUTTON_LED5_PIN_DIR TRISBbits.TRISB12 | |||||
| #define PUSH_BUTTON_LED5_PIN LATBbits.LATB12 | |||||
| #define PUSH_BUTTON_LED6_PIN_DIR TRISBbits.TRISB13 | |||||
| #define PUSH_BUTTON_LED6_PIN LATBbits.LATB13 | |||||
| #define PUSH_BUTTON_LED7_PIN_DIR TRISBbits.TRISB1 | |||||
| #define PUSH_BUTTON_LED7_PIN LATBbits.LATB1 | |||||
| #define PUSH_BUTTON_INPUT1_PIN_DIR TRISDbits.TRISD4 | |||||
| #define PUSH_BUTTON_INPUT1_PIN PORTDbits.RD4 | |||||
| #define PUSH_BUTTON_INPUT2_PIN_DIR TRISDbits.TRISD5 | |||||
| #define PUSH_BUTTON_INPUT2_PIN PORTDbits.RD5 | |||||
| #define PUSH_BUTTON_INPUT3_PIN_DIR TRISDbits.TRISD6 | |||||
| #define PUSH_BUTTON_INPUT3_PIN PORTDbits.RD6 | |||||
| #define PUSH_BUTTON_INPUT4_PIN_DIR TRISDbits.TRISD7 | |||||
| #define PUSH_BUTTON_INPUT4_PIN PORTDbits.RD7 | |||||
| #define PUSH_BUTTON_INPUT5_PIN_DIR TRISCbits.TRISC13 | |||||
| #define PUSH_BUTTON_INPUT5_PIN PORTCbits.RC13 | |||||
| #define PUSH_BUTTON_INPUT6_PIN_DIR TRISCbits.TRISC14 | |||||
| #define PUSH_BUTTON_INPUT6_PIN PORTCbits.RC14 | |||||
| #define PUSH_BUTTON_INPUT7_PIN_DIR TRISBbits.TRISB15 | |||||
| #define PUSH_BUTTON_INPUT7_PIN PORTBbits.RB15 | |||||
| #define VU1_DAC_SYNC_PIN_DIR TRISGbits.TRISG2 | |||||
| #define VU1_DAC_SYNC_PIN LATGbits.LATG2 | |||||
| #define VU1_BACKLIGHT_PIN_DIR TRISDbits.TRISD2 | |||||
| #define VU1_BACKLIGHT_PIN LATDbits.LATD2 | |||||
| #define VU2_DAC_SYNC_PIN_DIR TRISGbits.TRISG3 | |||||
| #define VU2_DAC_SYNC_PIN LATGbits.LATG3 | |||||
| #define VU2_BACKLIGHT_PIN_DIR TRISDbits.TRISD1 | |||||
| #define VU2_BACKLIGHT_PIN LATDbits.LATD1 | |||||
| #define BUREAU_VOL_POT_CW_PIN_DIR TRISDbits.TRISD9 | |||||
| #define BUREAU_VOL_POT_CW_PIN PORTDbits.RD9 //INT2 | |||||
| #define BUREAU_VOL_POT_CCW_PIN_DIR TRISDbits.TRISD8 | |||||
| #define BUREAU_VOL_POT_CCW_PIN PORTDbits.RD8 //INT1 | |||||
| #define CUISINE_VOL_POT_CW_PIN_DIR TRISDbits.TRISD11 | |||||
| #define CUISINE_VOL_POT_CW_PIN PORTDbits.RD11 //INT4 | |||||
| #define CUISINE_VOL_POT_CCW_PIN_DIR TRISDbits.TRISD10 | |||||
| #define CUISINE_VOL_POT_CCW_PIN PORTDbits.RD10 //INT3 | |||||
| /* ************************************************************************** */ | |||||
| /* Prototypes */ | |||||
| void InitDigitalIO(void); | |||||
| #ifdef __cplusplus | |||||
| } | |||||
| #endif | |||||
| #endif /* DIGITALIO_PINGUINO_H */ | |||||
| @@ -0,0 +1,58 @@ | |||||
| /* | |||||
| * File: DigitalIO_Fubarino.h | |||||
| * Author: JF | |||||
| * | |||||
| * Created on November 24, 2018, 3:20 PM | |||||
| */ | |||||
| #ifndef DIGITALIO_FUBARINO_H | |||||
| #define DIGITALIO_FUBARINO_H | |||||
| #ifdef __cplusplus | |||||
| extern "C" { | |||||
| #endif | |||||
| /* ************************************************************************** */ | |||||
| /* Includes */ | |||||
| #include "define.h" | |||||
| /* ************************************************************************** */ | |||||
| /* Defines */ | |||||
| #define SYS_FREQ (80000000L) //Clock period = 12.5 ns | |||||
| #define PERIPHERAL_FREQ (80000000L) | |||||
| //Output pins hardware definitions | |||||
| // | |||||
| #define HEARTBEAT_LED_1_PIN_DIR TRISEbits.TRISE5 | |||||
| #define HEARTBEAT_LED_1_PIN LATEbits.LATE5 | |||||
| #define HEARTBEAT_LED_1_TOGGLE_REG LATEINV | |||||
| #define HEARTBEAT_LED_1_SET_REG LATESET | |||||
| #define HEARTBEAT_LED_1_CLEAR_REG LATECLR | |||||
| #define HEARTBEAT_LED_1_TOGGLE_MASK _LATE_LATE5_MASK | |||||
| #define HEARTBEAT_LED_2_PIN_DIR TRISEbits.TRISE2 | |||||
| #define HEARTBEAT_LED_2_PIN LATEbits.LATE2 | |||||
| #define HEARTBEAT_LED_2_TOGGLE_REG LATEINV | |||||
| #define HEARTBEAT_LED_2_SET_REG LATESET | |||||
| #define HEARTBEAT_LED_2_CLEAR_REG LATECLR | |||||
| #define HEARTBEAT_LED_2_TOGGLE_MASK _LATE_LATE2_MASK | |||||
| #define SD_SPI_SDO_PIN_DIR TRISGbits.TRISG8 | |||||
| #define SD_SPI_CS_PIN_DIR TRISGbits.TRISG9 | |||||
| #define SD_SPI_CS_PIN LATGbits.LATG9 | |||||
| #define SD_SPI_SDI_PIN_DIR TRISGbits.TRISG7 | |||||
| #define SD_SPI_SCK_PIN_DIR TRISGbits.TRISG6 | |||||
| /* ************************************************************************** */ | |||||
| /* Prototypes */ | |||||
| void InitDigitalIO(void); | |||||
| #ifdef __cplusplus | |||||
| } | |||||
| #endif | |||||
| #endif /* DIGITALIO_FUBARINO_H */ | |||||
| @@ -0,0 +1,104 @@ | |||||
| /* | |||||
| * File: DigitalIO_Pinguino.h | |||||
| * Author: JF | |||||
| * | |||||
| * Created on November 24, 2018, 3:20 PM | |||||
| */ | |||||
| #ifndef DIGITALIO_PINGUINO_H | |||||
| #define DIGITALIO_PINGUINO_H | |||||
| #ifdef __cplusplus | |||||
| extern "C" { | |||||
| #endif | |||||
| /* ************************************************************************** */ | |||||
| /* Includes */ | |||||
| #include "define.h" | |||||
| /* ************************************************************************** */ | |||||
| /* Defines */ | |||||
| #define SYS_FREQ (80000000L) //Clock period = 12.5 ns | |||||
| #define PERIPHERAL_FREQ (80000000L) | |||||
| //Output pins hardware definitions | |||||
| // | |||||
| // #define HEARTBEAT_LED_2_PIN_DIR TRISGbits.TRISG6 | |||||
| // #define HEARTBEAT_LED_2_PIN LATGbits.LATG6 | |||||
| // #define HEARTBEAT_LED_2_TOGGLE_REG LATGINV | |||||
| // #define HEARTBEAT_LED_2_SET_REG LATGSET | |||||
| // #define HEARTBEAT_LED_2_CLEAR_REG LATGCLR | |||||
| // #define HEARTBEAT_LED_2_TOGGLE_MASK _LATG_LATG6_MASK | |||||
| #define HEARTBEAT_LED_1_PIN_DIR TRISDbits.TRISD1 | |||||
| #define HEARTBEAT_LED_1_PIN LATDbits.LATD1 | |||||
| #define HEARTBEAT_LED_1_TOGGLE_REG LATDINV | |||||
| #define HEARTBEAT_LED_1_SET_REG LATDSET | |||||
| #define HEARTBEAT_LED_1_CLEAR_REG LATDCLR | |||||
| #define HEARTBEAT_LED_1_TOGGLE_MASK _LATD_LATD1_MASK | |||||
| // #define SD_CARD_DETECT_PIN_DIR TRISDbits.TRISD8 | |||||
| // #define SD_CARD_DETECT_PIN LATDbits.LATD8 | |||||
| //SPI port defs | |||||
| #define SPI_SDO_PIN_DIR TRISGbits.TRISG8 | |||||
| #define SPI_SDI_PIN_DIR TRISGbits.TRISG7 | |||||
| #define SPI_SCK_PIN_DIR TRISGbits.TRISG6 | |||||
| //SD Card | |||||
| #define SD_SPI_SS_PIN_DIR TRISBbits.TRISB13 | |||||
| #define SD_SPI_SS_PIN LATBbits.LATB13 | |||||
| //Wifi (WINC3400 module) | |||||
| #define WIFI_SPI_SS_PIN_DIR TRISFbits.TRISF1 | |||||
| #define WIFI_SPI_SS_PIN LATFbits.LATF1 | |||||
| #define WIFI_IRQ_PIN_DIR TRISDbits.TRISD0 | |||||
| #define WIFI_IRQ_PIN PORTDbits.RD0 | |||||
| #define WIFI_WAKE_PIN_DIR TRISEbits.TRISE0 | |||||
| #define WIFI_WAKE_PIN LATEbits.LATE0 | |||||
| #define WIFI_SPI_CFG_PIN_DIR TRISEbits.TRISE1 | |||||
| #define WIFI_SPI_CFG_PIN LATEbits.LATE1 | |||||
| #define WIFI_CHP_EN_PIN_DIR TRISEbits.TRISE2 | |||||
| #define WIFI_CHP_EN_PIN LATEbits.LATE2 | |||||
| #define WIFI_CHP_RST_PIN_DIR TRISEbits.TRISE3 | |||||
| #define WIFI_CHP_RST_PIN LATEbits.LATE3 | |||||
| //Control knob encoder | |||||
| #define KNOB_PH_A_PIN_DIR TRISDbits.TRISD8 | |||||
| #define KNOB_PH_A_PIN PORTDbits.RD8 | |||||
| #define KNOB_PH_B_PIN_DIR TRISDbits.TRISD7 | |||||
| #define KNOB_PH_B_PIN PORTDbits.RD7 | |||||
| #define KNOB_TGLE_BTN_PIN_DIR TRISDbits.TRISD11 | |||||
| #define KNOB_TGLE_BTN_PIN PORTDbits.RD11 | |||||
| //Led controller PWM | |||||
| #define LED_PWM_PIN_DIR TRISDbits.TRISD2 | |||||
| #define LED_PWM_PIN LATDbits.LATD2 | |||||
| #define LED_PWM_VAL_REG OC3RS | |||||
| //Misc CPU or board related defines | |||||
| #define PWM_RANGE_MAX 16000 | |||||
| #define GP_DEBUG_1_PIN_DIR TRISEbits.TRISE5 | |||||
| #define GP_DEBUG_1_PIN LATEbits.LATE5 | |||||
| #define GP_DEBUG_2_PIN_DIR TRISEbits.TRISE6 | |||||
| #define GP_DEBUG_2_PIN LATEbits.LATE6 | |||||
| /* ************************************************************************** */ | |||||
| /* Prototypes */ | |||||
| void InitDigitalIO(void); | |||||
| #ifdef __cplusplus | |||||
| } | |||||
| #endif | |||||
| #endif /* DIGITALIO_PINGUINO_H */ | |||||
| @@ -0,0 +1,985 @@ | |||||
| //#include <proc/p32mx440f256h.h> | |||||
| #include "BootloaderInterface.h" | |||||
| #include "BootloaderProtocol.h" | |||||
| #include "ProtocolDefs.h" | |||||
| #include "BoardCfg.h" | |||||
| #include "timer.h" | |||||
| #include "WiFiCtrl.h" | |||||
| #include "SPI_Flash.h" | |||||
| #include "FlashMapping.h" | |||||
| #include "NetworkProtocol.h" | |||||
| #include "Syslog.h" | |||||
| #include "checksum.h" | |||||
| #include "FlashMapping.h" | |||||
| #define BOOTLOADER_FLASH_ERASE_POLL_TIMEOUT 25//100 //ms | |||||
| #define BOOTLOADER_FLASH_ERASE_MAX_POLL_COUNT 40//10 //One sector should not take more than 1s to erase... | |||||
| #define BOOTLOADER_FLASH_WRITE_POLL_TIMEOUT 25//100 //ms | |||||
| #define BOOTLOADER_FLASH_WRITE_MAX_POLL_COUNT 40//10 //One sector should not take more than 1s to erase... | |||||
| unsigned char BootloaderBuffer[300]; | |||||
| int BootloaderInterfaceState; | |||||
| int DataChunkWritten; | |||||
| int CurDataChunkIndex; | |||||
| int FirmwareUploaded; | |||||
| int CurDataChunkSize; | |||||
| int BooloaderFlashEraseState; | |||||
| int BootloaderFlashErased; | |||||
| unsigned int BootloaderCurFlashEraseAddress; | |||||
| int BooloaderFlashErasePollCount; | |||||
| int BootloaderFlashWriteState; | |||||
| unsigned int BootloaderCurFlashWriteAddress; | |||||
| int BootloaderFlashWritePollCount; | |||||
| int BootloaderFirmwareChunkWriteCount; | |||||
| char* BootloaderFlashWriteDataPtr; | |||||
| int BootloaderInterfaceInit() | |||||
| { | |||||
| BootloaderProtocolInit(); | |||||
| BootloaderResetStateMachine(); | |||||
| BootloaderCheckFlashBootloaderData(); | |||||
| update_crc_32(0,0); //Force to populate the CRC32 table... | |||||
| return 1; | |||||
| } | |||||
| void BootloaderInterfaceTick() | |||||
| { | |||||
| BootloaderInterfaceStateMachine(BOOTLOADER_TICK_EVENT,0); | |||||
| } | |||||
| void BootloaderExecuteCmd(char Cmd,bool CRCValid) | |||||
| { | |||||
| unsigned char *DataBufPtr = BootloaderProtocolGetDataBufferPtr(); | |||||
| if(CRCValid == 0) | |||||
| { | |||||
| printf("Bootloader received a frame with invalid CRC\n"); | |||||
| BootloaderInterfaceStateMachine(BOOTLOADER_NEW_CMD_EVENT,BOOTLOADER_SM_INVALID_CRC_CMD); | |||||
| return; | |||||
| } | |||||
| switch(Cmd) | |||||
| { | |||||
| case BOOTLOADER_HEARTBEAT_REQUEST: | |||||
| { | |||||
| printf("Bootloader Heartbeat Request\n"); | |||||
| *DataBufPtr = 1; | |||||
| BootloaderProtocolSendFrame(BOOTLOADER_HEARTBEAT_RESPONSE,1); | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_ERASE_BOOTLOADER_FLASH_REQUEST: | |||||
| { | |||||
| printf("BOOTLOADER_ERASE_BOOTLOADER_FLASH_REQUEST\n"); | |||||
| BootloaderInterfaceStateMachine(BOOTLOADER_NEW_CMD_EVENT,BOOTLOADER_SM_ERASE_FLASH_CMD); | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_INIT_UPLOAD_REQUEST: | |||||
| { | |||||
| printf("BOOTLOADER_INIT_UPLOAD_REQUEST\n"); | |||||
| BootloaderInterfaceStateMachine(BOOTLOADER_NEW_CMD_EVENT,BOOTLOADER_SM_INIT_UPLOAD_CMD); | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_GET_STATE_REQUEST: | |||||
| { | |||||
| printf("BOOTLOADER_GET_STATE_REQUEST\n"); | |||||
| BootloaderProtocolSendBootloaderState((char)BootloaderInterfaceState); | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_SEND_DATA_CHUNK_REQUEST: | |||||
| { | |||||
| // printf("BOOTLOADER_SEND_DATA_CHUNK_REQUEST\n"); | |||||
| BootloaderInterfaceStateMachine(BOOTLOADER_NEW_CMD_EVENT,BOOTLOADER_SM_NEW_DATA_CHUNK_CMD); | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_UPLOAD_FINISHED_REQUEST: | |||||
| { | |||||
| printf("BOOTLOADER_UPLOAD_FINISHED_REQUEST\n"); | |||||
| BootloaderInterfaceStateMachine(BOOTLOADER_NEW_CMD_EVENT,BOOTLOADER_SM_UPLOAD_FINISHED_CMD); | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_EXECUTE_UPGRAGE_REQUEST: | |||||
| { | |||||
| printf("BOOTLOADER_EXECUTE_UPGRAGE_REQUEST\n"); | |||||
| BootloaderInterfaceStateMachine(BOOTLOADER_NEW_CMD_EVENT,BOOTLOADER_SM_EXECUTE_UPGRAGE_CMD); | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_ABORT_OPERATION_REQUEST: | |||||
| { | |||||
| printf("BOOTLOADER_ABORT_OPERATION_REQUEST\n"); | |||||
| BootloaderInterfaceStateMachine(BOOTLOADER_NEW_CMD_EVENT,BOOTLOADER_SM_ABORT_CMD); | |||||
| } | |||||
| case BOOTLOADER_CHECK_FLASH_FIRMW_INTEGRITY_REQUEST: | |||||
| { | |||||
| printf("BOOTLOADER_CHECK_FLASH_FIRMW_INTEGRITY_REQUEST\n"); | |||||
| BootloaderInterfaceStateMachine(BOOTLOADER_NEW_CMD_EVENT,BOOTLOADER_SM_CHECK_FLASH_CMD); | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_GET_STORED_FIRMWARE_INFO_REQUEST: | |||||
| { | |||||
| printf("BOOTLOADER_CHECK_FLASH_FIRMW_INTEGRITY_REQUEST\n"); | |||||
| BootloaderInterfaceStateMachine(BOOTLOADER_NEW_CMD_EVENT,BOOTLOADER_SM_GET_FIRMWARE_DATA_CMD); | |||||
| break; | |||||
| } | |||||
| default: | |||||
| { | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| void BootloaderCRCError(char Cmd, int RxCRC, int ExpectedCRC) | |||||
| { | |||||
| printf("BootloaderProtocol detected a CRC error. Cmd: %d, RxCRC:0x%x, Expected:[0x%x]\n",Cmd,RxCRC,ExpectedCRC); | |||||
| BootloaderInterfaceStateMachine(BOOTLOADER_NEW_CMD_EVENT,BOOTLOADER_SM_INVALID_CRC_CMD); | |||||
| } | |||||
| void BootloaderInterfaceStateMachine(int Event, int Param) | |||||
| { | |||||
| switch(BootloaderInterfaceState) | |||||
| { | |||||
| case BOOTLOADER_STANDBY_STATE: | |||||
| { | |||||
| switch(Event) | |||||
| { | |||||
| case BOOTLOADER_TICK_EVENT: | |||||
| { | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_NEW_CMD_EVENT: | |||||
| { | |||||
| if(Param == BOOTLOADER_SM_ACTIVATE_CMD) | |||||
| { | |||||
| BootloaderInterfaceState = BOOTLOADER_ACTIVE_STATE; | |||||
| printf("Bootloader Interface going into active state\n"); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_TIMEOUT_EVENT: | |||||
| { | |||||
| break; | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_ACTIVE_STATE: | |||||
| { | |||||
| switch(Event) | |||||
| { | |||||
| case BOOTLOADER_TICK_EVENT: | |||||
| { | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_NEW_CMD_EVENT: | |||||
| { | |||||
| switch(Param) | |||||
| { | |||||
| case BOOTLOADER_SM_ERASE_FLASH_CMD: | |||||
| { | |||||
| ResetBootloaderFlashEraseStateMachine(); //Setup the state machine | |||||
| BootloaderProtocolSendACK(BOOTLOADER_ERASE_BOOTLOADER_FLASH_RESPONSE); | |||||
| BootloaderInterfaceState = BOOTLOADER_ERASE_FLASH_STATE; | |||||
| printf("Bootloader Interface going into Erase Flash state\n"); | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_SM_INIT_UPLOAD_CMD: | |||||
| { | |||||
| if(BootloaderFlashErased == 0) | |||||
| { | |||||
| BootloaderProtocolSendInitUploadResponse(BOOTLOADEDR_INIT_TRANSFER_ERROR_FLASH_NOT_ERASED); | |||||
| } | |||||
| else | |||||
| { | |||||
| BootloaderProtocolSendInitUploadResponse(BOOTLOADEDR_INIT_TRANSFER_OK); | |||||
| //TODO: Shall we prepare something before?? | |||||
| BootloaderProtocolSendACK(BOOTLOADER_READY_FOR_DATA_RESPONSE); | |||||
| BootloaderInterfaceState = BOOTLOADER_RECEIVING_FIRMWARE_STATE; | |||||
| printf("Bootloader Interface going into Firmware RX state\n"); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_SM_ABORT_CMD: | |||||
| { | |||||
| //TODO invalidate data in Flash | |||||
| printf("Aborting upload, going into STANDBY mode\n"); | |||||
| BootloaderResetStateMachine(); | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_SM_EXECUTE_UPGRAGE_CMD: | |||||
| { | |||||
| if(BootloaderCheckFlashBootloaderData() == RET_OK) | |||||
| { | |||||
| BootloaderProtocolSendACK(BOOTLOADER_EXECUTE_UPGRADE_RESPONSE); | |||||
| printf("Bootloader will now upgrade and reboot!!\n"); | |||||
| char Flags[2]; | |||||
| Flags[BOOTLOADER_FLAGS_ACTION_FLAG_INDEX] = BOOTLOADER_ACTION_FLASH_FIRMWARE_VALUE; | |||||
| Flags[BOOTLOADER_FLAGS_ACTION_VALIDATOR_INDEX] = BOOTLOADER_FLASH_FIRMWARE_VALIDATOR; | |||||
| SPIFlashWriteBuffer(Flags,2,FLASH_BTLDR_FLAGS_ADDRESS); | |||||
| Sleep(100); | |||||
| TurnOFFWiFi(); | |||||
| Sleep(100); | |||||
| SoftReset(); | |||||
| } | |||||
| else | |||||
| { | |||||
| BootloaderProtocolSendNACK(BOOTLOADER_EXECUTE_UPGRADE_RESPONSE); | |||||
| printf("Bootloader upgrade request denied: Firmware not uploaded\n"); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_SM_CHECK_FLASH_CMD: | |||||
| { | |||||
| if(BootloaderCheckFlashBootloaderData() == RET_OK) | |||||
| { | |||||
| BootloaderProtocolSendFlashCheckResult(FLASH_CHECK_SUCCESS); | |||||
| } | |||||
| else | |||||
| { | |||||
| BootloaderProtocolSendFlashCheckResult(FLASH_CHECK_FAILED); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_SM_GET_FIRMWARE_DATA_CMD: | |||||
| { | |||||
| char Response[21]; | |||||
| memset(Response,0xFF,sizeof(Response)); | |||||
| if(BootloaderCheckFlashBootloaderData() != RET_OK) | |||||
| { | |||||
| Response[0] = 0; | |||||
| } | |||||
| else | |||||
| { | |||||
| Response[0] = 1; | |||||
| BootloaderIntToBytes(&Response[1],mStoredBootloaderInfo.Firmwareflags); | |||||
| BootloaderIntToBytes(&Response[5],mStoredBootloaderInfo.NbRecords); | |||||
| BootloaderIntToBytes(&Response[9],mStoredBootloaderInfo.FirmwareSize); | |||||
| BootloaderIntToBytes(&Response[13],mStoredBootloaderInfo.Versioncode); | |||||
| BootloaderIntToBytes(&Response[17],mStoredBootloaderInfo.DataCRC32); | |||||
| } | |||||
| BootloaderProtocolSendStoredFirmwareInfoResponse(Response,sizeof(Response)); | |||||
| break; | |||||
| } | |||||
| default: | |||||
| { | |||||
| //SEND NACK | |||||
| BootloaderProtocolSendNACK(Param); | |||||
| break; | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_TIMEOUT_EVENT: | |||||
| { | |||||
| break; | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_ERASE_FLASH_STATE: | |||||
| { | |||||
| switch(Event) | |||||
| { | |||||
| case BOOTLOADER_TICK_EVENT: | |||||
| { | |||||
| int res = BootloaderFlashEraseStateMachine(BOOTLOADER_FLASH_ERASE_SM_TICK_EVENT); | |||||
| switch(res) | |||||
| { | |||||
| case BOOTLOADER_FLASH_ERASE_RUNNING_RES: | |||||
| { | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_FLASH_ERASE_FINISHED_RES: | |||||
| { | |||||
| printf("Flash erase finished. Bootloader Interface going into Active state\n"); | |||||
| BootloaderProtocolSendACK(BOOTLOADER_ERASE_BOOTLOADER_FLASH_RESULT_RESPONSE); //TODO: send result instead | |||||
| BootloaderInterfaceState = BOOTLOADER_ACTIVE_STATE; | |||||
| BootloaderFlashErased = 1; | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_FLASH_ERASE_ERROR_RES: | |||||
| { | |||||
| printf("Flash erase error. Bootloader Interface going into Active state\n"); | |||||
| BootloaderProtocolSendNACK(BOOTLOADER_ERASE_BOOTLOADER_FLASH_RESULT_RESPONSE); //TODO: send result instead | |||||
| BootloaderInterfaceState = BOOTLOADER_ACTIVE_STATE; | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_FLASH_ERASE_ABORT_RES: | |||||
| { | |||||
| printf("Flash erase abort. Bootloader Interface going into Active state\n"); | |||||
| BootloaderProtocolSendNACK(BOOTLOADER_ERASE_BOOTLOADER_FLASH_RESULT_RESPONSE); //TODO: send result instead | |||||
| BootloaderInterfaceState = BOOTLOADER_ACTIVE_STATE; | |||||
| break; | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_NEW_CMD_EVENT: | |||||
| { | |||||
| switch(Param) | |||||
| { | |||||
| case BOOTLOADER_SM_ABORT_CMD: | |||||
| { | |||||
| //TODO: stop erasing and reset SM. | |||||
| //TODO invalidate data in Flash | |||||
| BootloaderFlashEraseStateMachine(BOOTLOADER_FLASH_ERASE_SM_ABORT_EVENT); | |||||
| printf("Aborting Flash erase, going into STANDBY mode\n"); | |||||
| BootloaderResetStateMachine(); | |||||
| break; | |||||
| } | |||||
| default: | |||||
| { | |||||
| //SEND NACK | |||||
| BootloaderProtocolSendNACK(Param); | |||||
| break; | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_TIMEOUT_EVENT: | |||||
| { | |||||
| break; | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_RECEIVING_FIRMWARE_STATE: | |||||
| { | |||||
| switch(Event) | |||||
| { | |||||
| case BOOTLOADER_TICK_EVENT: | |||||
| { | |||||
| int res = BootloaderFlashWriteStateMachine(BOOTLOADER_FLASH_WRITE_SM_TICK_EVENT); | |||||
| switch(res) | |||||
| { | |||||
| case BOOTLOADER_FLASH_WRITING_RES: | |||||
| { | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_FLASH_WRITE_FINISHED_RES: | |||||
| { | |||||
| BootloaderProtocolSendDataChunkResult(BOOTLOADER_CHUNK_TRANSFER_SUCCESS,CurDataChunkIndex); | |||||
| printf("Bootloader Chunk %d successfuly written to flash\n",CurDataChunkIndex); | |||||
| CurDataChunkIndex++; | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_FLASH_WRITE_ERROR_RES: | |||||
| { | |||||
| BootloaderProtocolSendDataChunkResult(BOOTLOADER_CHUNK_TRANSFER_ERROR_FLASH_ERROR,CurDataChunkIndex); | |||||
| BootloaderResetStateMachine(); | |||||
| printf("Bootloader Flash write error. Aborting and going into STANDBY state\n"); | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_FLASH_WRITE_ABORT_RES: | |||||
| { | |||||
| break; | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_NEW_CMD_EVENT: | |||||
| { | |||||
| switch(Param) | |||||
| { | |||||
| case BOOTLOADER_SM_NEW_DATA_CHUNK_CMD: | |||||
| { | |||||
| //TODO:Check data validity | |||||
| //TODO: Write data to flash | |||||
| //Extract index from buffer | |||||
| unsigned int DataChunkIndex = 0; | |||||
| unsigned int DataChunkSize = 0; | |||||
| DataChunkSize = 0; | |||||
| // DataChunkIndex = BootloaderBuffer[0]; | |||||
| // DataChunkIndex <<= 8; | |||||
| // DataChunkIndex += BootloaderBuffer[1]; | |||||
| // DataChunkIndex <<= 8; | |||||
| // DataChunkIndex += BootloaderBuffer[2]; | |||||
| // DataChunkIndex <<= 8; | |||||
| // DataChunkIndex += BootloaderBuffer[3]; | |||||
| DataChunkIndex = BootloaderBytesToInt(&BootloaderBuffer[0]); | |||||
| // DataChunkSize = BootloaderBuffer[4]; | |||||
| // DataChunkSize <<= 8; | |||||
| // DataChunkSize += BootloaderBuffer[5]; | |||||
| // DataChunkSize <<= 8; | |||||
| // DataChunkSize += BootloaderBuffer[6]; | |||||
| // DataChunkSize <<= 8; | |||||
| // DataChunkSize += BootloaderBuffer[7]; | |||||
| DataChunkSize = BootloaderBytesToInt(&BootloaderBuffer[4]); | |||||
| BootloaderFlashWriteDataPtr = &BootloaderBuffer[8]; | |||||
| //Check CRC | |||||
| if(CurDataChunkIndex != DataChunkIndex) | |||||
| { | |||||
| //Error... abort. | |||||
| BootloaderProtocolSendDataChunkResult(BOOTLOADER_CHUNK_TRANSFER_ERROR_INVALID_CHUNK_INDEX,CurDataChunkIndex); | |||||
| printf("Bootloader Interface ABORTING UPLOAD. Received invalid chunk index. Rx: [%d] - Expected: [%d]\n", DataChunkIndex,CurDataChunkIndex); | |||||
| ResetBootloaderFlashWriteStateMachine(); | |||||
| } | |||||
| else | |||||
| { | |||||
| CurDataChunkSize = DataChunkSize; | |||||
| BootloaderFlashWriteStateMachine(BOOTLOADER_FLASH_WRITE_SM_NEW_BUFFER_EVENT); | |||||
| printf("Bootloader Interface. Rx new data chunk. Writing to flash. Index: %d\n", DataChunkIndex); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_SM_INVALID_CRC_CMD: | |||||
| { | |||||
| //BootloaderProtocol determined the CRC of the chunk was invalid. | |||||
| BootloaderProtocolSendDataChunkResult(BOOTLOADER_CHUNK_TRANSFER_ERROR_RESEND,CurDataChunkIndex); | |||||
| printf("Bootloader Interface invalid chunk CRC. Requesting resend chunk index [%d]\n", CurDataChunkIndex); | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_SM_UPLOAD_FINISHED_CMD: | |||||
| { | |||||
| printf("Bootloader Interface firmware upload finished. Check flash integrity.\n"); | |||||
| if(BootloaderCheckFlashBootloaderData() == RET_OK) | |||||
| { | |||||
| BootloaderInterfaceState = BOOTLOADER_ACTIVE_STATE; | |||||
| //BootloaderProtocolSendACK(BOOTLOADER_UPLOAD_FINISHED_RESPONSE); | |||||
| BootloaderProtocolSendFirmwareUploadResult(BOOTLOADER_UPLOAD_SUCCESS); | |||||
| FirmwareUploaded = 1; | |||||
| } | |||||
| else | |||||
| { | |||||
| printf("Firmware integrity check failed. Going back to STANDBY state.\n"); | |||||
| // BootloaderProtocolSendNACK(BOOTLOADER_UPLOAD_FINISHED_RESPONSE); | |||||
| BootloaderProtocolSendFirmwareUploadResult(BOOTLOADER_UPLOAD_FAILED_FLASH_VERIFICATION_ERROR); | |||||
| BootloaderResetStateMachine(); | |||||
| FirmwareUploaded = 0; | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_SM_ABORT_CMD: | |||||
| { | |||||
| //TODO invalidate data in Flash | |||||
| printf("Bootloader aborting firmware download. Going back to STANDBY state\n"); | |||||
| BootloaderFlashWriteStateMachine(BOOTLOADER_FLASH_WRITE_SM_ABORT_EVENT); | |||||
| BootloaderResetStateMachine(); | |||||
| break; | |||||
| } | |||||
| default: | |||||
| { | |||||
| //WHAT TO DO??? | |||||
| break; | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_TIMEOUT_EVENT: | |||||
| { | |||||
| break; | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_SENDING_FIRMWARE_COPY_STATE: | |||||
| { | |||||
| switch(Event) | |||||
| { | |||||
| case BOOTLOADER_TICK_EVENT: | |||||
| { | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_NEW_CMD_EVENT: | |||||
| { | |||||
| switch(Param) | |||||
| { | |||||
| case BOOTLOADER_SM_ABORT_CMD: | |||||
| { | |||||
| //TODO invalidate data in Flash | |||||
| printf("Aborting upload, going into STANDBY mode\n"); | |||||
| BootloaderResetStateMachine(); | |||||
| break; | |||||
| } | |||||
| default: | |||||
| { | |||||
| //SEND NACK | |||||
| BootloaderProtocolSendNACK(Param); | |||||
| break; | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_TIMEOUT_EVENT: | |||||
| { | |||||
| break; | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_PRINTING_FIRMWARE_STATE: | |||||
| { | |||||
| switch(Event) | |||||
| { | |||||
| case BOOTLOADER_TICK_EVENT: | |||||
| { | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_NEW_CMD_EVENT: | |||||
| { | |||||
| switch(Param) | |||||
| { | |||||
| case BOOTLOADER_SM_ABORT_CMD: | |||||
| { | |||||
| //TODO invalidate data in Flash | |||||
| printf("Aborting upload, going into STANDBY mode\n"); | |||||
| BootloaderResetStateMachine(); | |||||
| break; | |||||
| } | |||||
| default: | |||||
| { | |||||
| //SEND NACK | |||||
| BootloaderProtocolSendNACK(Param); | |||||
| break; | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_TIMEOUT_EVENT: | |||||
| { | |||||
| break; | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| void BootloaderResetStateMachine() | |||||
| { | |||||
| BootloaderInterfaceState = BOOTLOADER_STANDBY_STATE; | |||||
| DataChunkWritten = 0; | |||||
| CurDataChunkIndex = 0; | |||||
| FirmwareUploaded = 0; | |||||
| CurDataChunkIndex = 0; | |||||
| FirmwareUploaded = 0; | |||||
| CurDataChunkSize = 0; | |||||
| ResetBootloaderFlashEraseStateMachine(); | |||||
| ResetBootloaderFlashWriteStateMachine(); | |||||
| CloseBootloaderServer(); | |||||
| } | |||||
| void BootloaderActivateBootloader() | |||||
| { | |||||
| OpenBootloaderServer(); | |||||
| BootloaderInterfaceStateMachine(BOOTLOADER_NEW_CMD_EVENT,BOOTLOADER_SM_ACTIVATE_CMD); | |||||
| } | |||||
| void BootloaderDeactivateBootloader() | |||||
| { | |||||
| BootloaderResetStateMachine(); | |||||
| // CloseBootloaderServer(); | |||||
| // BootloaderIterfaceStateMachine(BOOTLOADER_SM_ABORT_CMD,0); | |||||
| } | |||||
| int BootloaderFlashEraseStateMachine(int event) | |||||
| { | |||||
| if(event == BOOTLOADER_FLASH_ERASE_SM_ABORT_EVENT) | |||||
| { | |||||
| ResetBootloaderFlashEraseStateMachine(); | |||||
| return BOOTLOADER_FLASH_ERASE_ABORT_RES; | |||||
| } | |||||
| switch(BooloaderFlashEraseState) | |||||
| { | |||||
| case BOOTLOADER_FLASH_ERASE_SECTOR_STATE: | |||||
| { | |||||
| if(SPIFlashErase64KSector(BootloaderCurFlashEraseAddress,0) == RET_ERROR) | |||||
| { | |||||
| printf("Bootloader Interface Erasing sector %0x%x\n", BootloaderCurFlashEraseAddress); | |||||
| BooloaderFlashEraseState = BOOTLOADER_FLASH_ERASE_ERROR_STATE; | |||||
| return BOOTLOADER_FLASH_ERASE_ERROR_RES; | |||||
| } | |||||
| BooloaderFlashErasePollCount = 0; | |||||
| TimerStart(BOOTLOADER_FLASH_POLL_TIMER,BOOTLOADER_FLASH_ERASE_POLL_TIMEOUT); | |||||
| BooloaderFlashEraseState = BOOTLOADER_FLASH_ERASE_WAIT_FOR_SECTOR_DONE; | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_FLASH_ERASE_WAIT_FOR_SECTOR_DONE: | |||||
| { | |||||
| if(IsTimerExpired(BOOTLOADER_FLASH_POLL_TIMER) == 1) | |||||
| { | |||||
| if(SPIFlashCheckBusy() == 0) //sector erased | |||||
| { | |||||
| if(BootloaderCurFlashEraseAddress == FLASH_BTLDR_FIRMWARE_LAST_64K_SECTOR_ADD) | |||||
| { | |||||
| //Whole bootloader partition is erased. | |||||
| printf("Bootloader Interface: Last sector 0x%x erased after %d polls\n",BootloaderCurFlashEraseAddress,BooloaderFlashErasePollCount); | |||||
| BooloaderFlashEraseState = BOOTLOADER_FLASH_ERASE_FINISHED_STATE; | |||||
| return BOOTLOADER_FLASH_ERASE_FINISHED_RES; | |||||
| break; | |||||
| } | |||||
| else | |||||
| { | |||||
| printf("Bootloader Interface sector 0x%x erased after %d polls\n",BootloaderCurFlashEraseAddress,BooloaderFlashErasePollCount); | |||||
| BootloaderCurFlashEraseAddress += SPI_FLASH_64K_SECTOR_SIZE; | |||||
| BooloaderFlashEraseState = BOOTLOADER_FLASH_ERASE_SECTOR_STATE; | |||||
| } | |||||
| } | |||||
| else | |||||
| { | |||||
| if(BooloaderFlashErasePollCount >= BOOTLOADER_FLASH_ERASE_MAX_POLL_COUNT) | |||||
| { | |||||
| printf("Bootloader Interface Flash erase error. Max poll count reached : %d!!!\n",BooloaderFlashErasePollCount); | |||||
| BooloaderFlashEraseState = BOOTLOADER_FLASH_ERASE_ERROR_STATE; | |||||
| return BOOTLOADER_FLASH_ERASE_ERROR_RES; | |||||
| } | |||||
| else | |||||
| { | |||||
| TimerStart(BOOTLOADER_FLASH_POLL_TIMER,BOOTLOADER_FLASH_ERASE_POLL_TIMEOUT); | |||||
| BooloaderFlashErasePollCount++; | |||||
| } | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_FLASH_ERASE_CHECKBACK_STATE: | |||||
| { | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_FLASH_ERASE_FINISHED_STATE: | |||||
| { | |||||
| return BOOTLOADER_FLASH_ERASE_FINISHED_RES; | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_FLASH_ERASE_ERROR_STATE: | |||||
| { | |||||
| return BOOTLOADER_FLASH_ERASE_ERROR_RES; | |||||
| break; | |||||
| } | |||||
| } | |||||
| return BOOTLOADER_FLASH_ERASE_RUNNING_RES; | |||||
| } | |||||
| int ResetBootloaderFlashEraseStateMachine() | |||||
| { | |||||
| BooloaderFlashEraseState = BOOTLOADER_FLASH_ERASE_SECTOR_STATE; | |||||
| BootloaderCurFlashEraseAddress = FLASH_BTLDR_FIRMWARE_START_ADDRESS; | |||||
| BooloaderFlashErasePollCount = 0; | |||||
| BootloaderFlashErased = 0; | |||||
| } | |||||
| int BootloaderFlashWriteStateMachine(int event) | |||||
| { | |||||
| switch(BootloaderFlashWriteState) | |||||
| { | |||||
| case BOOTLOADER_FLASH_WRITE_STANDBY_STATE: | |||||
| { | |||||
| if(event == BOOTLOADER_FLASH_WRITE_SM_TICK_EVENT) | |||||
| { | |||||
| //TODO: timeout | |||||
| // return BOOTLOADER_FLASH_WRITE_ERROR_RES; | |||||
| } | |||||
| else if(event == BOOTLOADER_FLASH_WRITE_SM_NEW_BUFFER_EVENT) | |||||
| { | |||||
| // printf("Starting writing data to Flash\nFlash Address : Data\n"); | |||||
| BootloaderFlashWriteState = BOOTLOADER_FLASH_WRITE_BUFFER_STATE; | |||||
| BootloaderFirmwareChunkWriteCount = 0; | |||||
| return BOOTLOADER_FLASH_WRITING_RES; | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_FLASH_WRITE_BUFFER_STATE: | |||||
| { | |||||
| if(BootloaderFlashWriteDataPtr == 0) | |||||
| { | |||||
| ResetBootloaderFlashWriteStateMachine(); | |||||
| return BOOTLOADER_FLASH_WRITE_ERROR_RES; | |||||
| } | |||||
| while(BootloaderFirmwareChunkWriteCount < CurDataChunkSize) | |||||
| { | |||||
| //printf("%d : 0x%x\n",(BootloaderCurFlashWriteAddress-FLASH_BTLDR_FIRMWARE_START_ADDRESS),(unsigned int)*BootloaderFlashWriteDataPtr); | |||||
| if(SPIFlashWriteByte(BootloaderCurFlashWriteAddress++,*BootloaderFlashWriteDataPtr++,1) == RET_ERROR) | |||||
| { | |||||
| printf("Bootloader flash error. Aborting and going back to STANDBY\n"); | |||||
| BootloaderFlashWriteState = BOOTLOADER_FLASH_WRITE_ERROR_STATE; | |||||
| return BOOTLOADER_FLASH_WRITE_ERROR_RES; | |||||
| } | |||||
| int cnt = 0; | |||||
| while(1) | |||||
| { | |||||
| if(SPIFlashCheckBusy() == 0) | |||||
| { | |||||
| break; | |||||
| } | |||||
| if(cnt++ > 200) | |||||
| { | |||||
| printf("Bootloader flash write timeout error. Aborting and going back to STANDBY\n"); | |||||
| BootloaderFlashWriteState = BOOTLOADER_FLASH_WRITE_ERROR_STATE; | |||||
| return BOOTLOADER_FLASH_WRITE_ERROR_RES; | |||||
| } | |||||
| } | |||||
| BootloaderFirmwareChunkWriteCount++; | |||||
| } | |||||
| BootloaderFlashWriteState = BOOTLOADER_FLASH_WRITE_WAIT_FOR_BYTE_DONE; | |||||
| return BOOTLOADER_FLASH_WRITING_RES; | |||||
| // BootloaderFlashWriteState = BOOTLOADER_FLASH_WRITE_STANDBY_STATE; | |||||
| // return BOOTLOADER_FLASH_WRITE_FINISHED_RES; | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_FLASH_WRITE_WAIT_FOR_BYTE_DONE: | |||||
| { | |||||
| if(event == BOOTLOADER_FLASH_WRITE_SM_TICK_EVENT) | |||||
| { | |||||
| BootloaderFlashWriteState = BOOTLOADER_FLASH_WRITE_STANDBY_STATE; | |||||
| return BOOTLOADER_FLASH_WRITE_FINISHED_RES; | |||||
| // if(SyslogIsBufferEmpty() == RET_OK) | |||||
| // { | |||||
| // BootloaderFlashWriteState = BOOTLOADER_FLASH_WRITE_STANDBY_STATE; | |||||
| // return BOOTLOADER_FLASH_WRITE_FINISHED_RES; | |||||
| // } | |||||
| // else | |||||
| // { | |||||
| // return BOOTLOADER_FLASH_WRITING_RES; | |||||
| // } | |||||
| } | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_FLASH_WRITE_CHECKBACK_STATE: | |||||
| { | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_FLASH_WRITE_FINISHED_STATE: | |||||
| { | |||||
| return BOOTLOADER_FLASH_WRITE_FINISHED_RES; | |||||
| break; | |||||
| } | |||||
| case BOOTLOADER_FLASH_WRITE_ERROR_STATE: | |||||
| { | |||||
| return BOOTLOADER_FLASH_WRITE_ERROR_RES; | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| int BootloaderPrintFlashData() | |||||
| { | |||||
| } | |||||
| int BootloaderCheckFlashBootloaderData() | |||||
| { | |||||
| unsigned char FlashData[700]; | |||||
| unsigned int FlashAddress = FLASH_BTLDR_FIRMWARE_START_ADDRESS; | |||||
| unsigned int FileHeaderCode, FirmwareFlags, NbRecords, FirmwareSize, VersionCode, CRC32; | |||||
| unsigned int ComputedCRC32 = CRC_START_32; | |||||
| //SPIFlashReadBuffer(FlashData,700,FlashAddress); | |||||
| printf("Checking Flash bootloader data integrity... \n"); | |||||
| SPIFlashReadBuffer(FlashData,FLASH_BTLDR_HEADER_SIZE,FlashAddress); | |||||
| FileHeaderCode = BootloaderBytesToInt(FlashData); | |||||
| FirmwareFlags = BootloaderBytesToInt(&FlashData[4]); | |||||
| NbRecords = BootloaderBytesToInt(&FlashData[8]); | |||||
| FirmwareSize = BootloaderBytesToInt(&FlashData[12]); | |||||
| VersionCode = BootloaderBytesToInt(&FlashData[16]); | |||||
| CRC32 = BootloaderBytesToInt(&FlashData[20]); | |||||
| mStoredBootloaderInfo.Firmwareflags = FirmwareFlags; | |||||
| mStoredBootloaderInfo.NbRecords = NbRecords; | |||||
| mStoredBootloaderInfo.FirmwareSize = FirmwareSize; | |||||
| mStoredBootloaderInfo.Versioncode = VersionCode; | |||||
| mStoredBootloaderInfo.DataCRC32 = CRC32; | |||||
| //printf("File Header: Code:[0x%x] - Flags:[0x%x] - Nb Records:[%d] - Firmware Size:[%d] - Version:[0x%x] - CRC32:[0x%x]\n",FileHeaderCode,FirmwareFlags,NbRecords,FirmwareSize,VersionCode,CRC32); | |||||
| if(FileHeaderCode != BOOTLOADER_FILE_HEADER_CODE) | |||||
| { | |||||
| // printf("Invalid file header code, aborting\n"); | |||||
| return RET_ERROR; | |||||
| } | |||||
| if(NbRecords == 0) | |||||
| { | |||||
| // printf("No records in file (NbRecords = 0), aborting\n"); | |||||
| return RET_ERROR; | |||||
| } | |||||
| FlashAddress += FLASH_BTLDR_HEADER_SIZE; //point to the start of bootloader data | |||||
| int CurRecord = 0; | |||||
| bool Done = false; | |||||
| int RecHeader, RecSize, RecStartAddress; | |||||
| //Check the header of each sector. | |||||
| while(Done == false) | |||||
| { | |||||
| SPIFlashReadBuffer(FlashData,12,FlashAddress); | |||||
| RecHeader = BootloaderBytesToInt(FlashData); | |||||
| RecSize = BootloaderBytesToInt(&FlashData[4]); | |||||
| RecStartAddress = BootloaderBytesToInt(&FlashData[8]); | |||||
| FlashAddress += 12; | |||||
| if(RecHeader != BOOTLOADER_RECORD_HEADER_CODE) | |||||
| { | |||||
| // printf("Error in record #%d. Invalid header code : [0x%x]\n",CurRecord,RecHeader); | |||||
| return RET_ERROR; | |||||
| } | |||||
| if(RecSize == 0) | |||||
| { | |||||
| // printf("Error in record #%d. Invalid record size (RecordSize = 0) \n"); | |||||
| return RET_ERROR; | |||||
| } | |||||
| // printf("Record #%d OK! Header:[0x%x] - Size:[%d] - Start Address:[0x%x]\n",CurRecord,RecHeader,RecSize,RecStartAddress); | |||||
| // while(SyslogIsBufferEmpty() == RET_ERROR) | |||||
| // { | |||||
| // SyslogTick(); | |||||
| // TickWiFi(); | |||||
| // } | |||||
| CurRecord++; | |||||
| if(CurRecord == NbRecords) | |||||
| { | |||||
| // Done = true; | |||||
| // printf("All records checked OK! Computing CRC...\n"); | |||||
| Done = true; | |||||
| break; | |||||
| //return RET_OK; | |||||
| } | |||||
| else | |||||
| { | |||||
| FlashAddress += RecSize; | |||||
| } | |||||
| } | |||||
| //Now, compute whole data CRC | |||||
| FlashAddress = FLASH_BTLDR_FIRMWARE_START_ADDRESS + FLASH_BTLDR_HEADER_SIZE; | |||||
| char Byte; | |||||
| int i; | |||||
| for(i = 0; i < FirmwareSize; i++) | |||||
| { | |||||
| SPIFlashReadBuffer(&Byte,1,FlashAddress++); | |||||
| ComputedCRC32 = update_crc_32(ComputedCRC32,Byte); | |||||
| } | |||||
| ComputedCRC32 ^= 0xffffffffL; | |||||
| if(ComputedCRC32 == CRC32) | |||||
| { | |||||
| // printf("CRC32 matches. Computed:[0x%x] - Expected:[0x%x]\n",ComputedCRC32,CRC32); | |||||
| // printf("Flash check success. Firmware is valid\n"); | |||||
| return RET_OK; | |||||
| } | |||||
| else | |||||
| { | |||||
| // printf("CRC32 mismatch. Computed:[0x%x] - Expected:[0x%x]\n",ComputedCRC32,CRC32); | |||||
| // printf("Flash check failed.\n"); | |||||
| return RET_ERROR; | |||||
| } | |||||
| return RET_OK; | |||||
| } | |||||
| int ResetBootloaderFlashWriteStateMachine() | |||||
| { | |||||
| BootloaderFlashWriteState = BOOTLOADER_FLASH_WRITE_STANDBY_STATE; | |||||
| BootloaderCurFlashWriteAddress = FLASH_BTLDR_FIRMWARE_START_ADDRESS; | |||||
| BootloaderFlashWritePollCount = 0; | |||||
| BootloaderFirmwareChunkWriteCount = 0; | |||||
| BootloaderFlashWriteDataPtr = 0; | |||||
| BootloaderFirmwareChunkWriteCount = 0; | |||||
| return RET_OK; | |||||
| } | |||||
| int BootloaderBytesToInt(unsigned char *Bytes) | |||||
| { | |||||
| if(Bytes == 0) | |||||
| { | |||||
| return 0; | |||||
| } | |||||
| int Output = Bytes[0]; | |||||
| Output <<= 8; | |||||
| Output += Bytes[1]; | |||||
| Output <<= 8; | |||||
| Output += Bytes[2]; | |||||
| Output <<= 8; | |||||
| Output += Bytes[3]; | |||||
| return Output; | |||||
| } | |||||
| int BootloaderIntToBytes(unsigned char *Buf, unsigned int Input) | |||||
| { | |||||
| if(Buf == 0) | |||||
| { | |||||
| return 0; | |||||
| } | |||||
| Buf[3] = (unsigned char)(Input & 0xFF); | |||||
| Input >>= 8; | |||||
| Buf[2] = (unsigned char)(Input & 0xFF); | |||||
| Input >>= 8; | |||||
| Buf[1] = (unsigned char)(Input & 0xFF); | |||||
| Input >>= 8; | |||||
| Buf[0] = (unsigned char)(Input & 0xFF); | |||||
| Input >>= 8; | |||||
| return 1; | |||||
| } | |||||
| @@ -0,0 +1,182 @@ | |||||
| /* | |||||
| * File: ChaletPowerRelay.h | |||||
| * Author: JF | |||||
| * | |||||
| * Created on November 30, 2018, 7:33 PM | |||||
| */ | |||||
| #ifndef BOOTLOADERINTERFACE_H | |||||
| #define BOOTLOADERINTERFACE_H | |||||
| #include "define.h" | |||||
| #define BOOTLOADER_FILE_HEADER_CODE (int)0xBAADBEEF | |||||
| #define BOOTLOADER_RECORD_HEADER_CODE (int)0xDEADBEEF | |||||
| #define BOOTLOADER_FLASH_FIRMWARE_VALIDATOR 0xA8 | |||||
| #define BOOTLOADER_ENTER_UPLOAD_MODE_VALIDATOR 0x5A | |||||
| typedef struct | |||||
| { | |||||
| unsigned char BootloaderAction; | |||||
| unsigned char BootloaderActionValidator; | |||||
| }stBootloaderFlags_t; | |||||
| typedef struct | |||||
| { | |||||
| unsigned int Firmwareflags; | |||||
| unsigned int NbRecords; | |||||
| unsigned int FirmwareSize; | |||||
| unsigned int Versioncode; | |||||
| unsigned int DataCRC32; | |||||
| }stStoredBootloaderInfo; | |||||
| extern stBootloaderFlags_t mBootloaderFlags; | |||||
| stStoredBootloaderInfo mStoredBootloaderInfo; | |||||
| enum eBootloaderFlagsIndex | |||||
| { | |||||
| BOOTLOADER_FLAGS_ACTION_FLAG_INDEX = 0, | |||||
| BOOTLOADER_FLAGS_ACTION_VALIDATOR_INDEX, | |||||
| BOOTLOADER_FLAGS_MAX_INDEX = 12 | |||||
| }; | |||||
| enum eBootloaderActionFlagValues | |||||
| { | |||||
| BOOTLOADER_ACTION_JUMP_TO_APP_VALUE = 0, | |||||
| BOOTLOADER_ACTION_FLASH_FIRMWARE_VALUE = 1, | |||||
| BOOTLOADER_ACTION_ENTER_UPDATE_MODE_VALUE = 2, | |||||
| BOOTLOADER_ACTION_MAX_VALUE | |||||
| }; | |||||
| enum eBootloaderStates | |||||
| { | |||||
| BOOTLOADER_STANDBY_STATE, | |||||
| BOOTLOADER_ACTIVE_STATE, | |||||
| BOOTLOADER_ERASE_FLASH_STATE, | |||||
| BOOTLOADER_RECEIVING_FIRMWARE_STATE, | |||||
| BOOTLOADER_SENDING_FIRMWARE_COPY_STATE, | |||||
| BOOTLOADER_PRINTING_FIRMWARE_STATE, | |||||
| BOOTLOADER_MAX_STATE | |||||
| }; | |||||
| enum eBootloaderStateMachineEvents | |||||
| { | |||||
| BOOTLOADER_TICK_EVENT, | |||||
| BOOTLOADER_NEW_CMD_EVENT, | |||||
| BOOTLOADER_TIMEOUT_EVENT, | |||||
| BOOTLOADER_MAX_EVENT | |||||
| }; | |||||
| enum eBootloaderFlashEraseStates | |||||
| { | |||||
| BOOTLOADER_FLASH_ERASE_SECTOR_STATE, | |||||
| BOOTLOADER_FLASH_ERASE_WAIT_FOR_SECTOR_DONE, | |||||
| BOOTLOADER_FLASH_ERASE_CHECKBACK_STATE, | |||||
| BOOTLOADER_FLASH_ERASE_FINISHED_STATE, | |||||
| BOOTLOADER_FLASH_ERASE_ERROR_STATE, | |||||
| BOOTLOADER_FLASH_ERASE_MAX_STATE | |||||
| }; | |||||
| enum eBootloaderFlashEraseResults | |||||
| { | |||||
| BOOTLOADER_FLASH_ERASE_RUNNING_RES, | |||||
| BOOTLOADER_FLASH_ERASE_FINISHED_RES, | |||||
| BOOTLOADER_FLASH_ERASE_ERROR_RES, | |||||
| BOOTLOADER_FLASH_ERASE_ABORT_RES, | |||||
| BOOTLOADER_FLASH_ERASE_MAX_RES | |||||
| }; | |||||
| enum eBootloaderFlahsEraseSMEvents | |||||
| { | |||||
| BOOTLOADER_FLASH_ERASE_SM_TICK_EVENT, | |||||
| BOOTLOADER_FLASH_ERASE_SM_ABORT_EVENT, | |||||
| BOOTLOADER_FLASH_ERASE_SM_MAX_EVENT | |||||
| }; | |||||
| enum eBootloaderFlashWriteStates | |||||
| { | |||||
| BOOTLOADER_FLASH_WRITE_STANDBY_STATE, | |||||
| BOOTLOADER_FLASH_WRITE_BUFFER_STATE, | |||||
| BOOTLOADER_FLASH_WRITE_WAIT_FOR_BYTE_DONE, | |||||
| BOOTLOADER_FLASH_WRITE_CHECKBACK_STATE, | |||||
| BOOTLOADER_FLASH_WRITE_FINISHED_STATE, | |||||
| BOOTLOADER_FLASH_WRITE_ERROR_STATE, | |||||
| BOOTLOADER_FLASH_WRITE_MAX_STATE | |||||
| }; | |||||
| enum eBootloaderFlashWriteResults | |||||
| { | |||||
| BOOTLOADER_FLASH_WRITING_RES, | |||||
| BOOTLOADER_FLASH_WRITE_FINISHED_RES, | |||||
| BOOTLOADER_FLASH_WRITE_ERROR_RES, | |||||
| BOOTLOADER_FLASH_WRITE_ABORT_RES, | |||||
| BOOTLOADER_FLASH_WRITE_MAX_RES | |||||
| }; | |||||
| enum eBootloaderFlahsWriteSMEvents | |||||
| { | |||||
| BOOTLOADER_FLASH_WRITE_SM_TICK_EVENT, | |||||
| BOOTLOADER_FLASH_WRITE_SM_NEW_BUFFER_EVENT, | |||||
| BOOTLOADER_FLASH_WRITE_SM_ABORT_EVENT, | |||||
| BOOTLOADER_FLASH_WRITE_SM_MAX_EVENT | |||||
| }; | |||||
| enum eBootloaderStateMachineCmds | |||||
| { | |||||
| BOOTLOADER_SM_ACTIVATE_CMD, | |||||
| BOOTLOADER_SM_ABORT_CMD, | |||||
| BOOTLOADER_SM_ERASE_FLASH_CMD, | |||||
| BOOTLOADER_SM_INIT_UPLOAD_CMD, | |||||
| BOOTLOADER_SM_NEW_DATA_CHUNK_CMD, | |||||
| BOOTLOADER_SM_UPLOAD_FINISHED_CMD, | |||||
| BOOTLOADER_SM_EXECUTE_UPGRAGE_CMD, | |||||
| BOOTLOADER_SM_INVALID_CRC_CMD, | |||||
| BOOTLOADER_SM_CHECK_FLASH_CMD, | |||||
| BOOTLOADER_SM_GET_FIRMWARE_DATA_CMD | |||||
| }; | |||||
| extern unsigned char BootloaderBuffer[300]; | |||||
| int BootloaderInterfaceInit(); | |||||
| void BootloaderExecuteCmd(char Cmd,bool CRCValid); | |||||
| void BootloaderCRCError(char Cmd, int RxCRC, int ExpectedCRC); | |||||
| void BootloaderInterfaceTick(); | |||||
| void BootloaderInterfaceStateMachine(int Event, int Param); | |||||
| void BootloaderResetStateMachine(); | |||||
| void BootloaderActivateBootloader(); | |||||
| void BootloaderDeactivateBootloader(); | |||||
| int BootloaderFlashEraseStateMachine(int event); | |||||
| int ResetBootloaderFlashEraseStateMachine(); | |||||
| int BootloaderFlashWriteStateMachine(int event); | |||||
| int ResetBootloaderFlashWriteStateMachine(); | |||||
| int BootloaderCheckFlashBootloaderData(); | |||||
| int BootloaderPrintFlashData(); | |||||
| int BootloaderBytesToInt(unsigned char *Bytes); | |||||
| int BootloaderIntToBytes(unsigned char *Buf, unsigned int Input); | |||||
| #endif /* BOOTLOADERINTERFACE_H */ | |||||
| @@ -0,0 +1,427 @@ | |||||
| /********************************************************************** | |||||
| Project: Automatic cat feeder | |||||
| Date: march 19 2006 | |||||
| Author: Jean-Fran�ois Martel | |||||
| Target: PIC 18F252 | |||||
| Compiler: Microchip mcc18 | |||||
| Filename: Protocol.c | |||||
| File description: Communication protocol implementation. | |||||
| jean-francois.martel@polymtl.ca | |||||
| **********************************************************************/ | |||||
| #include "define.h" | |||||
| #include <string.h> | |||||
| #include "ProtocolDefs.h" | |||||
| #include "BootloaderProtocol.h" | |||||
| #include "BootloaderInterface.h" | |||||
| #include "WiFiCtrl.h" | |||||
| #include "checksum.h" | |||||
| //test | |||||
| unsigned int BootloaderHeader = 0; | |||||
| unsigned int BootloaderDataSize = 0; | |||||
| unsigned int BootloaderDataCtr = 0; | |||||
| unsigned int BootloaderBufPtr = 0; | |||||
| unsigned int BootloaderCRC = 0; | |||||
| unsigned int BtldrComputedCRC = CRC_START_32; | |||||
| unsigned char *BootloaderRxPtr; | |||||
| unsigned char BootloaderCommand = 0; | |||||
| unsigned char BootloaderState = RxHeader1; | |||||
| const unsigned char *BootloaderDataStartPtr = &BootloaderBuffer[9]; | |||||
| static char MyDeviceID = ID_SPRINKLER_DEVICE; | |||||
| void BootloaderProtocolInit(void) | |||||
| { | |||||
| BootloaderProtocolResetStateMachine(); | |||||
| } | |||||
| void BootloaderProtocolStateMachine(unsigned char Data) | |||||
| { | |||||
| switch(BootloaderState) | |||||
| { | |||||
| case Initialization: //Reset all pointers and data... | |||||
| { | |||||
| BootloaderDataSize = 0; | |||||
| BootloaderBufPtr = 0; | |||||
| BootloaderCommand = 0; | |||||
| BootloaderCRC = 0; | |||||
| BootloaderState = RxHeader1; | |||||
| BtldrComputedCRC = CRC_START_32; | |||||
| break; | |||||
| } | |||||
| case RxHeader1: //Wait for data header... | |||||
| { | |||||
| BootloaderHeader <<= 8; | |||||
| BootloaderHeader += Data; //0xDE | |||||
| BtldrComputedCRC = update_crc_32(BtldrComputedCRC,Data); | |||||
| if(Data == BOOTLOADER_FRAME_HEADER_1) | |||||
| { | |||||
| BootloaderState = RxHeader2; | |||||
| } | |||||
| else | |||||
| { | |||||
| BootloaderProtocolResetStateMachine(); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case RxHeader2: //Wait for data header... | |||||
| { | |||||
| BootloaderHeader <<= 8; | |||||
| BootloaderHeader += Data; //0xAD | |||||
| BtldrComputedCRC = update_crc_32(BtldrComputedCRC,Data); | |||||
| if(Data == BOOTLOADER_FRAME_HEADER_2) | |||||
| { | |||||
| BootloaderState = RxHeader3; | |||||
| } | |||||
| else | |||||
| { | |||||
| BootloaderProtocolResetStateMachine(); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case RxHeader3: //Wait for data header... | |||||
| { | |||||
| BootloaderHeader <<= 8; | |||||
| BootloaderHeader += Data; //0xBE | |||||
| BtldrComputedCRC = update_crc_32(BtldrComputedCRC,Data); | |||||
| if(Data == BOOTLOADER_FRAME_HEADER_3) | |||||
| { | |||||
| BootloaderState = RxHeader4; | |||||
| } | |||||
| else | |||||
| { | |||||
| BootloaderProtocolResetStateMachine(); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case RxHeader4: //Wait for data header... | |||||
| { | |||||
| BootloaderHeader <<= 8; | |||||
| BootloaderHeader += Data; //0xEF | |||||
| BtldrComputedCRC = update_crc_32(BtldrComputedCRC,Data); | |||||
| if(BootloaderHeader != BOOTLOADER_FRAME_HEADER) | |||||
| { | |||||
| //TODO, send NACK? | |||||
| BootloaderProtocolResetStateMachine(); | |||||
| break; | |||||
| } | |||||
| else | |||||
| { | |||||
| BootloaderState = RxCmd; | |||||
| } | |||||
| break; | |||||
| } | |||||
| case RxCmd: | |||||
| { | |||||
| BootloaderCommand = Data; | |||||
| BootloaderState = RxPayloadSize1; | |||||
| BtldrComputedCRC = update_crc_32(BtldrComputedCRC,Data); | |||||
| break; | |||||
| } | |||||
| case RxPayloadSize1: | |||||
| { | |||||
| BootloaderDataSize = Data; | |||||
| BootloaderState = RxPayloadSize2; | |||||
| BtldrComputedCRC = update_crc_32(BtldrComputedCRC,Data); | |||||
| break; | |||||
| } | |||||
| case RxPayloadSize2: | |||||
| { | |||||
| BootloaderDataSize <<= 8; | |||||
| BootloaderDataSize += Data; | |||||
| BtldrComputedCRC = update_crc_32(BtldrComputedCRC,Data); | |||||
| BootloaderState = RxPayloadSize3; | |||||
| break; | |||||
| } | |||||
| case RxPayloadSize3: | |||||
| { | |||||
| BootloaderDataSize <<= 8; | |||||
| BootloaderDataSize += Data; | |||||
| BtldrComputedCRC = update_crc_32(BtldrComputedCRC,Data); | |||||
| BootloaderState = RxPayloadSize4; | |||||
| break; | |||||
| } | |||||
| case RxPayloadSize4: | |||||
| { | |||||
| BootloaderDataSize <<= 8; | |||||
| BootloaderDataSize += Data; | |||||
| BtldrComputedCRC = update_crc_32(BtldrComputedCRC,Data); | |||||
| if(BootloaderDataSize > MAX_BOOTLOADER_PAYLOAD_SIZE+8) //+8 bytes for the size and index data | |||||
| { | |||||
| //TODO, send NACK? | |||||
| BootloaderProtocolResetStateMachine(); | |||||
| break; | |||||
| } | |||||
| if(BootloaderDataSize == 0) | |||||
| { | |||||
| BootloaderState = RxCRC1; | |||||
| } | |||||
| else | |||||
| { | |||||
| BootloaderState = RxPayload; | |||||
| } | |||||
| break; | |||||
| } | |||||
| case RxPayload: //Data size | |||||
| { | |||||
| *BootloaderRxPtr = Data; | |||||
| BootloaderRxPtr++; | |||||
| BootloaderDataCtr++; | |||||
| BtldrComputedCRC = update_crc_32(BtldrComputedCRC,Data); | |||||
| if(BootloaderDataCtr == BootloaderDataSize) | |||||
| { | |||||
| BootloaderState = RxCRC1; | |||||
| break; | |||||
| } | |||||
| break; | |||||
| } | |||||
| case RxCRC1: //Data size | |||||
| { | |||||
| BootloaderCRC = Data; | |||||
| BootloaderState = RxCRC2; | |||||
| break; | |||||
| } | |||||
| case RxCRC2: //Data size | |||||
| { | |||||
| BootloaderCRC <<= 8; | |||||
| BootloaderCRC += Data; | |||||
| BootloaderState = RxCRC3; | |||||
| break; | |||||
| } | |||||
| case RxCRC3: //Data size | |||||
| { | |||||
| BootloaderCRC <<= 8; | |||||
| BootloaderCRC += Data; | |||||
| BootloaderState = RxCRC4; | |||||
| break; | |||||
| } | |||||
| case RxCRC4: //Data size | |||||
| { | |||||
| BootloaderCRC <<= 8; | |||||
| BootloaderCRC += Data; | |||||
| //TODO: Compute and Compare CRC. | |||||
| BtldrComputedCRC ^= 0xffffffffL; | |||||
| //if(BootloaderCRC != 0xBAADCAFE) | |||||
| if(BootloaderCRC != BtldrComputedCRC) | |||||
| { | |||||
| BootloaderExecuteCmd(BootloaderCommand,0); | |||||
| BootloaderProtocolResetStateMachine(); | |||||
| return; | |||||
| } | |||||
| BootloaderExecuteCmd(BootloaderCommand,1); | |||||
| BootloaderProtocolResetStateMachine(); | |||||
| break; | |||||
| } | |||||
| default: | |||||
| { | |||||
| BootloaderProtocolResetStateMachine(); | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| void BootloaderProtocolProtocolAnalyzeNewData(unsigned char *DataBuf, int size) | |||||
| { | |||||
| int i; | |||||
| for(i = 0; i < size; i++) | |||||
| { | |||||
| BootloaderProtocolStateMachine(*DataBuf++); | |||||
| } | |||||
| } | |||||
| void BootloaderProtocolResetStateMachine() | |||||
| { | |||||
| BootloaderDataSize = 0; | |||||
| BootloaderHeader = 0; | |||||
| BootloaderBufPtr = 0; | |||||
| BootloaderCommand = 0; | |||||
| BootloaderCRC = 0; | |||||
| BootloaderState = RxHeader1; | |||||
| BootloaderDataCtr = 0; | |||||
| BtldrComputedCRC = CRC_START_32; | |||||
| BootloaderRxPtr = &BootloaderBuffer[0]; | |||||
| } | |||||
| void BootloaderProtocolSendFrame(unsigned char Cmd, int Size) | |||||
| { | |||||
| //Header | |||||
| BootloaderBuffer[0] = BOOTLOADER_FRAME_HEADER_1; //Header | |||||
| BootloaderBuffer[1] = BOOTLOADER_FRAME_HEADER_2; | |||||
| BootloaderBuffer[2] = BOOTLOADER_FRAME_HEADER_3; | |||||
| BootloaderBuffer[3] = BOOTLOADER_FRAME_HEADER_4; | |||||
| BootloaderBuffer[4] = Cmd; | |||||
| char nibble = (char)((Size >> 24) &0x000000FF); | |||||
| BootloaderBuffer[5] = nibble; | |||||
| nibble = (char)((Size >> 16) &0x000000FF); | |||||
| BootloaderBuffer[6] = nibble; | |||||
| nibble = (char)((Size >> 8) &0x000000FF); | |||||
| BootloaderBuffer[7] = nibble; | |||||
| nibble = (char)(Size &0x000000FF); | |||||
| BootloaderBuffer[8] = nibble; | |||||
| unsigned int CRC = CRC_START_32; | |||||
| CRC = crc_32((const unsigned char*)BootloaderBuffer,Size+9); | |||||
| unsigned char* CRCPtr = (unsigned char*)BootloaderDataStartPtr + Size; | |||||
| nibble = (char)((CRC >> 24) &0x000000FF); | |||||
| *CRCPtr++ = nibble; | |||||
| nibble = (char)((CRC >> 16) &0x000000FF); | |||||
| *CRCPtr++ = nibble; | |||||
| nibble = (char)((CRC >> 8) &0x000000FF); | |||||
| *CRCPtr++ = nibble; | |||||
| nibble = (char)(CRC &0x000000FF); | |||||
| *CRCPtr++ = nibble; | |||||
| // *CRCPtr++ = 0xBA; | |||||
| // *CRCPtr++ = 0xAD; | |||||
| // *CRCPtr++ = 0xCA; | |||||
| // *CRCPtr++ = 0xFE; | |||||
| SendBootloaderData(&BootloaderBuffer[0],Size + PROTOCOL_INFO_DATA_SIZE); | |||||
| } | |||||
| unsigned char *BootloaderProtocolGetDataBufferPtr() | |||||
| { | |||||
| return (unsigned char*)BootloaderDataStartPtr; | |||||
| } | |||||
| void BootloaderProtocolSendHeartbeat() | |||||
| { | |||||
| *BootloaderProtocolGetDataBufferPtr() = BOOTLOADER_ACK; | |||||
| BootloaderProtocolSendFrame(BOOTLOADER_HEARTBEAT_RESPONSE,1); | |||||
| } | |||||
| void BootloaderProtocolSendACK(unsigned char Cmd) | |||||
| { | |||||
| *BootloaderProtocolGetDataBufferPtr() = BOOTLOADER_ACK; | |||||
| BootloaderProtocolSendFrame(Cmd,1); | |||||
| } | |||||
| void BootloaderProtocolSendNACK(unsigned char Cmd) | |||||
| { | |||||
| *BootloaderProtocolGetDataBufferPtr() = 0; | |||||
| BootloaderProtocolSendFrame(Cmd,1); | |||||
| } | |||||
| void BootloaderProtocolSendInitUploadResponse(char result) | |||||
| { | |||||
| int MaxSize = MAX_BOOTLOADER_PAYLOAD_SIZE; | |||||
| char* DataPtr = BootloaderProtocolGetDataBufferPtr(); | |||||
| *DataPtr++ = result; | |||||
| if(result == 1) | |||||
| { | |||||
| char nibble = (char)((MaxSize >> 24) &0x000000FF); | |||||
| *DataPtr++ = nibble; | |||||
| nibble = (char)((MaxSize >> 16) &0x000000FF); | |||||
| *DataPtr++ = nibble; | |||||
| nibble = (char)((MaxSize >> 8) &0x000000FF); | |||||
| *DataPtr++ = nibble; | |||||
| nibble = (char)(MaxSize &0x000000FF); | |||||
| *DataPtr++ = nibble; | |||||
| } | |||||
| else | |||||
| { | |||||
| *DataPtr++ = 0; | |||||
| *DataPtr++ = 0; | |||||
| *DataPtr++ = 0; | |||||
| *DataPtr++ = 0; | |||||
| } | |||||
| BootloaderProtocolSendFrame(BOOTLOADER_INIT_UPLOAD_RESPONSE,5); | |||||
| } | |||||
| void BootloaderProtocolSendDataChunkResult(char ErrorCode, int ChunkValue) | |||||
| { | |||||
| char* DataPtr = BootloaderProtocolGetDataBufferPtr(); | |||||
| *DataPtr++ = ErrorCode; | |||||
| char nibble = (char)((ChunkValue >> 24) &0x000000FF); | |||||
| *DataPtr++ = nibble; | |||||
| nibble = (char)((ChunkValue >> 16) &0x000000FF); | |||||
| *DataPtr++ = nibble; | |||||
| nibble = (char)((ChunkValue >> 8) &0x000000FF); | |||||
| *DataPtr++ = nibble; | |||||
| nibble = (char)(ChunkValue &0x000000FF); | |||||
| *DataPtr++ = nibble; | |||||
| BootloaderProtocolSendFrame(BOOTLOADER_SEND_DATA_CHUNK_RESPONSE,5); | |||||
| } | |||||
| void BootloaderProtocolSendBootloaderState(char State) | |||||
| { | |||||
| char* DataPtr = BootloaderProtocolGetDataBufferPtr(); | |||||
| *DataPtr++ = State; | |||||
| BootloaderProtocolSendFrame(BOOTLOADER_GET_STATE_RESPONSE,1); | |||||
| } | |||||
| void BootloaderProtocolSendFirmwareUploadResult(char Result) | |||||
| { | |||||
| char* DataPtr = BootloaderProtocolGetDataBufferPtr(); | |||||
| *DataPtr++ = Result; | |||||
| BootloaderProtocolSendFrame(BOOTLOADER_UPLOAD_FINISHED_RESPONSE,1); | |||||
| } | |||||
| void BootloaderProtocolSendFlashCheckResult(char Result) | |||||
| { | |||||
| char* DataPtr = BootloaderProtocolGetDataBufferPtr(); | |||||
| *DataPtr++ = Result; | |||||
| BootloaderProtocolSendFrame(BOOTLOADER_CHECK_FLASH_FIRMW_INTEGRITY_RESPONSE,1); | |||||
| } | |||||
| void BootloaderProtocolSendStoredFirmwareInfoResponse(unsigned char* FirmwareData, int size) | |||||
| { | |||||
| char* DataPtr = BootloaderProtocolGetDataBufferPtr(); | |||||
| int i = 0; | |||||
| for(i = 0; i < size; i++) | |||||
| { | |||||
| *DataPtr++ = *FirmwareData++; | |||||
| } | |||||
| BootloaderProtocolSendFrame(BOOTLOADER_GET_STORED_FIRMWARE_INFO_RESPONSE,size); | |||||
| } | |||||
| @@ -0,0 +1,123 @@ | |||||
| /********************************************************************** | |||||
| Project: Automatic cat feeder | |||||
| Date: march 19 2006 | |||||
| Author: Jean-Fran�ois Martel | |||||
| Target: PIC 18F252 | |||||
| Compiler: Microchip mcc18 | |||||
| Filename: Protocol.h | |||||
| File description: Communication protocol implementation. | |||||
| jean-francois.martel@polymtl.ca | |||||
| **********************************************************************/ | |||||
| #ifndef BOOTLOADERPROTOCOL_H | |||||
| #define BOOTLOADERPROTOCOL_H | |||||
| //Protocol buffer specific definitions | |||||
| #define MAX_BOOTLOADER_PAYLOAD_SIZE 150 | |||||
| #define BOOTLOADER_FRAME_HEADER 0xDEADBEEF | |||||
| #define BOOTLOADER_FRAME_HEADER_1 0xDE | |||||
| #define BOOTLOADER_FRAME_HEADER_2 0xAD | |||||
| #define BOOTLOADER_FRAME_HEADER_3 0xBE | |||||
| #define BOOTLOADER_FRAME_HEADER_4 0xEF | |||||
| #define PROTOCOL_INFO_DATA_SIZE 13 //Header + Cmd + Size + CRC = 13 bytes | |||||
| //State Machine states | |||||
| enum States | |||||
| { | |||||
| Initialization, | |||||
| RxHeader1, | |||||
| RxHeader2, | |||||
| RxHeader3, | |||||
| RxHeader4, | |||||
| RxCmd, | |||||
| RxPayloadSize1, | |||||
| RxPayloadSize2, | |||||
| RxPayloadSize3, | |||||
| RxPayloadSize4, | |||||
| RxPayload, | |||||
| RxCRC1, | |||||
| RxCRC2, | |||||
| RxCRC3, | |||||
| RxCRC4 | |||||
| }; | |||||
| enum eBootloaderProtocolDataTransferError | |||||
| { | |||||
| BOOTLOADER_CHUNK_TRANSFER_SUCCESS = 1, | |||||
| BOOTLOADER_CHUNK_TRANSFER_ERROR_RESEND = 2, | |||||
| BOOTLOADER_CHUNK_TRANSFER_ERROR_FLASH_FAILURE = 3, | |||||
| BOOTLOADER_CHUNK_TRANSFER_ERROR_INVALID_CHUNK_INDEX = 4, | |||||
| BOOTLOADER_CHUNK_TRANSFER_ERROR_FLASH_ERROR = 5, | |||||
| BOOTLOADER_CHUNK_TRANSFER_MAX_ERROR | |||||
| }; | |||||
| enum eBootloaderProtocolInitTransferError | |||||
| { | |||||
| BOOTLOADEDR_INIT_TRANSFER_ERROR = 0, | |||||
| BOOTLOADEDR_INIT_TRANSFER_OK = 1, | |||||
| BOOTLOADEDR_INIT_TRANSFER_ERROR_FLASH_NOT_ERASED, | |||||
| BOOTLOADEDR_INIT_TRANSFER_MAX_ERROR | |||||
| }; | |||||
| enum eBootloaderUploadResult | |||||
| { | |||||
| BOOTLOADER_UPLOAD_FAILED_UNKNOWN_ERROR = 0, | |||||
| BOOTLOADER_UPLOAD_SUCCESS = 1, | |||||
| BOOTLOADER_UPLOAD_FAILED_FLASH_VERIFICATION_ERROR = 2, | |||||
| BOOTLOADER_UPLOAD_MAX_ERROR | |||||
| }; | |||||
| enum eFlashCheckResult | |||||
| { | |||||
| FLASH_CHECK_FAILED = 0, | |||||
| FLASH_CHECK_SUCCESS = 1, | |||||
| FLASH_CHECK_MAX_RESULT | |||||
| }; | |||||
| //enum DEVICES_IDS | |||||
| //{ | |||||
| // ID_MASTER, //Master Controller | |||||
| // ID_CONSOLE, //LCD Console | |||||
| // ID_PC, //PC | |||||
| // ID_AV_MUX, //Audio Video Multiplexer | |||||
| // ID_IR_REMOTE, | |||||
| // ID_DEADBOLT | |||||
| //}; | |||||
| //enum MESSAGE_IDS | |||||
| //{ | |||||
| // TX_NETWORK_ACK = 1, | |||||
| // RX_GET_STATUS, | |||||
| // TX_DEADBOLT_STATUS, | |||||
| // | |||||
| // MAX_NETWORK_CMD | |||||
| //}; | |||||
| //State machine states definition | |||||
| void BootloaderProtocolInit(void); | |||||
| void BootloaderProtocolStateMachine(unsigned char STATE); | |||||
| void BootloaderProtocolResetStateMachine(void); | |||||
| void BootloaderProtocolProtocolAnalyzeNewData(unsigned char *DataBuf, int size); | |||||
| void BootloaderProtocolSendFrame(unsigned char Cmd, int size); | |||||
| unsigned char *BootloaderProtocolGetDataBufferPtr(); | |||||
| void BootloaderProtocolSendHeartbeat(); | |||||
| void BootloaderProtocolSendACK(unsigned char Cmd); | |||||
| void BootloaderProtocolSendNACK(unsigned char Cmd); | |||||
| void BootloaderProtocolSendInitUploadResponse(char result); | |||||
| void BootloaderProtocolSendDataChunkResult(char ErrorCode, int ChunkValue); | |||||
| void BootloaderProtocolSendBootloaderState(char State); | |||||
| void BootloaderProtocolSendFirmwareUploadResult(char Result); | |||||
| void BootloaderProtocolSendFlashCheckResult(char Result); | |||||
| void BootloaderProtocolSendStoredFirmwareInfoResponse(unsigned char* FirmwareData, int size); | |||||
| #endif | |||||
| @@ -0,0 +1,79 @@ | |||||
| //#include <proc/p32mx440f256h.h> | |||||
| #include "ChaletPowerRelay.h" | |||||
| #include "BoardCfg.h" | |||||
| #include "timer.h" | |||||
| #define PIN_ACTIVE 1 | |||||
| #define PIN_INACTIVE 0 | |||||
| bool PowerRelayState; | |||||
| void InitChaletPowerRelay() | |||||
| { | |||||
| POWER_RELAY_ON_PIN = PIN_INACTIVE; | |||||
| POWER_RELAY_OFF_PIN = PIN_INACTIVE; | |||||
| PowerRelayState = CHALET_POWER_RELAY_UNKNOWN_STATE; | |||||
| TimerStop(CHALET_POWER_RELAY_COIL_TIMER); | |||||
| } | |||||
| void ChaletPowerRelayTick() | |||||
| { | |||||
| if(CHALET_12V_PRESENCE_PIN == CHALET_12V_POWER_STATE_ON) | |||||
| { | |||||
| if(PowerRelayState == CHALET_POWER_RELAY_OFF_STATE) | |||||
| { | |||||
| printf("Inverter turned ON\n"); | |||||
| } | |||||
| PowerRelayState = CHALET_POWER_RELAY_ON_STATE; | |||||
| } | |||||
| else | |||||
| { | |||||
| if(PowerRelayState == CHALET_POWER_RELAY_ON_STATE) | |||||
| { | |||||
| printf("Inverter turned OFF\n"); | |||||
| } | |||||
| PowerRelayState = CHALET_POWER_RELAY_OFF_STATE; | |||||
| } | |||||
| if(IsTimerRunning(CHALET_POWER_RELAY_COIL_TIMER) == true) | |||||
| { | |||||
| if(IsTimerExpired(CHALET_POWER_RELAY_COIL_TIMER)) | |||||
| { | |||||
| POWER_RELAY_ON_PIN = PIN_INACTIVE; | |||||
| POWER_RELAY_OFF_PIN = PIN_INACTIVE; | |||||
| TimerStop(CHALET_POWER_RELAY_COIL_TIMER); | |||||
| } | |||||
| } | |||||
| if(IsTimerExpired(CHALET_POWER_RELAY_AUTOTURNOFF_TIMER)) | |||||
| { | |||||
| ChaletPowerRelayTurnOff(); | |||||
| } | |||||
| } | |||||
| void ChaletPowerRelayKickTimer() | |||||
| { | |||||
| TimerStartSeconds(CHALET_POWER_RELAY_AUTOTURNOFF_TIMER,CHALET_OFFLINE_POWER_RELAY_RESET_TIMEOUT); | |||||
| } | |||||
| bool ChaletPowerRelayTurnOn() | |||||
| { | |||||
| POWER_RELAY_ON_PIN = PIN_ACTIVE; | |||||
| TimerStart(CHALET_POWER_RELAY_COIL_TIMER,CHALET_POWER_RELAY_COIL_TIMEOUT); | |||||
| // PowerRelayState = CHALET_POWER_RELAY_ON_STATE; | |||||
| return true; | |||||
| } | |||||
| bool ChaletPowerRelayTurnOff() | |||||
| { | |||||
| POWER_RELAY_OFF_PIN = PIN_ACTIVE; | |||||
| TimerStart(CHALET_POWER_RELAY_COIL_TIMER,CHALET_POWER_RELAY_COIL_TIMEOUT); | |||||
| // PowerRelayState = CHALET_POWER_RELAY_OFF_STATE; | |||||
| return true; | |||||
| } | |||||
| char GetChaletPowerRelayState() | |||||
| { | |||||
| return (char)PowerRelayState; | |||||
| } | |||||
| @@ -0,0 +1,37 @@ | |||||
| /* | |||||
| * File: ChaletPowerRelay.h | |||||
| * Author: JF | |||||
| * | |||||
| * Created on November 30, 2018, 7:33 PM | |||||
| */ | |||||
| #ifndef CHALETPOWERRELAY_H | |||||
| #define CHALETPOWERRELAY_H | |||||
| #include "define.h" | |||||
| #define CHALET_OFFLINE_POWER_RELAY_RESET_TIMEOUT 43200 //43,200 = 12 hours in seconds | |||||
| enum eChaletPowerRelayState | |||||
| { | |||||
| CHALET_POWER_RELAY_OFF_STATE = 0, | |||||
| CHALET_POWER_RELAY_ON_STATE, | |||||
| CHALET_POWER_RELAY_UNKNOWN_STATE | |||||
| }; | |||||
| #define CHALET_12V_POWER_STATE_ON 0 | |||||
| #define CHALET_12V_POWER_STATE_OFF 1 | |||||
| #define CHALET_POWER_RELAY_COIL_TIMEOUT 200 //ms | |||||
| void InitChaletPowerRelay(); | |||||
| void ChaletPowerRelayTick(); | |||||
| bool ChaletPowerRelayTurnOn(); | |||||
| bool ChaletPowerRelayTurnOff(); | |||||
| char GetChaletPowerRelayState(); | |||||
| void ChaletPowerRelayKickTimer(); | |||||
| #endif /* CHALETPOWERRELAY_H */ | |||||
| @@ -0,0 +1,130 @@ | |||||
| #include "BoardCfg.h" | |||||
| int InitBoard() | |||||
| { | |||||
| HEARTBEAT_LED_1_PIN_DIR = PIN_OUTPUT; | |||||
| HEARTBEAT_LED_2_PIN_DIR = PIN_OUTPUT; | |||||
| HEARTBEAT_LED_2_PIN = LED_OFF; | |||||
| HEARTBEAT_LED_1_PIN = LED_ON; | |||||
| LORA_ACTIVITY_LED_PIN_DIR = PIN_OUTPUT; | |||||
| LORA_ACTIVITY_LED_PIN = LED_OFF; | |||||
| // GP_DEBUG_1_PIN_DIR = PIN_OUTPUT; | |||||
| // GP_DEBUG_1_PIN = 0; | |||||
| // GP_DEBUG_2_PIN_DIR = PIN_OUTPUT; | |||||
| // GP_DEBUG_2_PIN = 0; | |||||
| SPI_SDI_PIN_DIR = PIN_INPUT; | |||||
| SD_SPI_SS_PIN_DIR = PIN_OUTPUT; | |||||
| SPI_SDO_PIN_DIR = PIN_OUTPUT; | |||||
| SPI_SCK_PIN_DIR = PIN_OUTPUT; | |||||
| FLASH_SS_PIN_DIR = PIN_OUTPUT; | |||||
| FLASH_SS_PIN = 1; | |||||
| //Wifi (WINC1500 module) | |||||
| WIFI_SPI_SS_PIN_DIR = PIN_OUTPUT; | |||||
| WIFI_SPI_SS_PIN = 1; | |||||
| WIFI_IRQ_PIN_DIR = PIN_INPUT; | |||||
| // WIFI_SPI_CFG_PIN_DIR = PIN_OUTPUT; | |||||
| // WIFI_SPI_CFG_PIN = 0; | |||||
| WIFI_CHP_EN_PIN_DIR = PIN_OUTPUT; | |||||
| WIFI_CHP_EN_PIN = 0; | |||||
| WIFI_CHP_RST_PIN_DIR = PIN_OUTPUT; | |||||
| WIFI_CHP_RST_PIN = 0; | |||||
| // DOOR_PAD_D0_PIN_DIR = PIN_INPUT; | |||||
| // DOOR_PAD_D1_PIN_DIR | |||||
| // DOOR_PAD_D1_PIN | |||||
| //Wifi chip IRQ | |||||
| IEC0bits.INT0IE = 0; | |||||
| IFS0bits.INT0IF = 0; | |||||
| INTCONbits.INT0EP = 0; //Falling edge | |||||
| IPC0bits.INT0IP = 3; | |||||
| IPC0bits.INT0IS = 0; | |||||
| IEC0bits.INT0IE = 1; | |||||
| //Wifi chip SPI | |||||
| SPI2CON = 0; | |||||
| SPI2CONbits.MSTEN = 1; | |||||
| SPI2CONbits.CKE = 1; | |||||
| SPI2CONbits.SMP = 0; | |||||
| SPI2CONbits.CKP = 0; | |||||
| SPI2BRG = SPICalculateBRG(PERIPHERAL_FREQ, 1000000); | |||||
| // SPI2BRG = SPICalculateBRG(PERIPHERAL_FREQ, 50000); | |||||
| SPI2CONbits.ON = 1; | |||||
| //Chalet inverter power relay | |||||
| POWER_RELAY_ON_PIN_DIR = PIN_OUTPUT; | |||||
| POWER_RELAY_OFF_PIN_DIR = PIN_OUTPUT; | |||||
| POWER_RELAY_ON_PIN = 0; | |||||
| POWER_RELAY_OFF_PIN = 0; | |||||
| //Harakiri relay | |||||
| HARAKIRI_RELAY_ON_PIN_DIR = PIN_OUTPUT; | |||||
| HARAKIRI_RELAY_ON_PIN= 0; | |||||
| //12V presence detection input | |||||
| CHALET_12V_PRESENCE_PIN_DIR = PIN_INPUT; | |||||
| //Battery voltage measurement (analog input) | |||||
| BATTERY_VOLTAGE_ANALOG_PIN_DIR = PIN_INPUT; | |||||
| IEC0bits.INT1IE = 0; | |||||
| IFS0bits.INT1IF = 0; | |||||
| INTCONbits.INT1EP = 1; //Rising edge | |||||
| IPC1bits.INT1IP = 2; | |||||
| IPC1bits.INT1IS = 1; | |||||
| // IEC0bits.INT1IE = 1; | |||||
| // OC3CON = 0; | |||||
| // OC3R = 0; | |||||
| // OC3RS = 2000; //50% PWM | |||||
| // OC3CONbits.OCTSEL = 0; | |||||
| // OC3CONbits.OCM = 0b110; //PWM mode, no fault protection | |||||
| //#ifdef __32MX330F064H__ | |||||
| // RPD2Rbits.RPD2R = 0b1011; //RD2 peripheral selection = OC3 | |||||
| //#endif | |||||
| // | |||||
| // T2CONbits.TON = 0; // Disable Timer | |||||
| // // T2CONbits.TCS = 0; // Select internal instruction cycle clock | |||||
| // T2CONbits.TGATE = 0; // Disable Gated Timer mode | |||||
| // T2CONbits.TCKPS = 0b011; // Select 1:1 Prescaler | |||||
| // TMR2 = 0x00; // Clear timer register | |||||
| // | |||||
| // | |||||
| // IPC2bits.T2IP = 0x01; // Set Timer 2 Interrupt Priority Level | |||||
| // IFS0bits.T2IF = 0; // Clear Timer 2 Interrupt Flag | |||||
| // IEC0bits.T2IE = 0; // Disable Timer 2 interrupt | |||||
| // T2CONbits.TON = 1; // Start Timer | |||||
| // | |||||
| // OC3CONbits.ON = 1; | |||||
| //ADC test | |||||
| AD1PCFG = 0xFFFF; //Sart with I/O pins configured as digital I/O | |||||
| AD1PCFGbits.PCFG1 = 0; | |||||
| TRISBbits.TRISB1 = PIN_INPUT; | |||||
| AD1CON1 = 0; | |||||
| AD1CON2 = 0; | |||||
| AD1CON3 = 0; | |||||
| AD1CHS = 0; | |||||
| AD1CHSbits.CH0SA = 1; //AN1 | |||||
| AD1CON3bits.ADCS = 0xF0; | |||||
| AD1CON3bits.SAMC = 0x01; | |||||
| AD1CON1bits.ON = 1; | |||||
| AD1CON1bits.SAMP = 1; | |||||
| return RET_OK; | |||||
| } | |||||
| @@ -0,0 +1,172 @@ | |||||
| #include "BoardCfg.h" | |||||
| int InitBoard() | |||||
| { | |||||
| DDPCONbits.JTAGEN = 0; | |||||
| HEARTBEAT_LED_1_PIN_DIR = PIN_OUTPUT; | |||||
| HEARTBEAT_LED_2_PIN_DIR = PIN_OUTPUT; | |||||
| HEARTBEAT_LED_2_PIN = LED_OFF; | |||||
| HEARTBEAT_LED_1_PIN = LED_ON; | |||||
| // LORA_ACTIVITY_LED_PIN_DIR = PIN_OUTPUT; | |||||
| // LORA_ACTIVITY_LED_PIN = LED_OFF; | |||||
| // GP_DEBUG_1_PIN_DIR = PIN_OUTPUT; | |||||
| // GP_DEBUG_1_PIN = 0; | |||||
| // GP_DEBUG_2_PIN_DIR = PIN_OUTPUT; | |||||
| // GP_DEBUG_2_PIN = 0; | |||||
| SPI_SDI_PIN_DIR = PIN_INPUT; | |||||
| SD_SPI_SS_PIN_DIR = PIN_OUTPUT; | |||||
| SPI_SDO_PIN_DIR = PIN_OUTPUT; | |||||
| SPI_SCK_PIN_DIR = PIN_OUTPUT; | |||||
| //////////////// SPI FLASH ////////////////// | |||||
| FLASH_SS_PIN_DIR = PIN_OUTPUT; | |||||
| FLASH_SS_PIN = 1; | |||||
| /////////////////////////// WIFI /////////////////// | |||||
| //Wifi (WINC1500 module) | |||||
| WIFI_SPI_SS_PIN_DIR = PIN_OUTPUT; | |||||
| WIFI_SPI_SS_PIN = 1; | |||||
| WIFI_IRQ_PIN_DIR = PIN_INPUT; | |||||
| // WIFI_SPI_CFG_PIN_DIR = PIN_OUTPUT; | |||||
| // WIFI_SPI_CFG_PIN = 0; | |||||
| WIFI_CHP_EN_PIN_DIR = PIN_OUTPUT; | |||||
| WIFI_CHP_EN_PIN = 0; | |||||
| WIFI_CHP_RST_PIN_DIR = PIN_OUTPUT; | |||||
| WIFI_CHP_RST_PIN = 0; | |||||
| //Wifi chip IRQ | |||||
| IEC0bits.INT0IE = 0; | |||||
| IFS0bits.INT0IF = 0; | |||||
| INTCONbits.INT0EP = 0; //Falling edge | |||||
| IPC0bits.INT0IP = 3; | |||||
| IPC0bits.INT0IS = 0; | |||||
| IEC0bits.INT0IE = 1; | |||||
| //Wifi chip SPI | |||||
| SPI2CON = 0; | |||||
| SPI2CONbits.MSTEN = 1; | |||||
| SPI2CONbits.CKE = 1; | |||||
| SPI2CONbits.SMP = 0; | |||||
| SPI2CONbits.CKP = 0; | |||||
| SPI2BRG = SPICalculateBRG(PERIPHERAL_FREQ, 1000000); | |||||
| // SPI2BRG = SPICalculateBRG(PERIPHERAL_FREQ, 50000); | |||||
| SPI2CONbits.ON = 1; | |||||
| //ADC Config | |||||
| AD1PCFG = 0xFFFF; //Sart with I/O pins configured as digital I/O | |||||
| AD1PCFGbits.PCFG1 = 0; | |||||
| AD1PCFGbits.PCFG2 = 0; | |||||
| // TRISBbits.TRISB1 = PIN_INPUT; | |||||
| //TRISBbits.TRISB2 = PIN_INPUT; | |||||
| AD1CON1 = 0; | |||||
| AD1CON2 = 0; | |||||
| AD1CON3 = 0; | |||||
| // AD1CHS = 0; | |||||
| // AD1CHSbits.CH0SA = 1; //AN1 | |||||
| // AD1CON3bits.ADCS = 0xF0; | |||||
| // AD1CON3bits.SAMC = 0x01; | |||||
| // AD1CON1bits.ON = 1; | |||||
| // AD1CON1bits.SAMP = 1; | |||||
| ONBOARD_LED1_PIN_DIR = PIN_OUTPUT; | |||||
| ONBOARD_LED1_PIN = LED_OFF; | |||||
| ONBOARD_LED2_PIN_DIR = PIN_OUTPUT; | |||||
| ONBOARD_LED2_PIN = LED_OFF; | |||||
| ONBOARD_LED3_PIN_DIR = PIN_OUTPUT; | |||||
| ONBOARD_LED3_PIN = LED_OFF; | |||||
| ONBOARD_LED7_PIN_DIR = PIN_OUTPUT; | |||||
| ONBOARD_LED7_PIN = LED_OFF; | |||||
| PUSH_BUTTON_LED1_PIN_DIR = PIN_OUTPUT; | |||||
| PUSH_BUTTON_LED1_PIN = LED_OFF; | |||||
| PUSH_BUTTON_LED2_PIN_DIR = PIN_OUTPUT; | |||||
| PUSH_BUTTON_LED2_PIN = LED_OFF; | |||||
| PUSH_BUTTON_LED3_PIN_DIR = PIN_OUTPUT; | |||||
| PUSH_BUTTON_LED3_PIN = LED_OFF; | |||||
| PUSH_BUTTON_LED4_PIN_DIR = PIN_OUTPUT; | |||||
| PUSH_BUTTON_LED4_PIN = LED_OFF; | |||||
| PUSH_BUTTON_LED5_PIN_DIR = PIN_OUTPUT; | |||||
| PUSH_BUTTON_LED5_PIN = LED_OFF; | |||||
| PUSH_BUTTON_LED6_PIN_DIR = PIN_OUTPUT; | |||||
| PUSH_BUTTON_LED6_PIN = LED_OFF; | |||||
| PUSH_BUTTON_LED7_PIN_DIR = PIN_OUTPUT; | |||||
| PUSH_BUTTON_LED7_PIN = LED_OFF; | |||||
| PUSH_BUTTON_INPUT1_PIN_DIR = PIN_INPUT; | |||||
| PUSH_BUTTON_INPUT2_PIN_DIR = PIN_INPUT; | |||||
| PUSH_BUTTON_INPUT3_PIN_DIR = PIN_INPUT; | |||||
| PUSH_BUTTON_INPUT4_PIN_DIR = PIN_INPUT; | |||||
| PUSH_BUTTON_INPUT5_PIN_DIR = PIN_INPUT; | |||||
| PUSH_BUTTON_INPUT6_PIN_DIR = PIN_INPUT; | |||||
| PUSH_BUTTON_INPUT7_PIN_DIR = PIN_INPUT; | |||||
| VU1_DAC_SYNC_PIN_DIR = PIN_OUTPUT; | |||||
| VU1_DAC_SYNC_PIN = 1; | |||||
| VU1_BACKLIGHT_PIN_DIR = PIN_OUTPUT; | |||||
| VU1_BACKLIGHT_PIN = LED_OFF; | |||||
| VU2_DAC_SYNC_PIN_DIR = PIN_OUTPUT; | |||||
| VU2_DAC_SYNC_PIN = 1; | |||||
| VU2_BACKLIGHT_PIN_DIR = PIN_OUTPUT; | |||||
| VU2_BACKLIGHT_PIN = LED_OFF; | |||||
| BUREAU_VOL_POT_CW_PIN_DIR = PIN_INPUT; | |||||
| BUREAU_VOL_POT_CCW_PIN_DIR = PIN_INPUT; | |||||
| BUREAU_VOL_POT_CCW_PIN_DIR = PIN_INPUT; | |||||
| BUREAU_VOL_POT_CCW_PIN_DIR = PIN_INPUT; | |||||
| ////// MISC UNUSED STUFF /////////// | |||||
| // IEC0bits.INT1IE = 0; | |||||
| // IFS0bits.INT1IF = 0; | |||||
| // INTCONbits.INT1EP = 1; //Rising edge | |||||
| // IPC1bits.INT1IP = 2; | |||||
| // IPC1bits.INT1IS = 1; | |||||
| // IEC0bits.INT1IE = 1; | |||||
| // OC3CON = 0; | |||||
| // OC3R = 0; | |||||
| // OC3RS = 2000; //50% PWM | |||||
| // OC3CONbits.OCTSEL = 0; | |||||
| // OC3CONbits.OCM = 0b110; //PWM mode, no fault protection | |||||
| //#ifdef __32MX330F064H__ | |||||
| // RPD2Rbits.RPD2R = 0b1011; //RD2 peripheral selection = OC3 | |||||
| //#endif | |||||
| // | |||||
| // T2CONbits.TON = 0; // Disable Timer | |||||
| // // T2CONbits.TCS = 0; // Select internal instruction cycle clock | |||||
| // T2CONbits.TGATE = 0; // Disable Gated Timer mode | |||||
| // T2CONbits.TCKPS = 0b011; // Select 1:1 Prescaler | |||||
| // TMR2 = 0x00; // Clear timer register | |||||
| // | |||||
| // | |||||
| // IPC2bits.T2IP = 0x01; // Set Timer 2 Interrupt Priority Level | |||||
| // IFS0bits.T2IF = 0; // Clear Timer 2 Interrupt Flag | |||||
| // IEC0bits.T2IE = 0; // Disable Timer 2 interrupt | |||||
| // T2CONbits.TON = 1; // Start Timer | |||||
| // | |||||
| // OC3CONbits.ON = 1; | |||||
| RTCCONbits.ON = 1; | |||||
| return RET_OK; | |||||
| } | |||||
| @@ -0,0 +1,15 @@ | |||||
| #include "define.h" | |||||
| #include "CurrentSensor.h" | |||||
| #include "ina219.h" | |||||
| int CurrentSensorInit() | |||||
| { | |||||
| ina219SetCalibration_16V_200mA(); | |||||
| return RET_OK; | |||||
| } | |||||
| int GetSolarPanelCurrent() | |||||
| { | |||||
| return ina219GetCurrent(); | |||||
| } | |||||
| @@ -0,0 +1,16 @@ | |||||
| /* | |||||
| * File: SPI.h | |||||
| * Author: JF | |||||
| * | |||||
| * Created on December 2, 2018, 3:36 PM | |||||
| */ | |||||
| #ifndef CURRENTSENSOR_H | |||||
| #define CURRENTSENSOR_H | |||||
| int CurrentSensorInit(); | |||||
| int GetSolarPanelCurrent(); | |||||
| #endif /* CURRENTSENSOR_H */ | |||||
| @@ -0,0 +1,42 @@ | |||||
| /******************************************************************************* | |||||
| * * | |||||
| * Copyright 2010 Rheinmetall Canada Inc. * | |||||
| * * | |||||
| * No part of this document may be reproduced, stored in * | |||||
| * a retrieval system, or transmitted, in any form or by any means, * | |||||
| * electronic, mechanical, photocopying, recording, or otherwise, * | |||||
| * without the prior written permission of Rheinmetall Canada Inc. * | |||||
| * * | |||||
| *******************************************************************************/ | |||||
| /* | |||||
| Description: | |||||
| This is a template file for standard C code file. | |||||
| */ | |||||
| /* ************************************************************************** */ | |||||
| /* ¤Revision: | |||||
| 000 20100616 JFM, | |||||
| Original version. | |||||
| ### YYYYMMDD Initial, Bug Identification | |||||
| Change description. | |||||
| */ | |||||
| /* ************************************************************************** */ | |||||
| /* Includes */ | |||||
| #include "DigitalIO.h" | |||||
| //#include "define.h" | |||||
| //----------------------------------------------------------------------------- | |||||
| //----------------------------------------------------------------------------- | |||||
| void InitDigitalIO(void) | |||||
| { | |||||
| } | |||||
| //EOF | |||||
| @@ -0,0 +1,36 @@ | |||||
| /******************************************************************************* | |||||
| * * | |||||
| * Copyright 2010 Rheinmetall Canada Inc. * | |||||
| * * | |||||
| * No part of this document may be reproduced, stored in * | |||||
| * a retrieval system, or transmitted, in any form or by any means, * | |||||
| * electronic, mechanical, photocopying, recording, or otherwise, * | |||||
| * without the prior written permission of Rheinmetall Canada Inc. * | |||||
| * * | |||||
| *******************************************************************************/ | |||||
| /* | |||||
| Description: | |||||
| This is a template file for standard C header file. | |||||
| */ | |||||
| /* ************************************************************************** */ | |||||
| /* ¤Revision: | |||||
| 000 20100616 JFM, | |||||
| Original version. | |||||
| ### YYYYMMDD Initial, Bug Identification | |||||
| Change description. | |||||
| */ | |||||
| #ifndef DIGITAL_IO_H | |||||
| #define DIGITAL_IO_H | |||||
| #include "BoardCfg.h" | |||||
| #endif | |||||
| //EOF | |||||
| @@ -0,0 +1,225 @@ | |||||
| /*-----------------------------------------------------------------------*/ | |||||
| /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2016 */ | |||||
| /*-----------------------------------------------------------------------*/ | |||||
| /* If a working storage control module is available, it should be */ | |||||
| /* attached to the FatFs via a glue function rather than modifying it. */ | |||||
| /* This is an example of glue functions to attach various exsisting */ | |||||
| /* storage control modules to the FatFs module with a defined API. */ | |||||
| /*-----------------------------------------------------------------------*/ | |||||
| #include "diskio.h" /* FatFs lower layer API */ | |||||
| /* Definitions of physical drive number for each drive */ | |||||
| #define DEV_RAM 1 /* Example: Map Ramdisk to physical drive 0 */ | |||||
| #define DEV_MMC 0 /* Example: Map MMC/SD card to physical drive 1 */ | |||||
| #define DEV_USB 2 /* Example: Map USB MSD to physical drive 2 */ | |||||
| /*-----------------------------------------------------------------------*/ | |||||
| /* Get Drive Status */ | |||||
| /*-----------------------------------------------------------------------*/ | |||||
| DSTATUS disk_status ( | |||||
| BYTE pdrv /* Physical drive nmuber to identify the drive */ | |||||
| ) | |||||
| { | |||||
| DSTATUS stat; | |||||
| int result; | |||||
| switch (pdrv) { | |||||
| case DEV_RAM : | |||||
| // result = RAM_disk_status(); | |||||
| // translate the reslut code here | |||||
| return stat; | |||||
| case DEV_MMC : | |||||
| // result = MMC_disk_status(); | |||||
| // translate the reslut code here | |||||
| return stat; | |||||
| case DEV_USB : | |||||
| // result = USB_disk_status(); | |||||
| // translate the reslut code here | |||||
| return stat; | |||||
| } | |||||
| return STA_NOINIT; | |||||
| } | |||||
| /*-----------------------------------------------------------------------*/ | |||||
| /* Inidialize a Drive */ | |||||
| /*-----------------------------------------------------------------------*/ | |||||
| DSTATUS disk_initialize ( | |||||
| BYTE pdrv /* Physical drive nmuber to identify the drive */ | |||||
| ) | |||||
| { | |||||
| DSTATUS stat; | |||||
| int result; | |||||
| switch (pdrv) { | |||||
| case DEV_RAM : | |||||
| //result = RAM_disk_initialize(); | |||||
| // translate the reslut code here | |||||
| return stat; | |||||
| case DEV_MMC : | |||||
| // result = MMC_disk_initialize(); | |||||
| // translate the reslut code here | |||||
| return stat; | |||||
| case DEV_USB : | |||||
| // result = USB_disk_initialize(); | |||||
| // translate the reslut code here | |||||
| return stat; | |||||
| } | |||||
| return STA_NOINIT; | |||||
| } | |||||
| /*-----------------------------------------------------------------------*/ | |||||
| /* Read Sector(s) */ | |||||
| /*-----------------------------------------------------------------------*/ | |||||
| DRESULT disk_read ( | |||||
| BYTE pdrv, /* Physical drive nmuber to identify the drive */ | |||||
| BYTE *buff, /* Data buffer to store read data */ | |||||
| DWORD sector, /* Start sector in LBA */ | |||||
| UINT count /* Number of sectors to read */ | |||||
| ) | |||||
| { | |||||
| DRESULT res; | |||||
| int result; | |||||
| switch (pdrv) { | |||||
| case DEV_RAM : | |||||
| // translate the arguments here | |||||
| // result = RAM_disk_read(buff, sector, count); | |||||
| // translate the reslut code here | |||||
| return res; | |||||
| case DEV_MMC : | |||||
| // translate the arguments here | |||||
| // result = MMC_disk_read(buff, sector, count); | |||||
| // translate the reslut code here | |||||
| return res; | |||||
| case DEV_USB : | |||||
| // translate the arguments here | |||||
| // result = USB_disk_read(buff, sector, count); | |||||
| // translate the reslut code here | |||||
| return res; | |||||
| } | |||||
| return RES_PARERR; | |||||
| } | |||||
| /*-----------------------------------------------------------------------*/ | |||||
| /* Write Sector(s) */ | |||||
| /*-----------------------------------------------------------------------*/ | |||||
| DRESULT disk_write ( | |||||
| BYTE pdrv, /* Physical drive nmuber to identify the drive */ | |||||
| const BYTE *buff, /* Data to be written */ | |||||
| DWORD sector, /* Start sector in LBA */ | |||||
| UINT count /* Number of sectors to write */ | |||||
| ) | |||||
| { | |||||
| DRESULT res; | |||||
| int result; | |||||
| switch (pdrv) { | |||||
| case DEV_RAM : | |||||
| // translate the arguments here | |||||
| // result = RAM_disk_write(buff, sector, count); | |||||
| // translate the reslut code here | |||||
| return res; | |||||
| case DEV_MMC : | |||||
| // translate the arguments here | |||||
| // result = MMC_disk_write(buff, sector, count); | |||||
| // translate the reslut code here | |||||
| return res; | |||||
| case DEV_USB : | |||||
| // translate the arguments here | |||||
| // result = USB_disk_write(buff, sector, count); | |||||
| // translate the reslut code here | |||||
| return res; | |||||
| } | |||||
| return RES_PARERR; | |||||
| } | |||||
| /*-----------------------------------------------------------------------*/ | |||||
| /* Miscellaneous Functions */ | |||||
| /*-----------------------------------------------------------------------*/ | |||||
| DRESULT disk_ioctl ( | |||||
| BYTE pdrv, /* Physical drive nmuber (0..) */ | |||||
| BYTE cmd, /* Control code */ | |||||
| void *buff /* Buffer to send/receive control data */ | |||||
| ) | |||||
| { | |||||
| DRESULT res; | |||||
| int result; | |||||
| switch (pdrv) { | |||||
| case DEV_RAM : | |||||
| // Process of the command for the RAM drive | |||||
| return res; | |||||
| case DEV_MMC : | |||||
| // Process of the command for the MMC/SD card | |||||
| return res; | |||||
| case DEV_USB : | |||||
| // Process of the command the USB drive | |||||
| return res; | |||||
| } | |||||
| return RES_PARERR; | |||||
| } | |||||
| @@ -0,0 +1,101 @@ | |||||
| /*-----------------------------------------------------------------------/ | |||||
| / Low level disk interface modlue include file (C)ChaN, 2014 / | |||||
| /-----------------------------------------------------------------------*/ | |||||
| #ifndef _DISKIO_DEFINED | |||||
| #define _DISKIO_DEFINED | |||||
| #ifdef __cplusplus | |||||
| extern "C" { | |||||
| #endif | |||||
| #include "integer.h" | |||||
| #define _USE_WRITE 1 | |||||
| #define _USE_IOCTL 1 | |||||
| #define _USE | |||||
| /* Status of Disk Functions */ | |||||
| typedef BYTE DSTATUS; | |||||
| /* Results of Disk Functions */ | |||||
| typedef enum { | |||||
| RES_OK = 0, /* 0: Successful */ | |||||
| RES_ERROR, /* 1: R/W Error */ | |||||
| RES_WRPRT, /* 2: Write Protected */ | |||||
| RES_NOTRDY, /* 3: Not Ready */ | |||||
| RES_PARERR /* 4: Invalid Parameter */ | |||||
| } DRESULT; | |||||
| /*---------------------------------------*/ | |||||
| /* Prototypes for disk control functions */ | |||||
| DSTATUS disk_initialize (BYTE pdrv); | |||||
| DSTATUS disk_status (BYTE pdrv); | |||||
| DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); | |||||
| DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); | |||||
| DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); | |||||
| void disk_timerproc(void); | |||||
| /* Disk Status Bits (DSTATUS) */ | |||||
| #define STA_NOINIT 0x01 /* Drive not initialized */ | |||||
| #define STA_NODISK 0x02 /* No medium in the drive */ | |||||
| #define STA_PROTECT 0x04 /* Write protected */ | |||||
| /* Command code for disk_ioctrl fucntion */ | |||||
| /* Generic command (Used by FatFs) */ | |||||
| #define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ | |||||
| #define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ | |||||
| #define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ | |||||
| #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ | |||||
| #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ | |||||
| ///* Generic command (Not used by FatFs) */ | |||||
| //#define CTRL_POWER 5 /* Get/Set power status */ | |||||
| //#define CTRL_LOCK 6 /* Lock/Unlock media removal */ | |||||
| //#define CTRL_EJECT 7 /* Eject media */ | |||||
| //#define CTRL_FORMAT 8 /* Create physical format on the media */ | |||||
| /* Generic command (Not used by FatFs) */ | |||||
| #define CTRL_FORMAT 5 /* Create physical format on the media */ | |||||
| #define CTRL_POWER_IDLE 6 /* Put the device idle state */ | |||||
| #define CTRL_POWER_OFF 7 /* Put the device off state */ | |||||
| #define CTRL_LOCK 8 /* Lock media removal */ | |||||
| #define CTRL_UNLOCK 9 /* Unlock media removal */ | |||||
| #define CTRL_EJECT 10 /* Eject media */ | |||||
| /* MMC/SDC specific ioctl command */ | |||||
| #define MMC_GET_TYPE 10 /* Get card type */ | |||||
| #define MMC_GET_CSD 11 /* Get CSD */ | |||||
| #define MMC_GET_CID 12 /* Get CID */ | |||||
| #define MMC_GET_OCR 13 /* Get OCR */ | |||||
| #define MMC_GET_SDSTAT 14 /* Get SD status */ | |||||
| #define ISDIO_READ 55 /* Read data form SD iSDIO register */ | |||||
| #define ISDIO_WRITE 56 /* Write data to SD iSDIO register */ | |||||
| #define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */ | |||||
| /* MMC card type flags (MMC_GET_TYPE) */ | |||||
| #define CT_MMC 0x01 /* MMC ver 3 */ | |||||
| #define CT_SD1 0x02 /* SD ver 1 */ | |||||
| #define CT_SD2 0x04 /* SD ver 2 */ | |||||
| #define CT_SDC (CT_SD1|CT_SD2) /* SD */ | |||||
| #define CT_BLOCK 0x08 /* Block addressing */ | |||||
| /* ATA/CF specific ioctl command */ | |||||
| #define ATA_GET_REV 20 /* Get F/W revision */ | |||||
| #define ATA_GET_MODEL 21 /* Get model name */ | |||||
| #define ATA_GET_SN 22 /* Get serial number */ | |||||
| #ifdef __cplusplus | |||||
| } | |||||
| #endif | |||||
| #endif | |||||
| @@ -0,0 +1,366 @@ | |||||
| /*----------------------------------------------------------------------------/ | |||||
| / FatFs - Generic FAT Filesystem module R0.13a / | |||||
| /-----------------------------------------------------------------------------/ | |||||
| / | |||||
| / Copyright (C) 2017, ChaN, all right reserved. | |||||
| / | |||||
| / FatFs module is an open source software. Redistribution and use of FatFs in | |||||
| / source and binary forms, with or without modification, are permitted provided | |||||
| / that the following condition is met: | |||||
| / 1. Redistributions of source code must retain the above copyright notice, | |||||
| / this condition and the following disclaimer. | |||||
| / | |||||
| / This software is provided by the copyright holder and contributors "AS IS" | |||||
| / and any warranties related to this software are DISCLAIMED. | |||||
| / The copyright owner or contributors be NOT LIABLE for any damages caused | |||||
| / by use of this software. | |||||
| / | |||||
| /----------------------------------------------------------------------------*/ | |||||
| #ifndef FF_DEFINED | |||||
| #define FF_DEFINED 89352 /* Revision ID */ | |||||
| #ifdef __cplusplus | |||||
| extern "C" { | |||||
| #endif | |||||
| #include "integer.h" /* Basic integer types */ | |||||
| #include "ffconf.h" /* FatFs configuration options */ | |||||
| #if FF_DEFINED != FFCONF_DEF | |||||
| #error Wrong configuration file (ffconf.h). | |||||
| #endif | |||||
| /* Definitions of volume management */ | |||||
| #if FF_MULTI_PARTITION /* Multiple partition configuration */ | |||||
| typedef struct { | |||||
| BYTE pd; /* Physical drive number */ | |||||
| BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */ | |||||
| } PARTITION; | |||||
| extern PARTITION VolToPart[]; /* Volume - Partition resolution table */ | |||||
| #endif | |||||
| /* Type of path name strings on FatFs API */ | |||||
| #ifndef _INC_TCHAR | |||||
| #define _INC_TCHAR | |||||
| #if FF_USE_LFN && FF_LFN_UNICODE == 1 /* Unicode in UTF-16 encoding */ | |||||
| typedef WCHAR TCHAR; | |||||
| #define _T(x) L ## x | |||||
| #define _TEXT(x) L ## x | |||||
| #elif FF_USE_LFN && FF_LFN_UNICODE == 2 /* Unicode in UTF-8 encoding */ | |||||
| typedef char TCHAR; | |||||
| #define _T(x) u8 ## x | |||||
| #define _TEXT(x) u8 ## x | |||||
| #elif FF_USE_LFN && (FF_LFN_UNICODE < 0 || FF_LFN_UNICODE > 2) | |||||
| #error Wrong FF_LFN_UNICODE setting | |||||
| #else /* ANSI/OEM code in SBCS/DBCS */ | |||||
| typedef char TCHAR; | |||||
| #define _T(x) x | |||||
| #define _TEXT(x) x | |||||
| #endif | |||||
| #endif | |||||
| /* Type of file size variables */ | |||||
| #if FF_FS_EXFAT | |||||
| typedef QWORD FSIZE_t; | |||||
| #else | |||||
| typedef DWORD FSIZE_t; | |||||
| #endif | |||||
| /* Filesystem object structure (FATFS) */ | |||||
| typedef struct { | |||||
| BYTE fs_type; /* Filesystem type (0:N/A) */ | |||||
| BYTE pdrv; /* Physical drive number */ | |||||
| BYTE n_fats; /* Number of FATs (1 or 2) */ | |||||
| BYTE wflag; /* win[] flag (b0:dirty) */ | |||||
| BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ | |||||
| WORD id; /* Volume mount ID */ | |||||
| WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ | |||||
| WORD csize; /* Cluster size [sectors] */ | |||||
| #if FF_MAX_SS != FF_MIN_SS | |||||
| WORD ssize; /* Sector size (512, 1024, 2048 or 4096) */ | |||||
| #endif | |||||
| #if FF_USE_LFN | |||||
| WCHAR* lfnbuf; /* LFN working buffer */ | |||||
| #endif | |||||
| #if FF_FS_EXFAT | |||||
| BYTE* dirbuf; /* Directory entry block scratchpad buffer for exFAT */ | |||||
| #endif | |||||
| #if FF_FS_REENTRANT | |||||
| FF_SYNC_t sobj; /* Identifier of sync object */ | |||||
| #endif | |||||
| #if !FF_FS_READONLY | |||||
| DWORD last_clst; /* Last allocated cluster */ | |||||
| DWORD free_clst; /* Number of free clusters */ | |||||
| #endif | |||||
| #if FF_FS_RPATH | |||||
| DWORD cdir; /* Current directory start cluster (0:root) */ | |||||
| #if FF_FS_EXFAT | |||||
| DWORD cdc_scl; /* Containing directory start cluster (invalid when cdir is 0) */ | |||||
| DWORD cdc_size; /* b31-b8:Size of containing directory, b7-b0: Chain status */ | |||||
| DWORD cdc_ofs; /* Offset in the containing directory (invalid when cdir is 0) */ | |||||
| #endif | |||||
| #endif | |||||
| DWORD n_fatent; /* Number of FAT entries (number of clusters + 2) */ | |||||
| DWORD fsize; /* Size of an FAT [sectors] */ | |||||
| DWORD volbase; /* Volume base sector */ | |||||
| DWORD fatbase; /* FAT base sector */ | |||||
| DWORD dirbase; /* Root directory base sector/cluster */ | |||||
| DWORD database; /* Data base sector */ | |||||
| DWORD winsect; /* Current sector appearing in the win[] */ | |||||
| BYTE win[FF_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ | |||||
| } FATFS; | |||||
| /* Object ID and allocation information (FFOBJID) */ | |||||
| typedef struct { | |||||
| FATFS* fs; /* Pointer to the hosting volume of this object */ | |||||
| WORD id; /* Hosting volume mount ID */ | |||||
| BYTE attr; /* Object attribute */ | |||||
| BYTE stat; /* Object chain status (b1-0: =0:not contiguous, =2:contiguous, =3:flagmented in this session, b2:sub-directory stretched) */ | |||||
| DWORD sclust; /* Object data start cluster (0:no cluster or root directory) */ | |||||
| FSIZE_t objsize; /* Object size (valid when sclust != 0) */ | |||||
| #if FF_FS_EXFAT | |||||
| DWORD n_cont; /* Size of first fragment - 1 (valid when stat == 3) */ | |||||
| DWORD n_frag; /* Size of last fragment needs to be written to FAT (valid when not zero) */ | |||||
| DWORD c_scl; /* Containing directory start cluster (valid when sclust != 0) */ | |||||
| DWORD c_size; /* b31-b8:Size of containing directory, b7-b0: Chain status (valid when c_scl != 0) */ | |||||
| DWORD c_ofs; /* Offset in the containing directory (valid when file object and sclust != 0) */ | |||||
| #endif | |||||
| #if FF_FS_LOCK | |||||
| UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ | |||||
| #endif | |||||
| } FFOBJID; | |||||
| /* File object structure (FIL) */ | |||||
| typedef struct { | |||||
| FFOBJID obj; /* Object identifier (must be the 1st member to detect invalid object pointer) */ | |||||
| BYTE flag; /* File status flags */ | |||||
| BYTE err; /* Abort flag (error code) */ | |||||
| FSIZE_t fptr; /* File read/write pointer (Zeroed on file open) */ | |||||
| DWORD clust; /* Current cluster of fpter (invalid when fptr is 0) */ | |||||
| DWORD sect; /* Sector number appearing in buf[] (0:invalid) */ | |||||
| #if !FF_FS_READONLY | |||||
| DWORD dir_sect; /* Sector number containing the directory entry (not used at exFAT) */ | |||||
| BYTE* dir_ptr; /* Pointer to the directory entry in the win[] (not used at exFAT) */ | |||||
| #endif | |||||
| #if FF_USE_FASTSEEK | |||||
| DWORD* cltbl; /* Pointer to the cluster link map table (nulled on open, set by application) */ | |||||
| #endif | |||||
| #if !FF_FS_TINY | |||||
| BYTE buf[FF_MAX_SS]; /* File private data read/write window */ | |||||
| #endif | |||||
| } FIL; | |||||
| /* Directory object structure (DIR) */ | |||||
| typedef struct { | |||||
| FFOBJID obj; /* Object identifier */ | |||||
| DWORD dptr; /* Current read/write offset */ | |||||
| DWORD clust; /* Current cluster */ | |||||
| DWORD sect; /* Current sector (0:Read operation has terminated) */ | |||||
| BYTE* dir; /* Pointer to the directory item in the win[] */ | |||||
| BYTE fn[12]; /* SFN (in/out) {body[8],ext[3],status[1]} */ | |||||
| #if FF_USE_LFN | |||||
| DWORD blk_ofs; /* Offset of current entry block being processed (0xFFFFFFFF:Invalid) */ | |||||
| #endif | |||||
| #if FF_USE_FIND | |||||
| const TCHAR* pat; /* Pointer to the name matching pattern */ | |||||
| #endif | |||||
| } DIR; | |||||
| /* File information structure (FILINFO) */ | |||||
| typedef struct { | |||||
| FSIZE_t fsize; /* File size */ | |||||
| WORD fdate; /* Modified date */ | |||||
| WORD ftime; /* Modified time */ | |||||
| BYTE fattrib; /* File attribute */ | |||||
| #if FF_USE_LFN | |||||
| TCHAR altname[FF_SFN_BUF + 1];/* Altenative file name */ | |||||
| TCHAR fname[FF_LFN_BUF + 1]; /* Primary file name */ | |||||
| #else | |||||
| TCHAR fname[12 + 1]; /* File name */ | |||||
| #endif | |||||
| } FILINFO; | |||||
| /* File function return code (FRESULT) */ | |||||
| typedef enum { | |||||
| FR_OK = 0, /* (0) Succeeded */ | |||||
| FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ | |||||
| FR_INT_ERR, /* (2) Assertion failed */ | |||||
| FR_NOT_READY, /* (3) The physical drive cannot work */ | |||||
| FR_NO_FILE, /* (4) Could not find the file */ | |||||
| FR_NO_PATH, /* (5) Could not find the path */ | |||||
| FR_INVALID_NAME, /* (6) The path name format is invalid */ | |||||
| FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ | |||||
| FR_EXIST, /* (8) Access denied due to prohibited access */ | |||||
| FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ | |||||
| FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ | |||||
| FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ | |||||
| FR_NOT_ENABLED, /* (12) The volume has no work area */ | |||||
| FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ | |||||
| FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any problem */ | |||||
| FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ | |||||
| FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ | |||||
| FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ | |||||
| FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > FF_FS_LOCK */ | |||||
| FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ | |||||
| } FRESULT; | |||||
| /*--------------------------------------------------------------*/ | |||||
| /* FatFs module application interface */ | |||||
| FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ | |||||
| FRESULT f_close (FIL* fp); /* Close an open file object */ | |||||
| FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from the file */ | |||||
| FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to the file */ | |||||
| FRESULT f_lseek (FIL* fp, FSIZE_t ofs); /* Move file pointer of the file object */ | |||||
| FRESULT f_truncate (FIL* fp); /* Truncate the file */ | |||||
| FRESULT f_sync (FIL* fp); /* Flush cached data of the writing file */ | |||||
| FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */ | |||||
| FRESULT f_closedir (DIR* dp); /* Close an open directory */ | |||||
| FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */ | |||||
| FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ | |||||
| FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */ | |||||
| FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ | |||||
| FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ | |||||
| FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ | |||||
| FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */ | |||||
| FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of a file/dir */ | |||||
| FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change timestamp of a file/dir */ | |||||
| FRESULT f_chdir (const TCHAR* path); /* Change current directory */ | |||||
| FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ | |||||
| FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ | |||||
| FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ | |||||
| FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */ | |||||
| FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ | |||||
| FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ | |||||
| FRESULT f_expand (FIL* fp, FSIZE_t szf, BYTE opt); /* Allocate a contiguous block to the file */ | |||||
| FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ | |||||
| FRESULT f_mkfs (const TCHAR* path, BYTE opt, DWORD au, void* work, UINT len); /* Create a FAT volume */ | |||||
| FRESULT f_fdisk (BYTE pdrv, const DWORD* szt, void* work); /* Divide a physical drive into some partitions */ | |||||
| FRESULT f_setcp (WORD cp); /* Set current code page */ | |||||
| int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ | |||||
| int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ | |||||
| int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ | |||||
| TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ | |||||
| #define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize)) | |||||
| #define f_error(fp) ((fp)->err) | |||||
| #define f_tell(fp) ((fp)->fptr) | |||||
| #define f_size(fp) ((fp)->obj.objsize) | |||||
| #define f_rewind(fp) f_lseek((fp), 0) | |||||
| #define f_rewinddir(dp) f_readdir((dp), 0) | |||||
| #define f_rmdir(path) f_unlink(path) | |||||
| #define f_unmount(path) f_mount(0, path, 0) | |||||
| #ifndef EOF | |||||
| #define EOF (-1) | |||||
| #endif | |||||
| /*--------------------------------------------------------------*/ | |||||
| /* Additional user defined functions */ | |||||
| /* RTC function */ | |||||
| #if !FF_FS_READONLY && !FF_FS_NORTC | |||||
| DWORD get_fattime (void); | |||||
| #endif | |||||
| /* LFN support functions */ | |||||
| #if FF_USE_LFN >= 1 /* Code conversion (defined in unicode.c) */ | |||||
| WCHAR ff_oem2uni (WCHAR oem, WORD cp); /* OEM code to Unicode conversion */ | |||||
| WCHAR ff_uni2oem (DWORD uni, WORD cp); /* Unicode to OEM code conversion */ | |||||
| DWORD ff_wtoupper (DWORD uni); /* Unicode upper-case conversion */ | |||||
| #endif | |||||
| #if FF_USE_LFN == 3 /* Dynamic memory allocation */ | |||||
| void* ff_memalloc (UINT msize); /* Allocate memory block */ | |||||
| void ff_memfree (void* mblock); /* Free memory block */ | |||||
| #endif | |||||
| /* Sync functions */ | |||||
| #if FF_FS_REENTRANT | |||||
| int ff_cre_syncobj (BYTE vol, FF_SYNC_t* sobj); /* Create a sync object */ | |||||
| int ff_req_grant (FF_SYNC_t sobj); /* Lock sync object */ | |||||
| void ff_rel_grant (FF_SYNC_t sobj); /* Unlock sync object */ | |||||
| int ff_del_syncobj (FF_SYNC_t sobj); /* Delete a sync object */ | |||||
| #endif | |||||
| /*--------------------------------------------------------------*/ | |||||
| /* Flags and offset address */ | |||||
| /* File access mode and open method flags (3rd argument of f_open) */ | |||||
| #define FA_READ 0x01 | |||||
| #define FA_WRITE 0x02 | |||||
| #define FA_OPEN_EXISTING 0x00 | |||||
| #define FA_CREATE_NEW 0x04 | |||||
| #define FA_CREATE_ALWAYS 0x08 | |||||
| #define FA_OPEN_ALWAYS 0x10 | |||||
| #define FA_OPEN_APPEND 0x30 | |||||
| /* Fast seek controls (2nd argument of f_lseek) */ | |||||
| #define CREATE_LINKMAP ((FSIZE_t)0 - 1) | |||||
| /* Format options (2nd argument of f_mkfs) */ | |||||
| #define FM_FAT 0x01 | |||||
| #define FM_FAT32 0x02 | |||||
| #define FM_EXFAT 0x04 | |||||
| #define FM_ANY 0x07 | |||||
| #define FM_SFD 0x08 | |||||
| /* Filesystem type (FATFS.fs_type) */ | |||||
| #define FS_FAT12 1 | |||||
| #define FS_FAT16 2 | |||||
| #define FS_FAT32 3 | |||||
| #define FS_EXFAT 4 | |||||
| /* File attribute bits for directory entry (FILINFO.fattrib) */ | |||||
| #define AM_RDO 0x01 /* Read only */ | |||||
| #define AM_HID 0x02 /* Hidden */ | |||||
| #define AM_SYS 0x04 /* System */ | |||||
| #define AM_DIR 0x10 /* Directory */ | |||||
| #define AM_ARC 0x20 /* Archive */ | |||||
| #ifdef __cplusplus | |||||
| } | |||||
| #endif | |||||
| #endif /* FF_DEFINED */ | |||||