diff --git a/examples/knx-cc1310/CMakeLists.txt b/examples/knx-cc1310/CMakeLists.txt index 41b73a4..87e0f37 100644 --- a/examples/knx-cc1310/CMakeLists.txt +++ b/examples/knx-cc1310/CMakeLists.txt @@ -206,5 +206,5 @@ target_link_libraries(${PROJECT_NAME} c ) -target_compile_definitions(${PROJECT_NAME} PUBLIC -DDeviceFamily_CC13X0 -DRF_SINGLEMODE) +target_compile_definitions(${PROJECT_NAME} PUBLIC -DDeviceFamily_CC13X0 -DRF_SINGLEMODE -DKNX_FLASH_SIZE=2048) diff --git a/src/cc1310_platform.cpp b/src/cc1310_platform.cpp index af15dd1..ce2e760 100644 --- a/src/cc1310_platform.cpp +++ b/src/cc1310_platform.cpp @@ -18,24 +18,34 @@ //#define printf(args...) (SEGGER_RTT_printf(0, args)) #define PRINT_RTT -volatile uint32_t CC1310Platform::msCounter = 0; +static uint8_t serialNumber[6]; +// KNX_FLASH_SIZE shall be defined in CMakeLists.txt for example. It is also used in class Memory in memory.cpp +static uint8_t NVS_buffer[KNX_FLASH_SIZE]; -void CC1310Platform::clk0Fxn(uintptr_t arg0) +static UART_Handle uart; + +static NVS_Handle nvsHandle; + +static ClockP_Handle clk0Handle; +static ClockP_Struct clk0Struct; +static volatile uint32_t msCounter = 0; + +static void clk0Fxn(uintptr_t arg0) { msCounter++; } -void CC1310Platform::msClockInit() +static void msClockInit() { ClockP_Params clkParams; ClockP_Params_init(&clkParams); clkParams.period = 1000/ClockP_tickPeriod; clkParams.startFlag = true; - ClockP_construct(&clk0Struct, (ClockP_Fxn)CC1310Platform::clk0Fxn, 1000/ClockP_tickPeriod, &clkParams); + ClockP_construct(&clk0Struct, (ClockP_Fxn)clk0Fxn, 1000/ClockP_tickPeriod, &clkParams); clk0Handle = ClockP_handle(&clk0Struct); } -void CC1310Platform::InitUART() +static void InitUART() { UART_Params uartParams; UART_Params_init(&uartParams); @@ -52,7 +62,7 @@ void CC1310Platform::InitUART() } } -void CC1310Platform::InitNVS() +static void InitNVS() { NVS_Params nvsParams; NVS_Params_init(&nvsParams); @@ -69,92 +79,6 @@ void CC1310Platform::InitNVS() print("NVS flash sector size: "); println((int)attrs.sectorSize); } -CC1310Platform::CC1310Platform() -{ - // build serialNumber from IEEE MAC Address (MAC is 8 bytes, serialNumber 6 bytes only) - *(uint32_t*)(_serialNumber+2) = HWREG(FCFG1_BASE+FCFG1_O_MAC_15_4_0) ^ HWREG(FCFG1_BASE+FCFG1_O_MAC_15_4_1); // make a 6 byte hash from 8 bytes -} - -CC1310Platform::~CC1310Platform() -{ -} - -void CC1310Platform::init() -{ - // TI Drivers init - // According to SDK docs it is safe to call them AFTER NoRTOS_Start() - // If RTOS is used and multiple thread use the same driver, then the init shall be performed before BIOS_Start() - UART_init(); - NVS_init(); - - // Init UART - InitUART(); - - // tick Period on this controller 10us so we use our own millisecond clock - msClockInit(); - - // Init flash - InitNVS(); -} - -uint8_t* CC1310Platform::getEepromBuffer(uint16_t size) -{ - if(size > EEPROM_EMULATION_SIZE) - { - fatalError(); - } - - NVS_read(nvsHandle, 0, (void *) _NVS_buffer, size); - - for (int i=0; i KNX_FLASH_SIZE) + { + fatalError(); + } + + NVS_read(nvsHandle, 0, (void *) NVS_buffer, size); + + for (int i=0; i