diff --git a/Makefile b/Makefile index 75c128a20..baf6374c2 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,8 @@ warp: cp src/boot/ksdk1.1.0/devSI7021.* build/ksdk1.1/work/demos/Warp/src/ cp src/boot/ksdk1.1.0/devL3GD20H.* build/ksdk1.1/work/demos/Warp/src/ cp src/boot/ksdk1.1.0/devBME680.* build/ksdk1.1/work/demos/Warp/src/ + cp src/boot/ksdk1.1.0/devRF430CL331H.* build/ksdk1.1/work/demos/Warp/src/ + cp src/boot/ksdk1.1.0/devBNO055.* build/ksdk1.1/work/demos/Warp/src/ cp src/boot/ksdk1.1.0/devTCS34725.* build/ksdk1.1/work/demos/Warp/src/ cp src/boot/ksdk1.1.0/devSI4705.* build/ksdk1.1/work/demos/Warp/src/ cp src/boot/ksdk1.1.0/devCCS811.* build/ksdk1.1/work/demos/Warp/src/ @@ -67,6 +69,8 @@ glaux: cp src/boot/ksdk1.1.0/CMakeLists-Glaux.txt build/ksdk1.1/work/demos/Glaux/armgcc/Glaux/CMakeLists.txt cp src/boot/ksdk1.1.0/devIS25xP.* build/ksdk1.1/work/demos/Glaux/src/ cp src/boot/ksdk1.1.0/devRV8803C7.* build/ksdk1.1/work/demos/Glaux/src/ + cp src/boot/ksdk1.1.0/devRF430CL331H.* build/ksdk1.1/work/demos/Glaux/src/ + cp src/boot/ksdk1.1.0/devBNO055.* build/ksdk1.1/work/demos/Glaux/src/ cp src/boot/ksdk1.1.0/devBME680.* build/ksdk1.1/work/demos/Glaux/src/ cp src/boot/ksdk1.1.0/devADXL362.h build/ksdk1.1/work/demos/Glaux/src/ cp src/boot/ksdk1.1.0/devAMG8834.h build/ksdk1.1/work/demos/Glaux/src/ diff --git a/setup.conf b/setup.conf index 2d51f8cfc..5761bacf3 100644 --- a/setup.conf +++ b/setup.conf @@ -1,2 +1,2 @@ JLINKPATH = -ARMGCC_DIR = /usr/ +ARMGCC_DIR = /usr/ \ No newline at end of file diff --git a/src/boot/ksdk1.1.0/CMakeLists-Glaux.txt b/src/boot/ksdk1.1.0/CMakeLists-Glaux.txt index 37b137f2d..52f62db0e 100755 --- a/src/boot/ksdk1.1.0/CMakeLists-Glaux.txt +++ b/src/boot/ksdk1.1.0/CMakeLists-Glaux.txt @@ -94,6 +94,8 @@ ADD_EXECUTABLE(Glaux "${ProjDirPath}/../../src/powermodes.c" "${ProjDirPath}/../../src/devIS25xP.c" "${ProjDirPath}/../../src/devBME680.c" + "${ProjDirPath}/../../src/devBNO055.c" + "${ProjDirPath}/../../src/devRF430CL331H.c" "${ProjDirPath}/../../src/devRV8803C7.c" "${ProjDirPath}/../../src/SEGGER_RTT.c" "${ProjDirPath}/../../src/SEGGER_RTT_printf.c" diff --git a/src/boot/ksdk1.1.0/CMakeLists-Warp.txt b/src/boot/ksdk1.1.0/CMakeLists-Warp.txt index 1508eeac5..b0d33db24 100644 --- a/src/boot/ksdk1.1.0/CMakeLists-Warp.txt +++ b/src/boot/ksdk1.1.0/CMakeLists-Warp.txt @@ -34,7 +34,7 @@ SET(CMAKE_ASM_FLAGS_DEBUG "${CMAKE_ASM_FLAGS_DEBUG} -g -mcpu=cortex-m0plus -mt SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -mcpu=cortex-m0plus -mthumb -MMD -MP -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -Os -mapcs -std=gnu99 -fshort-enums") # DEBUG LD FLAGS -SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -g --specs=nano.specs -lm -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -Os -mthumb -mapcs -Xlinker --gc-sections -Xlinker -static -Xlinker -z -Xlinker muldefs -Xlinker --defsym=__stack_size__=0x300 -Xlinker --defsym=__heap_size__=0x0") +SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -g --specs=nano.specs -lm -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -Os -mthumb -mapcs -Xlinker --gc-sections -Xlinker -static -Xlinker -z -Xlinker muldefs -Xlinker --defsym=__stack_size__=0x200 -Xlinker --defsym=__heap_size__=0x0") # RELEASE ASM FLAGS SET(CMAKE_ASM_FLAGS_RELEASE "${CMAKE_ASM_FLAGS_RELEASE} -mcpu=cortex-m0plus -mthumb -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -Os -mapcs -std=gnu99") @@ -43,7 +43,7 @@ SET(CMAKE_ASM_FLAGS_RELEASE "${CMAKE_ASM_FLAGS_RELEASE} -mcpu=cortex-m0plus -mt SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -mcpu=cortex-m0plus -mthumb -MMD -MP -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -Os -mapcs -std=gnu99 -fshort-enums") # RELEASE LD FLAGS -SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} --specs=nano.specs -lm -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -Os -mthumb -mapcs -Xlinker --gc-sections -Xlinker -static -Xlinker -z -Xlinker muldefs -Xlinker --defsym=__stack_size__=0x300 -Xlinker --defsym=__heap_size__=0x0") +SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} --specs=nano.specs -lm -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -Os -mthumb -mapcs -Xlinker --gc-sections -Xlinker -static -Xlinker -z -Xlinker muldefs -Xlinker --defsym=__stack_size__=0x200 -Xlinker --defsym=__heap_size__=0x0") # ASM MACRO SET(CMAKE_ASM_FLAGS_DEBUG "${CMAKE_ASM_FLAGS_DEBUG} -DDEBUG") @@ -91,6 +91,7 @@ ADD_EXECUTABLE(Warp "${ProjDirPath}/../../src/errstrsEN.c" "${ProjDirPath}/../../src/powermodes.c" "${ProjDirPath}/../../src/devBMX055.c" + "${ProjDirPath}/../../src/devBNO055.c" "${ProjDirPath}/../../src/devADXL362.c" "${ProjDirPath}/../../src/devIS25xP.c" "${ProjDirPath}/../../src/devISL23415.c" diff --git a/src/boot/ksdk1.1.0/boot.c b/src/boot/ksdk1.1.0/boot.c index 53fe89384..544b2b1ed 100644 --- a/src/boot/ksdk1.1.0/boot.c +++ b/src/boot/ksdk1.1.0/boot.c @@ -82,10 +82,12 @@ #include "devMAG3110.h" #include "devL3GD20H.h" #include "devBME680.h" +#include "devBNO055.h" #include "devBMX055.h" #include "devCCS811.h" #include "devHDC1000.h" #include "devRV8803C7.h" +#include "devRF430CL331H.h" #if (WARP_BUILD_ENABLE_DEVADXL362) @@ -121,7 +123,14 @@ #if (WARP_BUILD_ENABLE_DEVMMA8451Q) volatile WarpI2CDeviceState deviceMMA8451QState; #endif - +#if (WARP_BUILD_ENABLE_DEVBNO055) + #include "devBNO055.h" + volatile WarpI2CDeviceState deviceBNO055State; +#endif +#if (WARP_BUILD_ENABLE_DEVRF430CL331H) + #include "devRF430CL331H.h" + volatile WarpI2CDeviceState deviceRF430CL331HState; +#endif #if (WARP_BUILD_ENABLE_DEVLPS25H) #include "devLPS25H.h" volatile WarpI2CDeviceState deviceLPS25HState; @@ -197,9 +206,11 @@ typedef enum kWarpFlashMAG3110BitField = 0b1000000, kWarpFlashL3GD20HBitField = 0b10000000, kWarpFlashBME680BitField = 0b100000000, - kWarpFlashBMX055BitField = 0b1000000000, - kWarpFlashCCS811BitField = 0b10000000000, - kWarpFlashHDC1000BitField = 0b100000000000, + kWarpFlashBNO055BitField = 0b1000000000, + kWarpFlashBMX055BitField = 0b10000000000, + kWarpFlashCCS811BitField = 0b100000000000, + kWarpFlashHDC1000BitField = 0b1000000000000, + kWarpFlashRF430CL331HBitField = 0b10000000000000, kWarpFlashRV8803C7BitField = 0b100000000000000, kWarpFlashNumConfigErrors = 0b1000000000000000, } WarpFlashSensorBitFieldEncoding; @@ -211,6 +222,7 @@ volatile lpuart_user_config_t lpuartUserConfig; volatile lpuart_state_t lpuartState; volatile bool gWarpBooted = false; +volatile bool gWarpSleepMode = false; volatile uint32_t gWarpI2cBaudRateKbps = kWarpDefaultI2cBaudRateKbps; volatile uint32_t gWarpUartBaudRateBps = kWarpDefaultUartBaudRateBps; volatile uint32_t gWarpSpiBaudRateKbps = kWarpDefaultSpiBaudRateKbps; @@ -254,7 +266,7 @@ static void repeatRegisterReadForDeviceAndAddress(WarpSensorDevice warpSens static int char2int(int character); static void activateAllLowPowerSensorModes(bool verbose); static void powerupAllSensors(void); -static uint8_t readHexByte(void); +static uint8_t readHexByte(void); static int read4digits(void); static void writeAllSensorsToFlash(int menuDelayBetweenEachRun, int loopForever); static void printAllSensors(bool printHeadersAndCalibration, bool hexModeFlag, int menuDelayBetweenEachRun, bool loopForever); @@ -407,8 +419,6 @@ callback0(power_manager_notify_struct_t * notify, power_manager_callback_data_t * Derived from KSDK power_manager_demo.c < 0) - { - // while (OSA_TimeGetMsec() - timeAtStart < menuDelayBetweenEachRun) - // { - // } - - // timeAtStart = OSA_TimeGetMsec(); - status = warpSetLowPowerMode(kWarpPowerModeVLPS, menuDelayBetweenEachRun); - if (status != kWarpStatusOK) - { - warpPrint("Failed to put into sleep: %d", status); - } - } + // if (menuDelayBetweenEachRun > 0) + // { + // // while (OSA_TimeGetMsec() - timeAtStart < menuDelayBetweenEachRun) + // // { + // // } + + // // timeAtStart = OSA_TimeGetMsec(); + // status = warpSetLowPowerMode(kWarpPowerModeVLPS, menuDelayBetweenEachRun); + + // if (status != kWarpStatusOK) + // { + // warpPrint("Failed to put into sleep: %d", status); + // } + // } readingCount++; @@ -3488,7 +3566,7 @@ printAllSensors(bool printHeadersAndCalibration, bool hexModeFlag, warpPrint("\r\n\nBME680 Calibration Data: "); for (uint8_t i = 0; i < kWarpSizesBME680CalibrationValuesCount; i++) { - warpPrint("0x%02x", deviceBME680CalibrationValues[i]); + warpPrint("%u", deviceBME680CalibrationValues[i]); if (i < kWarpSizesBME680CalibrationValuesCount - 1) { warpPrint(", "); @@ -3564,7 +3642,12 @@ printAllSensors(bool printHeadersAndCalibration, bool hexModeFlag, #if (WARP_BUILD_ENABLE_DEVBME680) warpPrint(" BME680 Press, BME680 Temp, BME680 Hum,"); #endif - +#if (WARP_BUILD_ENABLE_DEVBNO055) + warpPrint("Accel x,Accel y, Accel z, Mag x, Mag y, Mag z,Gyro x, Gyro y, Gyro z"); +#endif +#if (WARP_BUILD_ENABLE_DEVRF430CL331H) + warpPrint("NFC/RFID"); +#endif #if (WARP_BUILD_ENABLE_DEVBMX055) warpPrint(" BMX055acc x, BMX055acc y, BMX055acc z, BMX055acc Temp,"); warpPrint(" BMX055mag x, BMX055mag y, BMX055mag z, BMX055mag RHALL,"); @@ -3585,7 +3668,6 @@ printAllSensors(bool printHeadersAndCalibration, bool hexModeFlag, warpPrint(" numberOfConfigErrors"); warpPrint("\n\n"); } - do { @@ -3616,7 +3698,9 @@ printAllSensors(bool printHeadersAndCalibration, bool hexModeFlag, #if (WARP_BUILD_ENABLE_DEVBME680) printSensorDataBME680(hexModeFlag); #endif - +#if (WARP_BUILD_ENABLE_DEVBNO055) + printSensorDataBNO055(hexModeFlag); +#endif #if (WARP_BUILD_ENABLE_DEVBMX055) printSensorDataBMX055accel(hexModeFlag); printSensorDataBMX055mag(hexModeFlag); @@ -3636,19 +3720,19 @@ printAllSensors(bool printHeadersAndCalibration, bool hexModeFlag, #endif warpPrint(" %u\n", numberOfConfigErrors); - if (menuDelayBetweenEachRun > 0) - { - // while (OSA_TimeGetMsec() - timeAtStart < menuDelayBetweenEachRun) - // { - // } + // if (menuDelayBetweenEachRun > 0) + // { + // // while (OSA_TimeGetMsec() - timeAtStart < menuDelayBetweenEachRun) + // // { + // // } - // timeAtStart = OSA_TimeGetMsec(); - status = warpSetLowPowerMode(kWarpPowerModeVLPS, menuDelayBetweenEachRun); - if (status != kWarpStatusOK) - { - warpPrint("Failed to put into sleep: %d", status); - } - } + // // timeAtStart = OSA_TimeGetMsec(); + // status = warpSetLowPowerMode(kWarpPowerModeVLPS, menuDelayBetweenEachRun); + // if (status != kWarpStatusOK) + // { + // warpPrint("Failed to put into sleep: %d", status); + // } + // } readingCount++; @@ -3892,7 +3976,62 @@ repeatRegisterReadForDeviceAndAddress(WarpSensorDevice warpSensorDevice, uint8_t break; } + case kWarpSensorBNO055: + { + /* + * BNO055: VDD 1.95--3.6 + */ +#if (WARP_BUILD_ENABLE_DEVBNO055) + loopForSensor( "\r\nBNO055:\n\r", /* tagString */ + &readSensorRegisterBNO055, /* readSensorRegisterFunction */ + &deviceBNO055State, /* i2cDeviceState */ + NULL, /* spiDeviceState */ + baseAddress, /* baseAddress */ + 0x00, /* minAddress */ + 0x7F, /* maxAddress */ + repetitionsPerAddress, /* repetitionsPerAddress */ + chunkReadsPerAddress, /* chunkReadsPerAddress */ + spinDelay, /* spinDelay */ + autoIncrement, /* autoIncrement */ + sssupplyMillivolts, /* sssupplyMillivolts */ + referenceByte, /* referenceByte */ + adaptiveSssupplyMaxMillivolts, /* adaptiveSssupplyMaxMillivolts */ + chatty /* chatty */ + ); +#else + warpPrint("\r\n\tBNO055 Read Aborted. Device Disabled :("); +#endif + + break; + } + case kWarpSensorRF430CL331H: + { + /* + * BNO055: VDD 1.95--3.6 + */ +#if (WARP_BUILD_ENABLE_DEVRF430CL331H) + loopForSensor( "\r\nRF430CL331H:\n\r", /* tagString */ + &readSensorRegisterRF430CL331H, /* readSensorRegisterFunction */ + &deviceRF430CL331HState, /* i2cDeviceState */ + NULL, /* spiDeviceState */ + baseAddress, /* baseAddress */ + 0x0000, /* minAddress */ + 0xFFFF, /* maxAddress */ + repetitionsPerAddress, /* repetitionsPerAddress */ + chunkReadsPerAddress, /* chunkReadsPerAddress */ + spinDelay, /* spinDelay */ + autoIncrement, /* autoIncrement */ + sssupplyMillivolts, /* sssupplyMillivolts */ + referenceByte, /* referenceByte */ + adaptiveSssupplyMaxMillivolts, /* adaptiveSssupplyMaxMillivolts */ + chatty /* chatty */ + ); +#else + warpPrint("\r\n\tRF430CL331H Read Aborted. Device Disabled :("); +#endif + break; + } case kWarpSensorBMX055accel: { /* @@ -4452,7 +4591,7 @@ activateAllLowPowerSensorModes(bool verbose) * Put the Flash in deep power-down */ //TODO: move 0xB9 into a named constant - //spiTransactionIS25xP({0xB9 /* op0 */, 0x00 /* op1 */, 0x00 /* op2 */, 0x00 /* op3 */, 0x00 /* op4 */, 0x00 /* op5 */, 0x00 /* op6 */}, 1 /* opCount */); + // spiTransactionIS25xP({0xB9 /* op0 */, 0x00 /* op1 */, 0x00 /* op2 */, 0x00 /* op3 */, 0x00 /* op4 */, 0x00 /* op5 */, 0x00 /* op6 */}, 1 /* opCount */); #endif /* diff --git a/src/boot/ksdk1.1.0/config.h b/src/boot/ksdk1.1.0/config.h index 67936faac..17ef41985 100644 --- a/src/boot/ksdk1.1.0/config.h +++ b/src/boot/ksdk1.1.0/config.h @@ -39,8 +39,8 @@ #define WARP_BUILD_BOOT_TO_CSVSTREAM 1 #define WARP_CSVSTREAM_TO_FLASH 1 #define WARP_CSVSTREAM_FLASH_PRINT_METADATA 0 -#define WARP_BUILD_EXTRA_QUIET_MODE 1 -#define WARP_BUILD_BOOT_TO_VLPR 1 +#define WARP_BUILD_EXTRA_QUIET_MODE 0 +#define WARP_BUILD_BOOT_TO_VLPR 0 #define WARP_BUILD_DISABLE_SUPPLIES_BY_DEFAULT 0 /* @@ -65,49 +65,52 @@ * Force the required configuration if WARP_BUILD_ENABLE_GLAUX_VARIANT is set */ #if (WARP_BUILD_ENABLE_GLAUX_VARIANT) -#define WARP_BUILD_ENABLE_DEVADXL362 0 -#define WARP_BUILD_ENABLE_DEVAMG8834 0 -#define WARP_BUILD_ENABLE_DEVAS7262 0 -#define WARP_BUILD_ENABLE_DEVAS7263 0 -#define WARP_BUILD_ENABLE_DEVBGX 0 -#define WARP_BUILD_ENABLE_DEVBME680 1 -#define WARP_BUILD_ENABLE_DEVBMX055 0 -#define WARP_BUILD_ENABLE_DEVCCS811 0 -#define WARP_BUILD_ENABLE_DEVHDC1000 0 -#define WARP_BUILD_ENABLE_DEVIS25xP 1 -#define WARP_BUILD_ENABLE_DEVISL23415 0 -#define WARP_BUILD_ENABLE_DEVAT45DB 0 -#define WARP_BUILD_ENABLE_DEVICE40 0 -#define WARP_BUILD_ENABLE_DEVL3GD20H 0 -#define WARP_BUILD_ENABLE_DEVLPS25H 0 -#define WARP_BUILD_ENABLE_DEVMAG3110 0 -#define WARP_BUILD_ENABLE_DEVMMA8451Q 0 -#define WARP_BUILD_ENABLE_DEVRV8803C7 1 -#define WARP_BUILD_ENABLE_DEVSI4705 0 -#define WARP_BUILD_ENABLE_DEVSI7021 0 -#define WARP_BUILD_ENABLE_DEVTCS34725 0 +#define WARP_BUILD_ENABLE_DEVADXL362 0 +#define WARP_BUILD_ENABLE_DEVAMG8834 0 +#define WARP_BUILD_ENABLE_DEVAS7262 0 +#define WARP_BUILD_ENABLE_DEVAS7263 0 +#define WARP_BUILD_ENABLE_DEVBGX 0 +#define WARP_BUILD_ENABLE_DEVBME680 1 +#define WARP_BUILD_ENABLE_DEVBMX055 0 +#define WARP_BUILD_ENABLE_DEVCCS811 0 +#define WARP_BUILD_ENABLE_DEVHDC1000 0 +#define WARP_BUILD_ENABLE_DEVIS25xP 1 +#define WARP_BUILD_ENABLE_DEVISL23415 0 +#define WARP_BUILD_ENABLE_DEVAT45DB 0 +#define WARP_BUILD_ENABLE_DEVICE40 0 +#define WARP_BUILD_ENABLE_DEVL3GD20H 0 +#define WARP_BUILD_ENABLE_DEVLPS25H 0 +#define WARP_BUILD_ENABLE_DEVMAG3110 0 +#define WARP_BUILD_ENABLE_DEVMMA8451Q 0 +#define WARP_BUILD_ENABLE_DEVRV8803C7 0 +#define WARP_BUILD_ENABLE_DEVSI4705 0 +#define WARP_BUILD_ENABLE_DEVSI7021 0 +#define WARP_BUILD_ENABLE_DEVTCS34725 0 +#define WARP_BUILD_ENABLE_DEVBNO055 0 +#define WARP_BUILD_ENABLE_DEVRF430CL331H 0 #elif (WARP_BUILD_ENABLE_FRDMKL03) -#define WARP_BUILD_ENABLE_DEVADXL362 0 -#define WARP_BUILD_ENABLE_DEVAMG8834 0 -#define WARP_BUILD_ENABLE_DEVAS7262 0 -#define WARP_BUILD_ENABLE_DEVAS7263 0 -#define WARP_BUILD_ENABLE_DEVBGX 0 -#define WARP_BUILD_ENABLE_DEVBME680 0 -#define WARP_BUILD_ENABLE_DEVBMX055 0 -#define WARP_BUILD_ENABLE_DEVCCS811 0 -#define WARP_BUILD_ENABLE_DEVHDC1000 0 -#define WARP_BUILD_ENABLE_DEVIS25xP 0 -#define WARP_BUILD_ENABLE_DEVISL23415 0 -#define WARP_BUILD_ENABLE_DEVAT45DB 0 -#define WARP_BUILD_ENABLE_DEVICE40 0 -#define WARP_BUILD_ENABLE_DEVL3GD20H 0 -#define WARP_BUILD_ENABLE_DEVLPS25H 0 -#define WARP_BUILD_ENABLE_DEVMAG3110 0 -#define WARP_BUILD_ENABLE_DEVMMA8451Q 1 -#define WARP_BUILD_ENABLE_DEVRV8803C7 0 -#define WARP_BUILD_ENABLE_DEVSI4705 0 -#define WARP_BUILD_ENABLE_DEVSI7021 0 -#define WARP_BUILD_ENABLE_DEVTCS34725 0 +#define WARP_BUILD_ENABLE_DEVADXL362 0 +#define WARP_BUILD_ENABLE_DEVAMG8834 0 +#define WARP_BUILD_ENABLE_DEVAS7262 0 +#define WARP_BUILD_ENABLE_DEVAS7263 0 +#define WARP_BUILD_ENABLE_DEVBGX 0 +#define WARP_BUILD_ENABLE_DEVBME680 0 +#define WARP_BUILD_ENABLE_DEVBMX055 0 +#define WARP_BUILD_ENABLE_DEVCCS811 0 +#define WARP_BUILD_ENABLE_DEVHDC1000 0 +#define WARP_BUILD_ENABLE_DEVIS25xP 0 +#define WARP_BUILD_ENABLE_DEVISL23415 0 +#define WARP_BUILD_ENABLE_DEVAT45DB 0 +#define WARP_BUILD_ENABLE_DEVICE40 0 +#define WARP_BUILD_ENABLE_DEVL3GD20H 0 +#define WARP_BUILD_ENABLE_DEVLPS25H 0 +#define WARP_BUILD_ENABLE_DEVMAG3110 0 +#define WARP_BUILD_ENABLE_DEVMMA8451Q 1 +#define WARP_BUILD_ENABLE_DEVRV8803C7 0 +#define WARP_BUILD_ENABLE_DEVSI4705 0 +#define WARP_BUILD_ENABLE_DEVSI7021 0 +#define WARP_BUILD_ENABLE_DEVTCS34725 0 +#define WARP_BUILD_ENABLE_DEVBNO055 0 #else /* * Otherwise: Edit these to set which code paths are activated in the firmware compilation @@ -117,22 +120,23 @@ #define WARP_BUILD_ENABLE_DEVAS7262 0 #define WARP_BUILD_ENABLE_DEVAS7263 0 #define WARP_BUILD_ENABLE_DEVBGX 0 -#define WARP_BUILD_ENABLE_DEVBME680 0 -#define WARP_BUILD_ENABLE_DEVBMX055 1 +#define WARP_BUILD_ENABLE_DEVBME680 1 +#define WARP_BUILD_ENABLE_DEVBMX055 0 #define WARP_BUILD_ENABLE_DEVCCS811 0 #define WARP_BUILD_ENABLE_DEVHDC1000 0 #define WARP_BUILD_ENABLE_DEVIS25xP 0 #define WARP_BUILD_ENABLE_DEVISL23415 1 #define WARP_BUILD_ENABLE_DEVAT45DB 1 #define WARP_BUILD_ENABLE_DEVICE40 0 -#define WARP_BUILD_ENABLE_DEVL3GD20H 1 +#define WARP_BUILD_ENABLE_DEVL3GD20H 0 #define WARP_BUILD_ENABLE_DEVLPS25H 0 #define WARP_BUILD_ENABLE_DEVMAG3110 0 #define WARP_BUILD_ENABLE_DEVMMA8451Q 0 -#define WARP_BUILD_ENABLE_DEVRV8803C7 0 +#define WARP_BUILD_ENABLE_DEVRV8803C7 1 #define WARP_BUILD_ENABLE_DEVSI4705 0 #define WARP_BUILD_ENABLE_DEVSI7021 0 #define WARP_BUILD_ENABLE_DEVTCS34725 0 +#define WARP_BUILD_ENABLE_DEVBNO055 0 #endif typedef enum @@ -173,28 +177,30 @@ typedef enum /* * Voltages */ - kWarpDefaultSupplyVoltageMillivolts = 1800, - kWarpDefaultSupplyVoltageMillivoltsBGX = 2000, - kWarpDefaultSupplyVoltageMillivoltsBMX055accel = 2600, - kWarpDefaultSupplyVoltageMillivoltsBMX055gyro = 2600, - kWarpDefaultSupplyVoltageMillivoltsBMX055mag = 2600, - kWarpDefaultSupplyVoltageMillivoltsMMA8451Q = 1800, - kWarpDefaultSupplyVoltageMillivoltsLPS25H = 1800, - kWarpDefaultSupplyVoltageMillivoltsHDC1000 = 1800, - kWarpDefaultSupplyVoltageMillivoltsMAG3110 = 1800, - kWarpDefaultSupplyVoltageMillivoltsSI7021 = 1800, - kWarpDefaultSupplyVoltageMillivoltsL3GD20H = 2200, - kWarpDefaultSupplyVoltageMillivoltsBME680 = 2400, - kWarpDefaultSupplyVoltageMillivoltsTCS34725 = 1800, - kWarpDefaultSupplyVoltageMillivoltsSI4705 = 1800, - kWarpDefaultSupplyVoltageMillivoltsCCS811 = 1800, - kWarpDefaultSupplyVoltageMillivoltsAMG8834 = 2600, - kWarpDefaultSupplyVoltageMillivoltsAS7262 = 1800, - kWarpDefaultSupplyVoltageMillivoltsAS7263 = 1800, - kWarpDefaultSupplyVoltageMillivoltsRV8803C7 = 1800, - kWarpDefaultSupplyVoltageMillivoltsADXL362 = 2400, - kWarpDefaultSupplyVoltageMillivoltsIS25xP = 1800, - kWarpDefaultSupplyVoltageMillivoltsISL23415 = 1800, - kWarpDefaultSupplyVoltageMillivoltsAT45DB = 1800, - kWarpDefaultSupplyVoltageMillivoltsICE40 = 1800, + kWarpDefaultSupplyVoltageMillivolts = 1800, + kWarpDefaultSupplyVoltageMillivoltsBGX = 2000, + kWarpDefaultSupplyVoltageMillivoltsBMX055accel = 2600, + kWarpDefaultSupplyVoltageMillivoltsBMX055gyro = 2600, + kWarpDefaultSupplyVoltageMillivoltsBMX055mag = 2600, + kWarpDefaultSupplyVoltageMillivoltsMMA8451Q = 1800, + kWarpDefaultSupplyVoltageMillivoltsLPS25H = 1800, + kWarpDefaultSupplyVoltageMillivoltsHDC1000 = 1800, + kWarpDefaultSupplyVoltageMillivoltsMAG3110 = 1800, + kWarpDefaultSupplyVoltageMillivoltsSI7021 = 1800, + kWarpDefaultSupplyVoltageMillivoltsL3GD20H = 2200, + kWarpDefaultSupplyVoltageMillivoltsBME680 = 2400, + kWarpDefaultSupplyVoltageMillivoltsTCS34725 = 1800, + kWarpDefaultSupplyVoltageMillivoltsSI4705 = 1800, + kWarpDefaultSupplyVoltageMillivoltsCCS811 = 1800, + kWarpDefaultSupplyVoltageMillivoltsAMG8834 = 2600, + kWarpDefaultSupplyVoltageMillivoltsAS7262 = 1800, + kWarpDefaultSupplyVoltageMillivoltsAS7263 = 1800, + kWarpDefaultSupplyVoltageMillivoltsRV8803C7 = 1800, + kWarpDefaultSupplyVoltageMillivoltsADXL362 = 2400, + kWarpDefaultSupplyVoltageMillivoltsIS25xP = 1800, + kWarpDefaultSupplyVoltageMillivoltsISL23415 = 1800, + kWarpDefaultSupplyVoltageMillivoltsAT45DB = 1800, + kWarpDefaultSupplyVoltageMillivoltsICE40 = 1800, + kWarpDefaultSupplyVoltageMillivoltsBNO055 = 2500, + kWarpDefaultSupplyVoltageMillivoltsRF430CL331H = 2500, } WarpDefaults; \ No newline at end of file diff --git a/src/boot/ksdk1.1.0/devADXL362.c b/src/boot/ksdk1.1.0/devADXL362.c index efd7ab19b..b5e4b19a0 100644 --- a/src/boot/ksdk1.1.0/devADXL362.c +++ b/src/boot/ksdk1.1.0/devADXL362.c @@ -58,9 +58,9 @@ #include "devADXL362.h" extern volatile WarpSPIDeviceState deviceADXL362State; -extern volatile uint32_t gWarpSpiTimeoutMicroseconds; -extern uint8_t gWarpSpiCommonSourceBuffer[]; -extern uint8_t gWarpSpiCommonSinkBuffer[]; +extern volatile uint32_t gWarpSpiTimeoutMicroseconds; +extern uint8_t gWarpSpiCommonSourceBuffer[]; +extern uint8_t gWarpSpiCommonSinkBuffer[]; /* @@ -85,10 +85,10 @@ initADXL362(int chipSelectIoPinID, uint16_t operatingVoltageMillivolts) { WarpStatus status; - deviceADXL362State.chipSelectIoPinID = chipSelectIoPinID; - deviceADXL362State.spiSourceBuffer = gWarpSpiCommonSourceBuffer; - deviceADXL362State.spiSinkBuffer = gWarpSpiCommonSinkBuffer; - deviceADXL362State.spiBufferLength = kWarpMemoryCommonSpiBufferBytes; + deviceADXL362State.chipSelectIoPinID = chipSelectIoPinID; + deviceADXL362State.spiSourceBuffer = gWarpSpiCommonSourceBuffer; + deviceADXL362State.spiSinkBuffer = gWarpSpiCommonSinkBuffer; + deviceADXL362State.spiBufferLength = kWarpMemoryCommonSpiBufferBytes; deviceADXL362State.operatingVoltageMillivolts = operatingVoltageMillivolts; /* diff --git a/src/boot/ksdk1.1.0/devAMG8834.c b/src/boot/ksdk1.1.0/devAMG8834.c index 007b22b57..751d4971f 100644 --- a/src/boot/ksdk1.1.0/devAMG8834.c +++ b/src/boot/ksdk1.1.0/devAMG8834.c @@ -59,9 +59,9 @@ extern volatile WarpI2CDeviceState deviceAMG8834State; -extern volatile uint32_t gWarpI2cBaudRateKbps; -extern volatile uint32_t gWarpI2cTimeoutMilliseconds; -extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; +extern volatile uint32_t gWarpI2cBaudRateKbps; +extern volatile uint32_t gWarpI2cTimeoutMilliseconds; +extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; /* @@ -70,7 +70,7 @@ extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; void initAMG8834(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) { - deviceAMG8834State.i2cAddress = i2cAddress; + deviceAMG8834State.i2cAddress = i2cAddress; deviceAMG8834State.operatingVoltageMillivolts = operatingVoltageMillivolts; return; @@ -79,7 +79,7 @@ initAMG8834(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) WarpStatus writeSensorRegisterAMG8834(uint8_t deviceRegister, uint8_t payload) { - uint8_t payloadByte[1], commandByte[1]; + uint8_t payloadByte[1], commandByte[1]; i2c_status_t returnValue; @@ -160,8 +160,9 @@ readSensorRegisterAMG8834(uint8_t deviceRegister, int numberOfBytes) i2c_device_t slave = { - .address = deviceAMG8834State.i2cAddress, - .baudRate_kbps = gWarpI2cBaudRateKbps}; + .address = deviceAMG8834State.i2cAddress, + .baudRate_kbps = gWarpI2cBaudRateKbps + }; cmdBuf[0] = deviceRegister; @@ -264,10 +265,10 @@ appendSensorDataAMG8834(uint8_t* buf) { uint8_t index = 0; - uint16_t readSensorRegisterValueLSB; - uint16_t readSensorRegisterValueMSB; - int16_t readSensorRegisterValueCombined; - WarpStatus i2cReadStatus; + uint16_t readSensorRegisterValueLSB; + uint16_t readSensorRegisterValueMSB; + int16_t readSensorRegisterValueCombined; + WarpStatus i2cReadStatus; warpScaleSupplyVoltage(deviceAMG8834State.operatingVoltageMillivolts); diff --git a/src/boot/ksdk1.1.0/devAS7262.c b/src/boot/ksdk1.1.0/devAS7262.c index babf77984..35eda714a 100644 --- a/src/boot/ksdk1.1.0/devAS7262.c +++ b/src/boot/ksdk1.1.0/devAS7262.c @@ -59,14 +59,14 @@ #include "devAS726x.h" extern volatile WarpI2CDeviceState deviceAS7262State; -extern volatile uint32_t gWarpI2cBaudRateKbps; -extern volatile uint32_t gWarpI2cTimeoutMilliseconds; +extern volatile uint32_t gWarpI2cBaudRateKbps; +extern volatile uint32_t gWarpI2cTimeoutMilliseconds; void initAS7262(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) { - deviceAS7262State.i2cAddress = i2cAddress; + deviceAS7262State.i2cAddress = i2cAddress; deviceAS7262State.operatingVoltageMillivolts = operatingVoltageMillivolts; return; @@ -89,7 +89,7 @@ readSensorRegisterAS7262(uint8_t deviceRegister, int numberOfBytes) } i2c_device_t slave = - { + { .address = deviceAS7262State.i2cAddress, .baudRate_kbps = gWarpI2cBaudRateKbps }; diff --git a/src/boot/ksdk1.1.0/devAS7263.c b/src/boot/ksdk1.1.0/devAS7263.c index 4c29ba9b3..f4c779219 100644 --- a/src/boot/ksdk1.1.0/devAS7263.c +++ b/src/boot/ksdk1.1.0/devAS7263.c @@ -65,7 +65,7 @@ extern volatile uint32_t gWarpI2cTimeoutMilliseconds; void initAS7263(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) { - deviceAS7263State.i2cAddress = i2cAddress; + deviceAS7263State.i2cAddress = i2cAddress; deviceAS7263State.operatingVoltageMillivolts = operatingVoltageMillivolts; return; @@ -92,7 +92,7 @@ readSensorRegisterAS7263(uint8_t deviceRegister, int numberOfBytes) } i2c_device_t slave = - { + { .address = deviceAS7263State.i2cAddress, .baudRate_kbps = gWarpI2cBaudRateKbps }; diff --git a/src/boot/ksdk1.1.0/devAS726x.c b/src/boot/ksdk1.1.0/devAS726x.c index 309aa3b5d..b3667374d 100644 --- a/src/boot/ksdk1.1.0/devAS726x.c +++ b/src/boot/ksdk1.1.0/devAS726x.c @@ -67,7 +67,7 @@ ledOnAS726x(uint8_t i2cAddress) uint8_t cmdBuf_LEDON[2] = {kWarpI2C_AS726x_SLAVE_WRITE_REG, 0x1B}; i2c_device_t slave = - { + { .address = i2cAddress, .baudRate_kbps = gWarpI2cBaudRateKbps }; @@ -108,9 +108,9 @@ ledOffAS726x(uint8_t i2cAddress) uint8_t cmdBuf_LEDOFF[2] = {kWarpI2C_AS726x_SLAVE_WRITE_REG, 0x00}; i2c_device_t slave = - { - .address = i2cAddress, - .baudRate_kbps = gWarpI2cBaudRateKbps + { + .address = i2cAddress, + .baudRate_kbps = gWarpI2cBaudRateKbps }; warpEnableI2Cpins(); diff --git a/src/boot/ksdk1.1.0/devAS726x.h b/src/boot/ksdk1.1.0/devAS726x.h index 2999037fa..b225146f9 100644 --- a/src/boot/ksdk1.1.0/devAS726x.h +++ b/src/boot/ksdk1.1.0/devAS726x.h @@ -36,7 +36,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -enum { +enum +{ kWarpI2C_AS726x_SLAVE_WRITE_REG = 0x01, kWarpI2C_AS726x_SLAVE_READ_REG = 0x02 }; diff --git a/src/boot/ksdk1.1.0/devAT45DB.c b/src/boot/ksdk1.1.0/devAT45DB.c index 9eadf7912..1926a7cc9 100644 --- a/src/boot/ksdk1.1.0/devAT45DB.c +++ b/src/boot/ksdk1.1.0/devAT45DB.c @@ -73,18 +73,18 @@ extern uint8_t gWarpSpiCommonSourceBuffer[]; extern uint8_t gWarpSpiCommonSinkBuffer[]; /* Read commands */ -#define AT45DB_RDMN 0xd2 /* Main Memory Page Read */ -#define AT45DB_RDARRY 0xe8 /* Continuous Array Read (Legacy Command) */ +#define AT45DB_RDMN 0xd2 /* Main Memory Page Read */ +#define AT45DB_RDARRY 0xe8 /* Continuous Array Read (Legacy Command) */ #define AT45DB_RDARRAYLF 0x03 /* Continuous Array Read (Low Frequency) */ #define AT45DB_RDARRAYHF 0x0b /* Continuous Array Read (High Frequency) */ #define AT45DB_RDBF1LF 0xd1 /* Buffer 1 Read (Low Frequency) */ #define AT45DB_RDBF2LF 0xd3 /* Buffer 2 Read (Low Frequency) */ -#define AT45DB_RDBF1 0xd4 /* Buffer 1 Read */ -#define AT45DB_RDBF2 0xd6 /* Buffer 2 Read */ +#define AT45DB_RDBF1 0xd4 /* Buffer 1 Read */ +#define AT45DB_RDBF2 0xd6 /* Buffer 2 Read */ /* Program and Erase Commands */ -#define AT45DB_WRBF1 0x84 /* Buffer 1 Write */ -#define AT45DB_WRBF2 0x87 /* Buffer 2 Write */ +#define AT45DB_WRBF1 0x84 /* Buffer 1 Write */ +#define AT45DB_WRBF2 0x87 /* Buffer 2 Write */ #define AT45DB_BF1TOMNE 0x83 /* Buffer 1 to Main Memory Page Program with Built-in Erase */ #define AT45DB_BF2TOMNE 0x86 /* Buffer 2 to Main Memory Page Program with Built-in Erase */ #define AT45DB_BF1TOMN 0x88 /* Buffer 1 to Main Memory Page Program without Built-in Erase */ @@ -116,7 +116,7 @@ extern uint8_t gWarpSpiCommonSinkBuffer[]; #define AT45DB_PROGPROT2 0x2a /* Program Sector Protection Register - byte 2 */ #define AT45DB_PROGPROT3 0x7f /* Program Sector Protection Register - byte 3 */ #define AT45DB_PROGPROT4 0xfc /* Program Sector Protection Register - byte 4 */ -#define AT45DB_RDPROT 0x32 /* Read Sector Protection Register */ +#define AT45DB_RDPROT 0x32 /* Read Sector Protection Register */ #define AT45DB_LOCKDOWN1 0x3d /* Sector Lockdown - byte 1 */ #define AT45DB_LOCKDOWN2 0x2a /* Sector Lockdown - byte 2 */ #define AT45DB_LOCKDOWN3 0x7f /* Sector Lockdown - byte 3 */ @@ -136,27 +136,27 @@ extern uint8_t gWarpSpiCommonSinkBuffer[]; #define AT45DB_AUTOWRBF1 0x58 /* Auto Page Rewrite through Buffer 1 */ #define AT45DB_AUTOWRBF2 0x59 /* Auto Page Rewrite through Buffer 2 */ #define AT45DB_PWRDOWN 0xb9 /* Deep Power-down */ -#define AT45DB_RESUME 0xab /* Resume from Deep Power-down */ -#define AT45DB_RDSR 0xd7 /* Status Register Read */ +#define AT45DB_RESUME 0xab /* Resume from Deep Power-down */ +#define AT45DB_RDSR 0xd7 /* Status Register Read */ #define AT45DB_RDDEVID 0x9f /* Manufacturer and Device ID Read */ -#define AT45DB_MANUFACTURER 0x1f /* Manufacturer ID: Atmel */ -#define AT45DB_DEVID1_CAPMSK 0x1f /* Bits 0-4: Capacity */ -#define AT45DB_DEVID1_1MBIT 0x02 /* xxx0 0010 = 1Mbit AT45DB011 */ -#define AT45DB_DEVID1_2MBIT 0x03 /* xxx0 0012 = 2Mbit AT45DB021 */ -#define AT45DB_DEVID1_4MBIT 0x04 /* xxx0 0100 = 4Mbit AT45DB041 */ -#define AT45DB_DEVID1_8MBIT 0x05 /* xxx0 0101 = 8Mbit AT45DB081 */ -#define AT45DB_DEVID1_16MBIT 0x06 /* xxx0 0110 = 16Mbit AT45DB161 */ -#define AT45DB_DEVID1_32MBIT 0x07 /* xxx0 0111 = 32Mbit AT45DB321 */ -#define AT45DB_DEVID1_64MBIT 0x08 /* xxx0 1000 = 32Mbit AT45DB641 */ -#define AT45DB_DEVID1_FAMMSK 0xe0 /* Bits 5-7: Family */ -#define AT45DB_DEVID1_DFLASH 0x20 /* 001x xxxx = Dataflash */ -#define AT45DB_DEVID1_AT26DF 0x40 /* 010x xxxx = AT26DFxxx series (Not supported) */ -#define AT45DB_DEVID2_VERMSK 0x1f /* Bits 0-4: MLC mask */ -#define AT45DB_DEVID2_MLCMSK 0xe0 /* Bits 5-7: MLC mask */ +#define AT45DB_MANUFACTURER 0x1f /* Manufacturer ID: Atmel */ +#define AT45DB_DEVID1_CAPMSK 0x1f /* Bits 0-4: Capacity */ +#define AT45DB_DEVID1_1MBIT 0x02 /* xxx0 0010 = 1Mbit AT45DB011 */ +#define AT45DB_DEVID1_2MBIT 0x03 /* xxx0 0012 = 2Mbit AT45DB021 */ +#define AT45DB_DEVID1_4MBIT 0x04 /* xxx0 0100 = 4Mbit AT45DB041 */ +#define AT45DB_DEVID1_8MBIT 0x05 /* xxx0 0101 = 8Mbit AT45DB081 */ +#define AT45DB_DEVID1_16MBIT 0x06 /* xxx0 0110 = 16Mbit AT45DB161 */ +#define AT45DB_DEVID1_32MBIT 0x07 /* xxx0 0111 = 32Mbit AT45DB321 */ +#define AT45DB_DEVID1_64MBIT 0x08 /* xxx0 1000 = 32Mbit AT45DB641 */ +#define AT45DB_DEVID1_FAMMSK 0xe0 /* Bits 5-7: Family */ +#define AT45DB_DEVID1_DFLASH 0x20 /* 001x xxxx = Dataflash */ +#define AT45DB_DEVID1_AT26DF 0x40 /* 010x xxxx = AT26DFxxx series (Not supported) */ +#define AT45DB_DEVID2_VERMSK 0x1f /* Bits 0-4: MLC mask */ +#define AT45DB_DEVID2_MLCMSK 0xe0 /* Bits 5-7: MLC mask */ /* Status register bit definitions */ -#define AT45DB_SR_RDY (1 << 7) /* Bit 7: RDY/ Not BUSY */ +#define AT45DB_SR_RDY (1 << 7) /* Bit 7: RDY/ Not BUSY */ #define AT45DB_SR_COMP (1 << 6) /* Bit 6: COMP */ #define AT45DB_SR_PROTECT (1 << 1) /* Bit 1: PROTECT */ #define AT45DB_SR_PGSIZE (1 << 0) /* Bit 0: PAGE_SIZE */ @@ -175,11 +175,11 @@ initAT45DB(int chipSelectIoPinID, uint16_t operatingVoltageMillivolts) { WarpStatus status; - deviceAT45DBState.chipSelectIoPinID = chipSelectIoPinID; - deviceAT45DBState.spiSourceBuffer = gWarpSpiCommonSourceBuffer; - deviceAT45DBState.spiSinkBuffer = gWarpSpiCommonSinkBuffer; - deviceAT45DBState.spiBufferLength = kWarpMemoryCommonSpiBufferBytes; - deviceAT45DBState.operatingVoltageMillivolts = operatingVoltageMillivolts; + deviceAT45DBState.chipSelectIoPinID = chipSelectIoPinID; + deviceAT45DBState.spiSourceBuffer = gWarpSpiCommonSourceBuffer; + deviceAT45DBState.spiSinkBuffer = gWarpSpiCommonSinkBuffer; + deviceAT45DBState.spiBufferLength = kWarpMemoryCommonSpiBufferBytes; + deviceAT45DBState.operatingVoltageMillivolts = operatingVoltageMillivolts; enableAT45DBWrite(); @@ -384,7 +384,6 @@ writeToAT45DBFromEndBuffered(size_t nbyte, uint8_t* buf) status = writeToAT45DBFromEndBuffered(nbyte, buf); } else - { /* * If there is space in the current buffer, then fill it up as needed. @@ -445,7 +444,8 @@ writeBufferAndSavePagePositionAT45DB() if (status == kWarpStatusFlashFull) { return kWarpStatusOK; - } else if (status != kWarpStatusOK) + } + else if (status != kWarpStatusOK) { return status; } @@ -547,11 +547,11 @@ resetAT45DB() } warpPrint("Reinitializing global variables...\n"); - currentPageNumberAT45DB = kWarpInitialPageNumberAT45DB; - currentPageOffsetAT45DB = kWarpInitialPageOffsetAT45DB; + currentPageNumberAT45DB = kWarpInitialPageNumberAT45DB; + currentPageOffsetAT45DB = kWarpInitialPageOffsetAT45DB; - currentBufferOffsetAT45DB = kWarpInitialBufferOffsetAT45DB; - currentBufferAT45DB = bufferNumber1AT45DB; + currentBufferOffsetAT45DB = kWarpInitialBufferOffsetAT45DB; + currentBufferAT45DB = bufferNumber1AT45DB; return status; } @@ -643,7 +643,8 @@ bufferToMainMemoryWritePageAT45DB(BufferNumberAT45DB buffer) * If we have reached the end of the memory, don't do anything, and return ok. */ return kWarpStatusOK; - } else if (status != kWarpStatusOK) + } + else if (status != kWarpStatusOK) { return status; } @@ -652,7 +653,8 @@ bufferToMainMemoryWritePageAT45DB(BufferNumberAT45DB buffer) currentPageOffsetAT45DB = 0; - if (currentPageNumberAT45DB == (uint16_t)(kWarpSizeAT45DBNPages)) { + if (currentPageNumberAT45DB == (uint16_t)(kWarpSizeAT45DBNPages)) + { AT45DBFull = true; currentPageNumberAT45DB = kWarpSizeAT45DBNPages; diff --git a/src/boot/ksdk1.1.0/devBME680.c b/src/boot/ksdk1.1.0/devBME680.c index e5ed5cbf5..0ad39fbb4 100644 --- a/src/boot/ksdk1.1.0/devBME680.c +++ b/src/boot/ksdk1.1.0/devBME680.c @@ -58,16 +58,16 @@ extern volatile WarpI2CDeviceState deviceBME680State; -extern volatile uint8_t deviceBME680CalibrationValues[]; -extern volatile uint32_t gWarpI2cBaudRateKbps; -extern volatile uint32_t gWarpI2cTimeoutMilliseconds; -extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; +extern volatile uint8_t deviceBME680CalibrationValues[]; +extern volatile uint32_t gWarpI2cBaudRateKbps; +extern volatile uint32_t gWarpI2cTimeoutMilliseconds; +extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; void initBME680(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) { - deviceBME680State.i2cAddress = i2cAddress; + deviceBME680State.i2cAddress = i2cAddress; deviceBME680State.operatingVoltageMillivolts = operatingVoltageMillivolts; return; @@ -114,7 +114,7 @@ writeSensorRegisterBME680(uint8_t deviceRegister, uint8_t payload) WarpStatus readSensorRegisterBME680(uint8_t deviceRegister, int numberOfBytes) { - uint8_t cmdBuf[1] = {0xFF}; + uint8_t cmdBuf[1] = {0xFF}; i2c_status_t status; @@ -179,7 +179,7 @@ configureSensorBME680(uint8_t payloadCtrl_Hum, uint8_t payloadCtrl_Meas, uint8_t /* * Read the calibration registers */ - for ( reg = kWarpSensorConfigurationRegisterBME680CalibrationRegion1Start; + for (reg = kWarpSensorConfigurationRegisterBME680CalibrationRegion1Start; reg < kWarpSensorConfigurationRegisterBME680CalibrationRegion1End; reg++) { @@ -187,7 +187,7 @@ configureSensorBME680(uint8_t payloadCtrl_Hum, uint8_t payloadCtrl_Meas, uint8_t deviceBME680CalibrationValues[index++] = deviceBME680State.i2cBuffer[0]; } - for ( reg = kWarpSensorConfigurationRegisterBME680CalibrationRegion2Start; + for (reg = kWarpSensorConfigurationRegisterBME680CalibrationRegion2Start; reg < kWarpSensorConfigurationRegisterBME680CalibrationRegion2End; reg++) { @@ -437,4 +437,14 @@ appendSensorDataBME680(uint8_t* buf) * total number of bytes written */ return index; +} + +WarpStatus +StateBME680() +{ + WarpStatus i2cReadStatusLSB; + i2cReadStatusLSB = readSensorRegisterBME680(kWarpSensorConfigurationRegisterBME680Ctrl_Meas, 1); + warpPrint("BME680 Status = [" BYTE_TO_BINARY_PATTERN "]\n", + BYTE_TO_BINARY(deviceBME680State.i2cBuffer[0])); + return kWarpStatusOK; } \ No newline at end of file diff --git a/src/boot/ksdk1.1.0/devBME680.h b/src/boot/ksdk1.1.0/devBME680.h index f4d4f3d58..5e7cff29c 100644 --- a/src/boot/ksdk1.1.0/devBME680.h +++ b/src/boot/ksdk1.1.0/devBME680.h @@ -43,6 +43,7 @@ WarpStatus configureSensorBME680( uint8_t payloadCtrl_Hum, WarpStatus readSensorRegisterBME680(uint8_t deviceRegister, int numberOfBytes); void printSensorDataBME680(bool hexModeFlag); uint8_t appendSensorDataBME680(uint8_t* buf); +WarpStatus StateBME680(); const uint8_t bytesPerMeasurementBME680 = 12; const uint8_t bytesPerReadingBME680 = 4; diff --git a/src/boot/ksdk1.1.0/devBMX055.c b/src/boot/ksdk1.1.0/devBMX055.c index 29d9ba41d..ecb420f26 100644 --- a/src/boot/ksdk1.1.0/devBMX055.c +++ b/src/boot/ksdk1.1.0/devBMX055.c @@ -60,9 +60,9 @@ extern volatile WarpI2CDeviceState deviceBMX055accelState; extern volatile WarpI2CDeviceState deviceBMX055gyroState; extern volatile WarpI2CDeviceState deviceBMX055magState; -extern volatile uint32_t gWarpI2cBaudRateKbps; -extern volatile uint32_t gWarpI2cTimeoutMilliseconds; -extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; +extern volatile uint32_t gWarpI2cBaudRateKbps; +extern volatile uint32_t gWarpI2cTimeoutMilliseconds; +extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; @@ -72,7 +72,7 @@ extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; void initBMX055accel(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) { - deviceBMX055accelState.i2cAddress = i2cAddress; + deviceBMX055accelState.i2cAddress = i2cAddress; deviceBMX055accelState.operatingVoltageMillivolts = operatingVoltageMillivolts; return; @@ -81,7 +81,7 @@ initBMX055accel(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) WarpStatus writeSensorRegisterBMX055accel(uint8_t deviceRegister, uint8_t payload) { - uint8_t payloadByte[1], commandByte[1]; + uint8_t payloadByte[1], commandByte[1]; i2c_status_t status; if (deviceRegister > 0x3F) @@ -93,7 +93,7 @@ writeSensorRegisterBMX055accel(uint8_t deviceRegister, uint8_t payload) { .address = deviceBMX055accelState.i2cAddress, .baudRate_kbps = gWarpI2cBaudRateKbps - }; + }; commandByte[0] = deviceRegister; payloadByte[0] = payload; @@ -135,7 +135,7 @@ configureSensorBMX055accel(uint8_t payloadPMU_RANGE, uint8_t payloadACCD_HBW) WarpStatus readSensorRegisterBMX055accel(uint8_t deviceRegister, int numberOfBytes) { - uint8_t cmdBuf[1] = {0xFF}; + uint8_t cmdBuf[1] = {0xFF}; i2c_status_t status; @@ -175,7 +175,7 @@ readSensorRegisterBMX055accel(uint8_t deviceRegister, int numberOfBytes) void initBMX055mag(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) { - deviceBMX055magState.i2cAddress = i2cAddress; + deviceBMX055magState.i2cAddress = i2cAddress; deviceBMX055magState.operatingVoltageMillivolts = operatingVoltageMillivolts; return; @@ -184,7 +184,7 @@ initBMX055mag(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) WarpStatus writeSensorRegisterBMX055mag(uint8_t deviceRegister, uint8_t payload) { - uint8_t payloadByte[1], commandByte[1]; + uint8_t payloadByte[1], commandByte[1]; i2c_status_t status; if (deviceRegister > 0x52 || deviceRegister < 0x40) @@ -194,8 +194,9 @@ writeSensorRegisterBMX055mag(uint8_t deviceRegister, uint8_t payload) i2c_device_t slave = { - .address = deviceBMX055magState.i2cAddress, - .baudRate_kbps = gWarpI2cBaudRateKbps}; + .address = deviceBMX055magState.i2cAddress, + .baudRate_kbps = gWarpI2cBaudRateKbps + }; commandByte[0] = deviceRegister; payloadByte[0] = payload; @@ -239,7 +240,7 @@ configureSensorBMX055mag(uint8_t payloadPowerCtrl, uint8_t payloadOpMode) WarpStatus readSensorRegisterBMX055mag(uint8_t deviceRegister, int numberOfBytes) { - uint8_t cmdBuf[1] = {0xFF}; + uint8_t cmdBuf[1] = {0xFF}; i2c_status_t status; @@ -250,8 +251,9 @@ readSensorRegisterBMX055mag(uint8_t deviceRegister, int numberOfBytes) i2c_device_t slave = { - .address = deviceBMX055magState.i2cAddress, - .baudRate_kbps = gWarpI2cBaudRateKbps}; + .address = deviceBMX055magState.i2cAddress, + .baudRate_kbps = gWarpI2cBaudRateKbps + }; cmdBuf[0] = deviceRegister; @@ -277,7 +279,7 @@ readSensorRegisterBMX055mag(uint8_t deviceRegister, int numberOfBytes) void initBMX055gyro(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) { - deviceBMX055gyroState.i2cAddress = i2cAddress; + deviceBMX055gyroState.i2cAddress = i2cAddress; deviceBMX055gyroState.operatingVoltageMillivolts = operatingVoltageMillivolts; return; @@ -286,7 +288,7 @@ initBMX055gyro(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) WarpStatus writeSensorRegisterBMX055gyro(uint8_t deviceRegister, uint8_t payload) { - uint8_t payloadByte[1], commandByte[1]; + uint8_t payloadByte[1], commandByte[1]; i2c_status_t status; if (deviceRegister > 0x3F) @@ -296,8 +298,9 @@ writeSensorRegisterBMX055gyro(uint8_t deviceRegister, uint8_t payload) i2c_device_t slave = { - .address = deviceBMX055gyroState.i2cAddress, - .baudRate_kbps = gWarpI2cBaudRateKbps}; + .address = deviceBMX055gyroState.i2cAddress, + .baudRate_kbps = gWarpI2cBaudRateKbps + }; commandByte[0] = deviceRegister; payloadByte[0] = payload; @@ -349,7 +352,7 @@ configureSensorBMX055gyro(uint8_t payloadRANGE, uint8_t payloadBW, uint8_t paylo WarpStatus readSensorRegisterBMX055gyro(uint8_t deviceRegister, int numberOfBytes) { - uint8_t cmdBuf[1] = {0xFF}; + uint8_t cmdBuf[1] = {0xFF}; i2c_status_t status; @@ -361,8 +364,9 @@ readSensorRegisterBMX055gyro(uint8_t deviceRegister, int numberOfBytes) i2c_device_t slave = { - .address = deviceBMX055gyroState.i2cAddress, - .baudRate_kbps = gWarpI2cBaudRateKbps}; + .address = deviceBMX055gyroState.i2cAddress, + .baudRate_kbps = gWarpI2cBaudRateKbps + }; cmdBuf[0] = deviceRegister; @@ -604,7 +608,6 @@ printSensorDataBMX055mag(bool hexModeFlag) */ readSensorRegisterValueCombined = (readSensorRegisterValueCombined ^ (1 << 12)) - (1 << 12); - if (i2cReadStatus != kWarpStatusOK) { warpPrint(" ----,"); @@ -705,10 +708,10 @@ appendSensorDataBMX055accel(uint8_t* buf) { uint8_t index = 0; - uint16_t readSensorRegisterValueLSB; - uint16_t readSensorRegisterValueMSB; - int16_t readSensorRegisterValueCombined; - WarpStatus i2cReadStatus; + uint16_t readSensorRegisterValueLSB; + uint16_t readSensorRegisterValueMSB; + int16_t readSensorRegisterValueCombined; + WarpStatus i2cReadStatus; warpScaleSupplyVoltage(deviceBMX055accelState.operatingVoltageMillivolts); i2cReadStatus = readSensorRegisterBMX055accel(kWarpSensorOutputRegisterBMX055accelACCD_X_LSB, 2 /* numberOfBytes */); @@ -837,10 +840,10 @@ appendSensorDataBMX055gyro(uint8_t* buf) { uint8_t index = 0; - uint16_t readSensorRegisterValueLSB; - uint16_t readSensorRegisterValueMSB; - int16_t readSensorRegisterValueCombined; - WarpStatus i2cReadStatus; + uint16_t readSensorRegisterValueLSB; + uint16_t readSensorRegisterValueMSB; + int16_t readSensorRegisterValueCombined; + WarpStatus i2cReadStatus; warpScaleSupplyVoltage(deviceBMX055gyroState.operatingVoltageMillivolts); i2cReadStatus = readSensorRegisterBMX055gyro(kWarpSensorOutputRegisterBMX055gyroRATE_X_LSB, 2 /* numberOfBytes */); @@ -938,10 +941,10 @@ appendSensorDataBMX055mag(uint8_t* buf) { uint8_t index = 0; - uint16_t readSensorRegisterValueLSB; - uint16_t readSensorRegisterValueMSB; - int16_t readSensorRegisterValueCombined; - WarpStatus i2cReadStatus; + uint16_t readSensorRegisterValueLSB; + uint16_t readSensorRegisterValueMSB; + int16_t readSensorRegisterValueCombined; + WarpStatus i2cReadStatus; warpScaleSupplyVoltage(deviceBMX055magState.operatingVoltageMillivolts); i2cReadStatus = readSensorRegisterBMX055mag(kWarpSensorOutputRegisterBMX055magX_LSB, 2 /* numberOfBytes */); diff --git a/src/boot/ksdk1.1.0/devBNO055.c b/src/boot/ksdk1.1.0/devBNO055.c new file mode 100644 index 000000000..7bb84fb62 --- /dev/null +++ b/src/boot/ksdk1.1.0/devBNO055.c @@ -0,0 +1,445 @@ +#include + +/* + * config.h needs to come first + */ +#include "config.h" + +#include "fsl_misc_utilities.h" +#include "fsl_device_registers.h" +#include "fsl_i2c_master_driver.h" +#include "fsl_spi_master_driver.h" +#include "fsl_rtc_driver.h" +#include "fsl_clock_manager.h" +#include "fsl_power_manager.h" +#include "fsl_mcglite_hal.h" +#include "fsl_port_hal.h" + +#include "gpio_pins.h" +#include "SEGGER_RTT.h" +#include "warp.h" + + +extern volatile WarpI2CDeviceState deviceBNO055State; +extern volatile WarpI2CDeviceState deviceBNO055accelState; +extern volatile WarpI2CDeviceState deviceBNO055gyroState; +extern volatile WarpI2CDeviceState deviceBNO055magState; +extern volatile uint32_t gWarpI2cBaudRateKbps; +extern volatile uint32_t gWarpI2cTimeoutMilliseconds; +extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; + +void +initBNO055(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) +{ + deviceBNO055State.i2cAddress = i2cAddress; + deviceBNO055State.operatingVoltageMillivolts = operatingVoltageMillivolts; + + return; +} + +WarpStatus +writeSensorRegisterBNO055(uint8_t deviceRegister, uint8_t payload) +{ + uint8_t payloadByte[1], commandByte[1]; + i2c_status_t status; + + if (deviceRegister > 0x3F) + { + return kWarpStatusBadDeviceCommand; + } + + i2c_device_t slave = + { + .address = deviceBNO055State.i2cAddress, + .baudRate_kbps = gWarpI2cBaudRateKbps + }; + + commandByte[0] = deviceRegister; + payloadByte[0] = payload; + + warpScaleSupplyVoltage(deviceBNO055State.operatingVoltageMillivolts); + warpEnableI2Cpins(); + status = I2C_DRV_MasterSendDataBlocking( + 0 /* I2C instance */, + &slave, + commandByte, + 1, + payloadByte, + 1, + gWarpI2cTimeoutMilliseconds); + if (status != kStatus_I2C_Success) + { + return kWarpStatusDeviceCommunicationFailed; + } + + return kWarpStatusOK; +} + +WarpStatus +configureSensorRegisterBNO055(uint8_t payloadOP_Mode, uint8_t payloadPWR_Mode) +{ + WarpStatus status1, status2; + + warpScaleSupplyVoltage(deviceBNO055State.operatingVoltageMillivolts); + status1 = writeSensorRegisterBNO055(kWarpSensorConfigurationRegisterBNO055_OPR_MODE /* register address PMU_RANGE */, + payloadOP_Mode /* payload */ + ); + status2 = writeSensorRegisterBNO055(kWarpSensorConfigurationRegisterBNO055_PWR_MODE /* register address PMU_RANGE */, + payloadPWR_Mode /* payload */ + ); + + OSA_TimeDelay(7); + + + return (status1 | status2); +} + +WarpStatus +readSensorRegisterBNO055(uint8_t deviceRegister, int numberOfBytes) +{ + uint8_t cmdBuf[1] = {0xFF}; + i2c_status_t status; + + i2c_device_t slave = + { + .address = deviceBNO055State.i2cAddress, + .baudRate_kbps = gWarpI2cBaudRateKbps + }; + cmdBuf[0] = deviceRegister; + warpScaleSupplyVoltage(deviceBNO055State.operatingVoltageMillivolts); + warpEnableI2Cpins(); + + status = I2C_DRV_MasterReceiveDataBlocking( + 0 /* I2C peripheral instance */, + &slave, + cmdBuf, + 1, + (uint8_t *)deviceBNO055State.i2cBuffer, + numberOfBytes, + gWarpI2cTimeoutMilliseconds); + + if (status != kStatus_I2C_Success) + { + return kWarpStatusDeviceCommunicationFailed; + } + return kWarpStatusOK; +} + +void +printSensorDataBNO055(bool hexModeFlag) { + int16_t readSensorRegisterValueLSB; + int16_t readSensorRegisterValueMSB; + int16_t readSensorRegisterValueCombined; + WarpStatus i2cReadStatus; + int16_t accX, accY, accZ, magX, magY, magZ, gyrX, gyrY, gyrZ; + + i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Accel_Data_X_LSB, 6); + + accX = (int16_t)((deviceBNO055State.i2cBuffer[1] << 8) | deviceBNO055State.i2cBuffer[0]); + accY = (int16_t)((deviceBNO055State.i2cBuffer[3] << 8) | deviceBNO055State.i2cBuffer[2]); + accZ = (int16_t)((deviceBNO055State.i2cBuffer[5] << 8) | deviceBNO055State.i2cBuffer[4]); + + if (i2cReadStatus != kWarpStatusOK) + { + warpPrint(" ----,"); + } + else + { + if (hexModeFlag) + { + warpPrint(" 0x%02x 0x%02x,", readSensorRegisterValueMSB, readSensorRegisterValueLSB); + } + else + { + warpPrint(" %d, %d, %d,", accX, accY, accZ); + } + } + + i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Mag_Data_X_LSB, 6); + + magX = (int16_t)((deviceBNO055State.i2cBuffer[1] << 8) | deviceBNO055State.i2cBuffer[0]); + magY = (int16_t)((deviceBNO055State.i2cBuffer[3] << 8) | deviceBNO055State.i2cBuffer[2]); + magZ = (int16_t)((deviceBNO055State.i2cBuffer[5] << 8) | deviceBNO055State.i2cBuffer[4]); + + if (i2cReadStatus != kWarpStatusOK) + { + warpPrint(" ----,"); + } + else + { + if (hexModeFlag) + { + warpPrint(" 0x%02x 0x%02x,", readSensorRegisterValueMSB, readSensorRegisterValueLSB); + } + else + { + warpPrint(" %d,%d, %d,", magX, magY, magZ); + } + } + + warpScaleSupplyVoltage(deviceBNO055State.operatingVoltageMillivolts); + i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Gyro_Data_X_LSB, 6); + + gyrX = (int16_t)((deviceBNO055State.i2cBuffer[1] << 8) | deviceBNO055State.i2cBuffer[0]); + gyrY = (int16_t)((deviceBNO055State.i2cBuffer[3] << 8) | deviceBNO055State.i2cBuffer[2]); + gyrZ = (int16_t)((deviceBNO055State.i2cBuffer[5] << 8) | deviceBNO055State.i2cBuffer[4]); + + if (i2cReadStatus != kWarpStatusOK) + { + warpPrint(" ----,"); + } + else + { + if (hexModeFlag) + { + warpPrint(" 0x%02x 0x%02x,", readSensorRegisterValueMSB, readSensorRegisterValueLSB); + } + else + { + warpPrint(" %d,%d,%d,", gyrX, gyrY, gyrZ); + } + } + +} + +WarpStatus +StateBNO055() +{ + WarpStatus status; + status = readSensorRegisterBNO055(0x3E , 1); + warpPrint("BNO055 PWR_MODE: %x\n", deviceBNO055State.i2cBuffer[0]); + status = readSensorRegisterBNO055(0x3D , 1); + warpPrint("BNO055 OP_MODE: %x\n", deviceBNO055State.i2cBuffer[0]); + return status; +} + +uint8_t +appendSensorDataBNO055(uint8_t* buf) +{ + uint8_t index = 0; + + int16_t readSensorRegisterValueLSB; + int16_t readSensorRegisterValueMSB; + int16_t readSensorRegisterValueCombined; + WarpStatus i2cReadStatus; + + warpScaleSupplyVoltage(deviceBNO055State.operatingVoltageMillivolts); + + /* + * First, trigger a measurement + */ + + i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Accel_Data_X_LSB, 2); + readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0]; + readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1]; + readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB; + + + if ((i2cReadStatus != kWarpStatusOK)) + { + buf[index] = 0; + index += 1; + } + else + { + /* + * MSB first + */ + buf[index] = (uint8_t)(readSensorRegisterValueCombined >> 24); + index += 1; + + buf[index] = (uint8_t)(readSensorRegisterValueCombined >> 16); + index += 1; + + } + + i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Accel_Data_Y_LSB, 2); + readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0]; + readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1]; + readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB; + + if ((i2cReadStatus != kWarpStatusOK)) + { + buf[index] = 0; + index += 1; + } + else + { + /* + * MSB first + */ + buf[index] = (uint8_t)(readSensorRegisterValueCombined >> 24); + index += 1; + + buf[index] = (uint8_t)(readSensorRegisterValueCombined >> 16); + index += 1; + + } + + i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Accel_Data_Z_LSB, 2); + readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0]; + readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1]; + readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB; + + if ((i2cReadStatus != kWarpStatusOK)) + { + buf[index] = 0; + index += 1; + } + else + { + /* + * MSB first + */ + buf[index] = (uint8_t)(readSensorRegisterValueCombined >> 24); + index += 1; + + buf[index] = (uint8_t)(readSensorRegisterValueCombined >> 16); + index += 1; + + } + + i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Mag_Data_X_LSB, 2); + readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0]; + readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1]; + readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB; + + if ((i2cReadStatus != kWarpStatusOK)) + { + buf[index] = 0; + index += 1; + } + else + { + /* + * MSB first + */ + buf[index] = (uint8_t)(readSensorRegisterValueCombined >> 24); + index += 1; + + buf[index] = (uint8_t)(readSensorRegisterValueCombined >> 16); + index += 1; + + } + + i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Mag_Data_Y_LSB, 2); + readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0]; + readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1]; + readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB; + + if ((i2cReadStatus != kWarpStatusOK)) + { + buf[index] = 0; + index += 1; + } + else + { + /* + * MSB first + */ + buf[index] = (uint8_t)(readSensorRegisterValueCombined >> 24); + index += 1; + + buf[index] = (uint8_t)(readSensorRegisterValueCombined >> 16); + index += 1; + + } + + i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Mag_Data_Z_LSB, 2); + readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0]; + readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1]; + readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB; + + if ((i2cReadStatus != kWarpStatusOK)) + { + buf[index] = 0; + index += 1; + } + else + { + /* + * MSB first + */ + buf[index] = (uint8_t)(readSensorRegisterValueCombined >> 24); + index += 1; + + buf[index] = (uint8_t)(readSensorRegisterValueCombined >> 16); + index += 1; + + } + + i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Gyro_Data_X_LSB, 2); + readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0]; + readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1]; + readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB; + + if ((i2cReadStatus != kWarpStatusOK)) + { + buf[index] = 0; + index += 1; + } + else + { + /* + * MSB first + */ + buf[index] = (uint8_t)(readSensorRegisterValueCombined >> 24); + index += 1; + + buf[index] = (uint8_t)(readSensorRegisterValueCombined >> 16); + index += 1; + + } + + i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Gyro_Data_Y_LSB, 2); + readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0]; + readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1]; + readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB; + + if ((i2cReadStatus != kWarpStatusOK)) + { + buf[index] = 0; + index += 1; + + } + else + { + /* + * MSB first + */ + buf[index] = (uint8_t)(readSensorRegisterValueCombined >> 24); + index += 1; + + buf[index] = (uint8_t)(readSensorRegisterValueCombined >> 16); + index += 1; + + } + + i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Gyro_Data_Z_LSB, 2); + readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0]; + readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1]; + readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB; + + if ((i2cReadStatus != kWarpStatusOK)) + { + buf[index] = 0; + index += 1; + } + else + { + /* + * MSB first + */ + buf[index] = (uint8_t)(readSensorRegisterValueCombined >> 24); + index += 1; + + buf[index] = (uint8_t)(readSensorRegisterValueCombined >> 16); + index += 1; + + } + + /* + * total number of bytes written + */ + return index; +} \ No newline at end of file diff --git a/src/boot/ksdk1.1.0/devBNO055.h b/src/boot/ksdk1.1.0/devBNO055.h new file mode 100644 index 000000000..6954295f2 --- /dev/null +++ b/src/boot/ksdk1.1.0/devBNO055.h @@ -0,0 +1,9 @@ +void initBNO055(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts); +WarpStatus readSensorRegisterBNO055(uint8_t deviceRegister, int numberOfBytes); +WarpStatus writeSensorRegisterBNO055(uint8_t deviceRegister, uint8_t payload); +WarpStatus configureSensorRegisterBNO055(uint8_t payloadOP_Mode, uint8_t payloadPWR_Mode); +void printSensorDataBNO055(bool hexModeFlag); +WarpStatus StateBNO055(); +uint8_t appendSensorDataBNO055(uint8_t* buf); + + diff --git a/src/boot/ksdk1.1.0/devCCS811.c b/src/boot/ksdk1.1.0/devCCS811.c index 9c720ccb0..65c2e79c0 100644 --- a/src/boot/ksdk1.1.0/devCCS811.c +++ b/src/boot/ksdk1.1.0/devCCS811.c @@ -57,9 +57,9 @@ #include "warp.h" extern volatile WarpI2CDeviceState deviceCCS811State; -extern volatile uint32_t gWarpI2cBaudRateKbps; -extern volatile uint32_t gWarpI2cTimeoutMilliseconds; -extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; +extern volatile uint32_t gWarpI2cBaudRateKbps; +extern volatile uint32_t gWarpI2cTimeoutMilliseconds; +extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; @@ -69,7 +69,7 @@ extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; void initCCS811(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) { - deviceCCS811State.i2cAddress = i2cAddress; + deviceCCS811State.i2cAddress = i2cAddress; deviceCCS811State.operatingVoltageMillivolts = operatingVoltageMillivolts; return; diff --git a/src/boot/ksdk1.1.0/devHDC1000.c b/src/boot/ksdk1.1.0/devHDC1000.c index b703a82b6..a66defda6 100644 --- a/src/boot/ksdk1.1.0/devHDC1000.c +++ b/src/boot/ksdk1.1.0/devHDC1000.c @@ -57,15 +57,15 @@ #include "warp.h" extern volatile WarpI2CDeviceState deviceHDC1000State; -extern volatile uint32_t gWarpI2cBaudRateKbps; -extern volatile uint32_t gWarpI2cTimeoutMilliseconds; -extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; +extern volatile uint32_t gWarpI2cBaudRateKbps; +extern volatile uint32_t gWarpI2cTimeoutMilliseconds; +extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; void initHDC1000(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) { - deviceHDC1000State.i2cAddress = i2cAddress; + deviceHDC1000State.i2cAddress = i2cAddress; deviceHDC1000State.operatingVoltageMillivolts = operatingVoltageMillivolts; return; @@ -93,8 +93,9 @@ writeSensorRegisterHDC1000(uint8_t deviceRegister, uint16_t payload) i2c_device_t slave = { - .address = deviceHDC1000State.i2cAddress, - .baudRate_kbps = gWarpI2cBaudRateKbps}; + .address = deviceHDC1000State.i2cAddress, + .baudRate_kbps = gWarpI2cBaudRateKbps + }; warpScaleSupplyVoltage(deviceHDC1000State.operatingVoltageMillivolts); diff --git a/src/boot/ksdk1.1.0/devIS25xP.c b/src/boot/ksdk1.1.0/devIS25xP.c index b753a5c80..bcc547a9f 100644 --- a/src/boot/ksdk1.1.0/devIS25xP.c +++ b/src/boot/ksdk1.1.0/devIS25xP.c @@ -64,10 +64,10 @@ extern uint8_t gWarpSpiCommonSinkBuffer[]; extern uint16_t gWarpBuffAddress; uint8_t gFlashWriteLimit = 0x20; - uint8_t deviceOpsBuffer[kWarpMemoryCommonSpiBufferBytes]; -void initIS25xP(int chipSelectIoPinID, uint16_t operatingVoltageMillivolts) +void +initIS25xP(int chipSelectIoPinID, uint16_t operatingVoltageMillivolts) { deviceIS25xPState.chipSelectIoPinID = chipSelectIoPinID; deviceIS25xPState.spiSourceBuffer = gWarpSpiCommonSourceBuffer; @@ -154,7 +154,8 @@ spiTransactionIS25xP(uint8_t ops[], size_t opCount) return kWarpStatusOK; } -void enableIS25xPWrite() +void +enableIS25xPWrite() { WarpStatus status; uint8_t ops[1] = @@ -168,7 +169,8 @@ void enableIS25xPWrite() } } -void disableIS25xPWrite() +void +disableIS25xPWrite() { WarpStatus status; uint8_t ops[] = @@ -203,13 +205,9 @@ programSingleIS25xPWithoutOffsetUpdate(uint16_t* pageNumber_p, uint8_t* pageOffs } } - if (excess > 0) { + if (excess > 0) + { status = programPageIS25xP(*pageNumber_p, *pageOffset_p, excess, buf + (nIterations * gFlashWriteLimit)); - if (status != kWarpStatusOK) - { - warpPrint("\r\n\tError: programPageIS25xP failed"); - return status; - } *pageOffset_p += excess; } @@ -234,7 +232,8 @@ programMultipleIS25xPWithoutOffsetUpdate(uint16_t* pageNumber_p, uint8_t* pageOf *pageOffset_p = 0; status = programMultipleIS25xPWithoutOffsetUpdate(pageNumber_p, pageOffset_p, nbyte - nByteToWrite, buf + (nByteToWrite)); - } else + } + else { status = programSingleIS25xPWithoutOffsetUpdate(pageNumber_p, pageOffset_p, nbyte, buf); if (status != kWarpStatusOK) @@ -335,66 +334,6 @@ resetIS25xP() return kWarpStatusOK; } -// WarpStatus getCurrentPage - -WarpStatus readAllMemoryIS25xP() -{ - WarpStatus status; - - uint8_t pageOffsetBuf[3]; - status = readMemoryIS25xP(kWarpIS25xPPageOffsetStoragePage, kWarpIS25xPPageOffsetStorageOffset, kWarpIS25xPPageOffsetStorageSize, pageOffsetBuf); - if (status != kWarpStatusOK) - { - return status; - } - - uint8_t pageOffset = pageOffsetBuf[2]; - uint16_t pageNumber = pageOffsetBuf[1] | pageOffsetBuf[0] << 8; - - warpPrint("\r\n\tPage number: %d\t page offset: %d\n", pageNumber, pageOffset); - - uint32_t startAddress = kWarpInitialPageOffsetIS25xP | kWarpInitialPageNumberIS25xP << 8; - - uint32_t endAddress = pageOffset | pageNumber << 8; - - size_t n_iterations = (endAddress - startAddress) / gFlashWriteLimit; - size_t excess = (endAddress - startAddress) % gFlashWriteLimit; - - uint8_t ops[kWarpMemoryCommonSpiBufferBytes] = {0}; - ops[0] = 0x03; /* NORD */ - - warpPrint("Data start\n"); - for (int i = 0; i < n_iterations; i++) { - ops[3] = (uint8_t)(startAddress); - ops[2] = (uint8_t)(startAddress >> 8); - ops[1] = (uint8_t)(startAddress >> 16); - status = spiTransactionIS25xP(ops, kWarpMemoryCommonSpiBufferBytes); - if (status != kWarpStatusOK) - { - return status; - } - for (size_t i = 0; i < gFlashWriteLimit; i++) { - warpPrint("%c", deviceIS25xPState.spiSinkBuffer[i + 4]); - } - - startAddress += gFlashWriteLimit; - } - - ops[3] = (uint8_t)(startAddress); - ops[2] = (uint8_t)(startAddress >> 8); - ops[1] = (uint8_t)(startAddress >> 16); - status = spiTransactionIS25xP(ops, kWarpMemoryCommonSpiBufferBytes); - if (status != kWarpStatusOK) - { - return status; - } - for (size_t i = 0; i < excess; i++) { - warpPrint("%c", deviceIS25xPState.spiSinkBuffer[i + 4]); - } - warpPrint("Data end\n"); - return kWarpStatusOK; -} - WarpStatus readMemoryIS25xP(uint16_t startPageNumber, uint8_t startPageOffset, size_t nbyte, void *buf) { @@ -408,45 +347,42 @@ readMemoryIS25xP(uint16_t startPageNumber, uint8_t startPageOffset, size_t nbyte size_t nBytesBeingRead; uint16_t nextPageNumber; uint8_t nextPageOffset; - // warpPrint("\nReading %d bytes from page %d, offset %d\n", nbyte, startPageNumber, startPageOffset); size_t nBytesRemainingInPage = kWarpSizeAT45DBPageSizeBytes - startPageOffset; size_t nBytesSpiLimit = kWarpMemoryCommonSpiBufferBytes - 4; - // warpPrint("nBytesRemaining: %d, nByte: %d\n", nBytesRemainingInPage, nbyte); if (nBytesRemainingInPage < nbyte) { - // warpPrint("nBytesRemainingInPage < nbyte\n"); if (nBytesRemainingInPage > nBytesSpiLimit) { nBytesBeingRead = nBytesSpiLimit; nextPageNumber = startPageNumber; nextPageOffset = startPageOffset + nBytesSpiLimit; - } else + } + else { nBytesBeingRead = nBytesRemainingInPage; nextPageNumber = startPageNumber + 1; nextPageOffset = 0; } - } else + } + else { - // warpPrint("nBytesRemainingInPage >= nbyte\n"); if (nbyte > nBytesSpiLimit) { nBytesBeingRead = nBytesSpiLimit; nextPageNumber = startPageNumber; nextPageOffset = startPageOffset + nBytesSpiLimit; - } else + } + else { nBytesBeingRead = nbyte; nextPageNumber = startPageNumber; nextPageOffset = startPageOffset + nbyte; } } - // warpPrint("nBytesBeingRead: %d\n", nBytesBeingRead); size_t nBytesRemaining = nbyte - nBytesBeingRead; - // warpPrint("nBytesRemaining: %d\n", nBytesRemaining); deviceOpsBuffer[0] = 0x03; /* NORD */ deviceOpsBuffer[2] = (uint8_t)(startPageNumber); @@ -544,46 +480,6 @@ eraseSectorIS25xP(uint32_t address) return kWarpStatusOK; } -WarpStatus -erase32kBlockIS25xP(uint32_t address) -{ - WarpStatus status; - - uint8_t ops[4] = {0}; - ops[0] = 0x52; /* BER32K (SPI Mode) */ - ops[1] = (uint8_t)((address & 0x0F00) >> 2); - ops[2] = (uint8_t)((address & 0x00F0) >> 1); - ops[3] = (uint8_t)((address & 0x000F)); - - status = spiTransactionIS25xP(ops, 4); - if (status != kWarpStatusOK) - { - warpPrint("\r\n\tError: communication failed"); - return status; - } - return kWarpStatusOK; -} - -WarpStatus -erase64kBlockIS25xP(uint32_t address) -{ - WarpStatus status; - - uint8_t ops[4] = {0}; - ops[0] = 0xD8; /* BER64K (SPI Mode) */ - ops[1] = (uint8_t)((address & 0x0F00) >> 2); - ops[2] = (uint8_t)((address & 0x00F0) >> 1); - ops[3] = (uint8_t)((address & 0x000F)); - - status = spiTransactionIS25xP(ops, 4); - if (status != kWarpStatusOK) - { - warpPrint("\r\n\tError: communication failed"); - return status; - } - return kWarpStatusOK; -} - WarpStatus chipEraseIS25xP() { @@ -609,7 +505,8 @@ chipEraseIS25xP() WarpStatus flashStatusIS25xP() { - uint8_t ops4[2] = { + uint8_t ops4[2] = + { /* Read Status Register */ 0x05, /* Byte0 */ 0x00, /* Dummy Byte1 */ @@ -621,16 +518,17 @@ flashStatusIS25xP() } else { - warpPrint("Status = [" BYTE_TO_BINARY_PATTERN "]\n", + warpPrint("Flash Status = [" BYTE_TO_BINARY_PATTERN "]\n", BYTE_TO_BINARY(deviceIS25xPState.spiSinkBuffer[1])); + return kWarpStatusOK; } - return kWarpStatusOK; } WarpStatus waitForWriteCompletion() { - uint8_t ops4[] = { + uint8_t ops4[] = + { /* Read Status Register */ 0x05, /* Byte0 */ 0x00, /* Dummy Byte1 */ @@ -656,4 +554,43 @@ waitForWriteCompletion() } } return kWarpStatusOK; +} +WarpStatus +deepPowerModeIS25xP() +{ + enableIS25xPWrite(); + uint8_t ops[1] = {0}; + + ops[0] = 0xB9; /* CER (SPI Mode) */ + + WarpStatus status; + status = spiTransactionIS25xP(ops, 1); + if (status != kWarpStatusOK) + { + warpPrint("\r\n\tError: communication failed"); + return status; + } + waitForWriteCompletion(); + + + return status; +} +WarpStatus +releaseDeepPowerModeIS25xP() +{ + enableIS25xPWrite(); + uint8_t ops[1] = {0}; + + ops[0] = 0xAB; /* CER (SPI Mode) */ + + WarpStatus status; + status = spiTransactionIS25xP(ops, 1); + if (status != kWarpStatusOK) + { + warpPrint("\r\n\tError: communication failed"); + return status; + } + waitForWriteCompletion(); + + return status; } \ No newline at end of file diff --git a/src/boot/ksdk1.1.0/devIS25xP.h b/src/boot/ksdk1.1.0/devIS25xP.h index 228ccd583..cd20a19de 100644 --- a/src/boot/ksdk1.1.0/devIS25xP.h +++ b/src/boot/ksdk1.1.0/devIS25xP.h @@ -65,7 +65,6 @@ WarpStatus spiTransactionIS25xP(uint8_t ops[], size_t opCount); * @param nbyte Number of bytes to read from the flash memory. * @param buf Buffer to place the read values in. Must fit `nbyte` bytes. */ -WarpStatus readAllMemoryIS25xP(); WarpStatus readMemoryIS25xP(uint16_t startPageNumber, uint8_t startPageOffset, size_t nbyte, void* buf); WarpStatus programPageIS25xP(uint16_t startPageAddress, uint8_t startPageOffset, size_t nbyte, uint8_t* buf); WarpStatus eraseSectorIS25xP(uint32_t address); @@ -78,4 +77,6 @@ WarpStatus writeToIS25xPFromEnd(size_t nbyte, uint8_t* buf); void enableIS25xPWrite(); void disableIS25xPWrite(); WarpStatus flashStatusIS25xP(); -WarpStatus waitForWriteCompletion(); \ No newline at end of file +WarpStatus waitForWriteCompletion(); +WarpStatus deepPowerModeIS25xP(); +WarpStatus releaseDeepPowerModeIS25xP(); \ No newline at end of file diff --git a/src/boot/ksdk1.1.0/devL3GD20H.c b/src/boot/ksdk1.1.0/devL3GD20H.c index fdd711ad0..53693d1dd 100644 --- a/src/boot/ksdk1.1.0/devL3GD20H.c +++ b/src/boot/ksdk1.1.0/devL3GD20H.c @@ -58,16 +58,16 @@ extern volatile WarpI2CDeviceState deviceL3GD20HState; -extern volatile uint32_t gWarpI2cBaudRateKbps; -extern volatile uint32_t gWarpI2cTimeoutMilliseconds; -extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; +extern volatile uint32_t gWarpI2cBaudRateKbps; +extern volatile uint32_t gWarpI2cTimeoutMilliseconds; +extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; void initL3GD20H(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) { - deviceL3GD20HState.i2cAddress = i2cAddress; + deviceL3GD20HState.i2cAddress = i2cAddress; deviceL3GD20HState.operatingVoltageMillivolts = operatingVoltageMillivolts; return; diff --git a/src/boot/ksdk1.1.0/devL3GD20H.h b/src/boot/ksdk1.1.0/devL3GD20H.h index a95452106..3f59e7dcd 100644 --- a/src/boot/ksdk1.1.0/devL3GD20H.h +++ b/src/boot/ksdk1.1.0/devL3GD20H.h @@ -44,5 +44,5 @@ void printSensorDataL3GD20H(bool hexModeFlag); uint8_t appendSensorDataL3GD20H(uint8_t* buf); const uint8_t bytesPerMeasurementL3GD20H = 8; -const uint8_t bytesPerReadingL3GD20H = 2; +const uint8_t bytesPerReadingL3GD20H = 2; const uint8_t numberOfReadingsPerMeasurementL3GD20H = 4; \ No newline at end of file diff --git a/src/boot/ksdk1.1.0/devLPS25H.c b/src/boot/ksdk1.1.0/devLPS25H.c index 5a18d7ad0..1aa766229 100644 --- a/src/boot/ksdk1.1.0/devLPS25H.c +++ b/src/boot/ksdk1.1.0/devLPS25H.c @@ -57,16 +57,16 @@ extern volatile WarpI2CDeviceState deviceLPS25HState; -extern volatile uint32_t gWarpI2cBaudRateKbps; -extern volatile uint32_t gWarpI2cTimeoutMilliseconds; -extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; +extern volatile uint32_t gWarpI2cBaudRateKbps; +extern volatile uint32_t gWarpI2cTimeoutMilliseconds; +extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; void initLPS25H(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) { - deviceLPS25HState.i2cAddress = i2cAddress; + deviceLPS25HState.i2cAddress = i2cAddress; deviceLPS25HState.operatingVoltageMillivolts = operatingVoltageMillivolts; return; @@ -86,7 +86,7 @@ readSensorRegisterLPS25H(uint8_t deviceRegister, int numberOfBytes) } i2c_device_t slave = - { + { .address = deviceLPS25HState.i2cAddress, .baudRate_kbps = gWarpI2cBaudRateKbps }; diff --git a/src/boot/ksdk1.1.0/devMAG3110.c b/src/boot/ksdk1.1.0/devMAG3110.c index aa69c4c77..9fcb573ea 100644 --- a/src/boot/ksdk1.1.0/devMAG3110.c +++ b/src/boot/ksdk1.1.0/devMAG3110.c @@ -58,15 +58,15 @@ #include "warp.h" extern volatile WarpI2CDeviceState deviceMAG3110State; -extern volatile uint32_t gWarpI2cBaudRateKbps; -extern volatile uint32_t gWarpI2cTimeoutMilliseconds; -extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; +extern volatile uint32_t gWarpI2cBaudRateKbps; +extern volatile uint32_t gWarpI2cTimeoutMilliseconds; +extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; void initMAG3110(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) { - deviceMAG3110State.i2cAddress = i2cAddress; + deviceMAG3110State.i2cAddress = i2cAddress; deviceMAG3110State.operatingVoltageMillivolts = operatingVoltageMillivolts; return; diff --git a/src/boot/ksdk1.1.0/devMAX11300_FC.c b/src/boot/ksdk1.1.0/devMAX11300_FC.c index 8023f0c74..ae20f9b01 100644 --- a/src/boot/ksdk1.1.0/devMAX11300_FC.c +++ b/src/boot/ksdk1.1.0/devMAX11300_FC.c @@ -63,7 +63,8 @@ enum }; -int writeCommand(uint8_t Register_Byte, uint16_t Command_Bytes, bool W_R) /* W_R = 0/1 (Write/Read) */ +int +writeCommand(uint8_t Register_Byte, uint16_t Command_Bytes, bool W_R) /* W_R = 0/1 (Write/Read) */ { spi_status_t status; @@ -103,7 +104,9 @@ int writeCommand(uint8_t Register_Byte, uint16_t Command_Bytes, bool W_R) /* W_R /* - - - - - - - - - - - - - - - - - - - - - - */ -void read_ID(void){ +void +read_ID(void) +{ SEGGER_RTT_printf(0, "\r\t Address (R/W): 0x%x Commands: 0x%x 0x%x \n", payloadBytes[0], payloadBytes[1], payloadBytes[2]); OSA_TimeDelay(10); writeCommand(0x00, 0x0000, 1); /* READ DEVICE ID: 0x00 (1) [Read] */ @@ -113,9 +116,12 @@ void read_ID(void){ /* - - - - - - - - - - - - - - - - - - - - - - */ -int read_1_digit(int Lower_limit, int Higher_limit){ +int +read_1_digit(int Lower_limit, int Higher_limit) +{ int number = -1; - while (!(number >= Lower_limit && number <= Higher_limit)){ + while (!(number >= Lower_limit && number <= Higher_limit)) + { number = SEGGER_RTT_WaitKey() - '0'; } return number; @@ -123,11 +129,14 @@ int read_1_digit(int Lower_limit, int Higher_limit){ /* - - - - - - - - - - - - - - - - - - - - - - */ -int read_2_digits(int Lower_limit, int Higher_limit){ +int +read_2_digits(int Lower_limit, int Higher_limit) +{ int Digit1 = 0; int Digit2 = 0; int number = -1; - while (!(number >= Lower_limit && number <= Higher_limit)){ + while (!(number >= Lower_limit && number <= Higher_limit)) + { Digit1 = SEGGER_RTT_WaitKey() - '0'; Digit2 = SEGGER_RTT_WaitKey() - '0'; number = Digit1*10 + Digit2; @@ -137,13 +146,16 @@ int read_2_digits(int Lower_limit, int Higher_limit){ /* - - - - - - - - - - - - - - - - - - - - - - */ -int read_4_digits(int Lower_limit, int Higher_limit){ +int +read_4_digits(int Lower_limit, int Higher_limit) +{ int Digit1 = 0; int Digit2 = 0; int Digit3 = 0; int Digit4 = 0; int number = -1; - while (!(number >= Lower_limit && number <= Higher_limit)){ + while (!(number >= Lower_limit && number <= Higher_limit)) + { Digit1 = SEGGER_RTT_WaitKey() - '0'; Digit2 = SEGGER_RTT_WaitKey() - '0'; Digit3 = SEGGER_RTT_WaitKey() - '0'; @@ -155,14 +167,17 @@ int read_4_digits(int Lower_limit, int Higher_limit){ /* - - - - - - - - - - - - - - - - - - - - - - */ -int read_5_digits(int Lower_limit, int Higher_limit){ +int +read_5_digits(int Lower_limit, int Higher_limit) +{ int Digit1 = 0; int Digit2 = 0; int Digit3 = 0; int Digit4 = 0; int Digit5 = 0; int number = -1; - while (!(number >= Lower_limit && number <= Higher_limit)){ + while (!(number >= Lower_limit && number <= Higher_limit)) + { Digit1 = SEGGER_RTT_WaitKey() - '0'; Digit2 = SEGGER_RTT_WaitKey() - '0'; Digit3 = SEGGER_RTT_WaitKey() - '0'; @@ -175,9 +190,12 @@ int read_5_digits(int Lower_limit, int Higher_limit){ /* - - - - - - - - - - - - - - - - - - - - - - */ -uint16_t assemble_Command(bool D[16]){ +uint16_t +assemble_Command(bool D[16]) +{ uint16_t Command = 0; - for(int i=0; i<16; i++){ + for(int i=0; i<16; i++) + { Command |= D[i] << i; } return Command; @@ -185,7 +203,9 @@ uint16_t assemble_Command(bool D[16]){ /* - - - - - - - - - - - - - - - - - - - - - - */ -void SPI_Scope(void){ +void +SPI_Scope(void) +{ SEGGER_RTT_printf(0, "\r\t Address (R/W): 0x%x Commands: 0x%x 0x%x \n", payloadBytes[0], payloadBytes[1], payloadBytes[2]); OSA_TimeDelay(10); SEGGER_RTT_printf(0, "\r\t Bytes Received: 0x%x 0x%x 0x%x \n", inBuffer[0], inBuffer[1], inBuffer[2]); @@ -194,8 +214,9 @@ void SPI_Scope(void){ /* - - - - - - - - - - - - - - - - - - - - - - */ -uint16_t Assemble_DAC_DAT(int Data){ - +uint16_t +Assemble_DAC_DAT(int Data) +{ bool D_C_DAC_DATA[12]; for (int i = 0; i < 12; i++) { @@ -211,7 +232,9 @@ uint16_t Assemble_DAC_DAT(int Data){ /* - - - - - - - - - - - - - - - - - - - - - - */ -uint16_t Assemble_CONF(bool FUNCPRM[12], bool FUNCid[13][4], int FUNC){ +uint16_t +Assemble_CONF(bool FUNCPRM[12], bool FUNCid[13][4], int FUNC) +{ bool D_C_FUNC_DAC_ID_PRM_C[16] = { FUNCPRM[11], FUNCPRM[10], @@ -238,29 +261,37 @@ uint16_t Assemble_CONF(bool FUNCPRM[12], bool FUNCid[13][4], int FUNC){ /* - - - - - - - - - - - - - - - - - - - - - - */ -int read_1_char(char input[10]){ +int +read_1_char(char input[10]) +{ char Character = '0'; - while (!((Character == input[0] || Character == input[1]) || (Character == input[2] || Character == input[3]) || (Character == input[4] || Character == input[5]) || (Character == input[6] || Character == input[7]) || (Character == input[8] || Character == input[9]))){ + while (!((Character == input[0] || Character == input[1]) || (Character == input[2] || Character == input[3]) || (Character == input[4] || Character == input[5]) || (Character == input[6] || Character == input[7]) || (Character == input[8] || Character == input[9]))) + { Character = SEGGER_RTT_WaitKey(); } int match = 0; - if(Character == input[0] || Character == input[1]){ + if(Character == input[0] || Character == input[1]) + { match = 1; } - else if(Character == input[2] || Character == input[3]){ + else if(Character == input[2] || Character == input[3]) + { match = 2; } - else if(Character == input[4] || Character == input[5]){ + else if(Character == input[4] || Character == input[5]) + { match = 3; } - else if(Character == input[6] || Character == input[7]){ + else if(Character == input[6] || Character == input[7]) + { match = 4; } - else if(Character == input[8] || Character == input[9]){ + else if(Character == input[8] || Character == input[9]) + { match = 5; } @@ -271,7 +302,9 @@ int read_1_char(char input[10]){ /* - - - - - - - - - - - - - - - - - - - - - - */ -int devMAX11300(void){ +int +devMAX11300(void) +{ /* * Override Warp firmware's use of these pins. @@ -368,11 +401,13 @@ int devMAX11300(void){ OSA_TimeDelay(10); char Character = '0'; - while (!((Character == 'M' || Character == 'm')||(Character == 'A' || Character == 'a'))){ + while (!((Character == 'M' || Character == 'm')||(Character == 'A' || Character == 'a'))) + { Character = SEGGER_RTT_WaitKey(); } - if (Character == 'M' || Character == 'm'){ + if (Character == 'M' || Character == 'm') + { SEGGER_RTT_WriteString(0, "\r\t Manual Configutation Selected \n"); OSA_TimeDelay(10); @@ -465,7 +500,8 @@ int devMAX11300(void){ /* - - - - - - - - - - - - - - - - - - - - - - */ - if(MODE == 1 || MODE == 3 || MODE == 4 || MODE == 5 || MODE == 6 || MODE == 10){ + if(MODE == 1 || MODE == 3 || MODE == 4 || MODE == 5 || MODE == 6 || MODE == 10) + { SEGGER_RTT_WriteString(0, "\r\t Configure DACREF, DACL: \n"); OSA_TimeDelay(10); @@ -478,11 +514,13 @@ int devMAX11300(void){ 1: Internal Reference Voltage */ DACREF = read_1_digit(0, 1); - if(DACREF == 0){ + if(DACREF == 0) + { SEGGER_RTT_printf(0, "\r\t External Reference. \n"); OSA_TimeDelay(10); } - else{ + else + { SEGGER_RTT_printf(0, "\r\t Internal Reference. \n"); OSA_TimeDelay(10); } @@ -519,7 +557,8 @@ int devMAX11300(void){ /* - - - - - - - - - - - - - - - - - - - - - - */ - if (!((DACL == 2) || (DACL == 3))){ + if (!((DACL == 2) || (DACL == 3))) + { SEGGER_RTT_WriteString(0, "\r\t Enter DACDAT[i] for ports in mode 1,3,4,5,6 or 10 \n"); OSA_TimeDelay(10); @@ -546,7 +585,8 @@ int devMAX11300(void){ } - else{ + else + { SEGGER_RTT_WriteString(0, "\r\t Enter DACPRSTDAT1 or DACPRSTDAT2 DATA \n"); OSA_TimeDelay(10); @@ -580,7 +620,8 @@ int devMAX11300(void){ /* - - - - - - - - - - - - - - - - - - - - - - */ - else{ + else + { /* - - - - - - - - - - - - - - - - - - - - - - */ BRST = 0; /* 0: Default address incrementing mode */ @@ -685,34 +726,42 @@ int devMAX11300(void){ int input = 0; int c = 0; - while(c != 1){ + while(c != 1) + { - for(int i = 0; i < length; i++){ + for(int i = 0; i < length; i++) + { input = read_1_char(input_values); - if (input == 1){ + if (input == 1) + { AS_number++; AS_port[AS_number] = i; } - else if (input == 2){ + else if (input == 2) + { DAC_number++; DAC_port[DAC_number] = i; } - else if (input == 3){ + else if (input == 3) + { DAC_WAVE_number++; DAC_WAVE_port = i; } - else if (input == 4){ + else if (input == 4) + { HI_number++; HI_port[HI_number] = i; } - else if (input == 5){ + else if (input == 5) + { ADC_number++; ADC_port[ADC_number] = i; } } - if(DAC_WAVE_number > 1){ + if(DAC_WAVE_number > 1) + { SEGGER_RTT_WriteString(0, "\r\t Variable DAC Output ALREADY SELECTED \n"); OSA_TimeDelay(10); @@ -724,7 +773,8 @@ int devMAX11300(void){ DAC_WAVE_port = 0; } - else{ + else + { c = 1; } @@ -733,7 +783,8 @@ int devMAX11300(void){ /* - - - - - - - - - - - - - - - - - - - - - - */ - if (AS_number >= 1){ + if (AS_number >= 1) + { for (int k = 0; k < AS_number; k++){ /* --- --- --- AS PORT CONFIGURATION */ @@ -747,8 +798,10 @@ int devMAX11300(void){ /* - - - - - - - - - - - - - - - - - - - - - - */ - if (HI_number >= 1){ - for (int k = 0; k < HI_number; k++){ + if (HI_number >= 1) + { + for (int k = 0; k < HI_number; k++) + { /* --- --- --- HI PORT CONFIGURATION */ writeCommand(PORT_Config_Addr[HI_port[k]], S_Command4_HI, 0); /* PORT CONTROL - HI (0) [Write] */ @@ -761,9 +814,11 @@ int devMAX11300(void){ /* - - - - - - - - - - - - - - - - - - - - - - */ - if (DAC_number >= 1){ + if (DAC_number >= 1) + { - for (int k = 1; k <= DAC_number; k++){ + for (int k = 1; k <= DAC_number; k++) + { /* --- --- --- DAC PORT CONFIGURATION */ writeCommand(PORT_Config_Addr[DAC_port[k]], S_Command4_DAC, 0); /* PORT CONTROL - DAC (0) [Write] */ @@ -775,7 +830,8 @@ int devMAX11300(void){ SEGGER_RTT_printf(0, "\r\t DAC Configuration Starts. %d DACs selected. \n", DAC_number); OSA_TimeDelay(10); - for (int k = 1; k <= DAC_number; k++){ + for (int k = 1; k <= DAC_number; k++) + { SEGGER_RTT_printf(0, "\r\t Select single DAC output value for DAC # %d : \n", k); OSA_TimeDelay(10); @@ -799,7 +855,8 @@ int devMAX11300(void){ int Period = 0; - if (DAC_WAVE_number == 1){ + if (DAC_WAVE_number == 1) + { SEGGER_RTT_WriteString(0, "\r\t Variable DAC Output Configuration \n"); OSA_TimeDelay(10); @@ -833,7 +890,8 @@ int devMAX11300(void){ int WAVE_INT = 0; - for(int l = 0; l <= Period; l+=1){ + for(int l = 0; l <= Period; l+=1) + { float Slope = (Amplitude*4095/Period/1000); @@ -851,13 +909,15 @@ int devMAX11300(void){ } - if (ADC_number >= 1){ + if (ADC_number >= 1) + { SEGGER_RTT_WriteString(0, "\r\t ADCs Configuration \n"); OSA_TimeDelay(10); - for (int k = 1; k <= ADC_number; k++){ + for (int k = 1; k <= ADC_number; k++) + { /* --- --- --- ADC PORT CONFIGURATION */ writeCommand(PORT_Config_Addr[ADC_port[k]], S_Command4_ADC, 0); /* PORT CONTROL - ADC (0) [Write] */ diff --git a/src/boot/ksdk1.1.0/devMMA8451Q.c b/src/boot/ksdk1.1.0/devMMA8451Q.c index e14e3237e..f590747a7 100644 --- a/src/boot/ksdk1.1.0/devMMA8451Q.c +++ b/src/boot/ksdk1.1.0/devMMA8451Q.c @@ -58,16 +58,16 @@ extern volatile WarpI2CDeviceState deviceMMA8451QState; -extern volatile uint32_t gWarpI2cBaudRateKbps; -extern volatile uint32_t gWarpI2cTimeoutMilliseconds; -extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; +extern volatile uint32_t gWarpI2cBaudRateKbps; +extern volatile uint32_t gWarpI2cTimeoutMilliseconds; +extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; void initMMA8451Q(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) { - deviceMMA8451QState.i2cAddress = i2cAddress; + deviceMMA8451QState.i2cAddress = i2cAddress; deviceMMA8451QState.operatingVoltageMillivolts = operatingVoltageMillivolts; return; diff --git a/src/boot/ksdk1.1.0/devRF430CL331H.c b/src/boot/ksdk1.1.0/devRF430CL331H.c new file mode 100644 index 000000000..44353f23b --- /dev/null +++ b/src/boot/ksdk1.1.0/devRF430CL331H.c @@ -0,0 +1,126 @@ +#include + +/* + * config.h needs to come first + */ +#include "config.h" + +#include "fsl_misc_utilities.h" +#include "fsl_device_registers.h" +#include "fsl_i2c_master_driver.h" +#include "fsl_spi_master_driver.h" +#include "fsl_rtc_driver.h" +#include "fsl_clock_manager.h" +#include "fsl_power_manager.h" +#include "fsl_mcglite_hal.h" +#include "fsl_port_hal.h" + +#include "gpio_pins.h" +#include "SEGGER_RTT.h" +#include "warp.h" + + +extern volatile WarpI2CDeviceState deviceRF430CL331HState; +extern volatile uint32_t gWarpI2cBaudRateKbps; +extern volatile uint32_t gWarpI2cTimeoutMilliseconds; +extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; + +void +initRF430CL331H(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) +{ + deviceRF430CL331HState.i2cAddress = i2cAddress; + deviceRF430CL331HState.operatingVoltageMillivolts = operatingVoltageMillivolts; + + return; +} + +WarpStatus +writeSensorRegisterRF430CL331H(uint16_t deviceRegister, uint16_t payload) +{ + uint8_t payloadByte[2], commandByte[2]; + i2c_status_t status; + + i2c_device_t slave = + { + .address = deviceRF430CL331HState.i2cAddress, + .baudRate_kbps = gWarpI2cBaudRateKbps + }; + + commandByte[0] = (uint8_t)((deviceRegister >> 8) & 0xFF); /* MSB first */ + commandByte[1] = (uint8_t)(deviceRegister & 0xFF); /* LSB */ + payloadByte[0] =(uint8_t) ((payload >> 8) & 0xFF); /* MSB first */ + payloadByte[1] = (uint8_t)(payload & 0xFF); /* LSB */ + + warpScaleSupplyVoltage(deviceRF430CL331HState.operatingVoltageMillivolts); + warpEnableI2Cpins(); + status = I2C_DRV_MasterSendDataBlocking( + 0 /* I2C instance */, + &slave, + commandByte, + 1, + payloadByte, + 1, + gWarpI2cTimeoutMilliseconds); + if (status != kStatus_I2C_Success) + { + return kWarpStatusDeviceCommunicationFailed; + } + + return kWarpStatusOK; +} + +WarpStatus +configureSensorRegisterRF430CL331H(uint16_t payloadOP_Mode) +{ + WarpStatus status1, status2; + + warpScaleSupplyVoltage(deviceRF430CL331HState.operatingVoltageMillivolts); + status1 = writeSensorRegisterRF430CL331H(kWarpSensorConfigureationRegisterRF430CL331H_Genral /* register address PMU_RANGE */, + payloadOP_Mode /* payload */ + ); + + return (status1); +} + +WarpStatus +readSensorRegisterRF430CL331H(uint16_t deviceRegister, int numberOfBytes) +{ + uint8_t cmdBuf[2] = {0xFF}; + i2c_status_t status; + + i2c_device_t slave = + { + .address = deviceRF430CL331HState.i2cAddress, + .baudRate_kbps = gWarpI2cBaudRateKbps + }; + cmdBuf[0] = (uint8_t)((deviceRegister >> 8) & 0xFF); /* MSB first */ + cmdBuf[1] = (uint8_t)(deviceRegister & 0xFF); /* LSB */ + warpScaleSupplyVoltage(deviceRF430CL331HState.operatingVoltageMillivolts); + warpEnableI2Cpins(); + + status = I2C_DRV_MasterReceiveDataBlocking( + 0 /* I2C peripheral instance */, + &slave, + cmdBuf, + 1, + (uint8_t *)deviceRF430CL331HState.i2cBuffer, + numberOfBytes, + gWarpI2cTimeoutMilliseconds); + + if (status != kStatus_I2C_Success) + { + return kWarpStatusDeviceCommunicationFailed; + } + return kWarpStatusOK; +} + +WarpStatus +StatusRF430CL331H() +{ + WarpStatus status; + status = readSensorRegisterRF430CL331H(kWarpSensorConfigureationRegisterRF430CL331H_Genral , 2); + warpPrint("RF430Status Status = [" BYTE_TO_BINARY_PATTERN "]\n", + BYTE_TO_BINARY(deviceRF430CL331HState.i2cBuffer[0])); + return status; + +} \ No newline at end of file diff --git a/src/boot/ksdk1.1.0/devRF430CL331H.h b/src/boot/ksdk1.1.0/devRF430CL331H.h new file mode 100644 index 000000000..433110336 --- /dev/null +++ b/src/boot/ksdk1.1.0/devRF430CL331H.h @@ -0,0 +1,6 @@ + +void initRF430CL331H(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts); +WarpStatus writeSensorRegisterRF430CL331H(uint16_t deviceRegister, uint16_t payload); +WarpStatus configureSensorRegisterRF430CL331H(uint16_t payloadOP_Mode); +WarpStatus readSensorRegisterRF430CL331H(uint16_t deviceRegister, int numberOfBytes); +WarpStatus StatusRF430CL331H(); diff --git a/src/boot/ksdk1.1.0/devRV8803C7.c b/src/boot/ksdk1.1.0/devRV8803C7.c index 56806f945..3ff536f3c 100644 --- a/src/boot/ksdk1.1.0/devRV8803C7.c +++ b/src/boot/ksdk1.1.0/devRV8803C7.c @@ -50,14 +50,14 @@ #include "devRV8803C7.h" extern volatile WarpI2CDeviceState deviceRV8803C7State; -extern volatile uint32_t gWarpI2cBaudRateKbps; -extern volatile uint32_t gWarpI2cTimeoutMilliseconds; +extern volatile uint32_t gWarpI2cBaudRateKbps; +extern volatile uint32_t gWarpI2cTimeoutMilliseconds; void initRV8803C7(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) { - deviceRV8803C7State.i2cAddress = i2cAddress; + deviceRV8803C7State.i2cAddress = i2cAddress; deviceRV8803C7State.operatingVoltageMillivolts = operatingVoltageMillivolts; return; @@ -76,7 +76,8 @@ readRTCRegisterRV8803C7(uint8_t deviceRegister, uint8_t *receiveData) return kWarpStatusBadDeviceCommand; } - i2c_device_t slave = { + i2c_device_t slave = + { .address = deviceRV8803C7State.i2cAddress, .baudRate_kbps = gWarpI2cBaudRateKbps }; @@ -117,7 +118,8 @@ readRTCRegistersRV8803C7(uint8_t deviceStartRegister, uint8_t nRegs, uint8_t * return kWarpStatusBadDeviceCommand; } - i2c_device_t slave = { + i2c_device_t slave = + { .address = deviceRV8803C7State.i2cAddress, .baudRate_kbps = gWarpI2cBaudRateKbps }; @@ -159,7 +161,8 @@ writeRTCRegisterRV8803C7(uint8_t deviceRegister, uint8_t payload) return kWarpStatusBadDeviceCommand; } - i2c_device_t slave = { + i2c_device_t slave = + { .address = deviceRV8803C7State.i2cAddress, .baudRate_kbps = gWarpI2cBaudRateKbps }; @@ -201,7 +204,8 @@ writeRTCRegistersRV8803C7(uint8_t deviceStartRegister, uint8_t nRegs, uint8_t pa return kWarpStatusBadDeviceCommand; } - i2c_device_t slave = { + i2c_device_t slave = + { .address = deviceRV8803C7State.i2cAddress, .baudRate_kbps = gWarpI2cBaudRateKbps }; diff --git a/src/boot/ksdk1.1.0/devRV8803C7.h b/src/boot/ksdk1.1.0/devRV8803C7.h index fb9df9cc4..4e5981a66 100644 --- a/src/boot/ksdk1.1.0/devRV8803C7.h +++ b/src/boot/ksdk1.1.0/devRV8803C7.h @@ -113,7 +113,6 @@ WarpStatus writeRTCRegisterRV8803C7(uint8_t deviceStartRegister, uint8_t payload WarpStatus writeRTCRegistersRV8803C7(uint8_t deviceStartRegister, uint8_t nRegs, uint8_t payload[]); WarpStatus setRTCTimeRV8803C7(rtc_datetime_t * tm); WarpStatus setRTCCountdownRV8803C7(uint16_t countdown, WarpRV8803ExtTD clk_freq, bool interupt_enable); - uint8_t appendSensorDataRV8803C7(uint8_t* buf); const uint8_t bytesPerMeasurementRV8803C7 = 3; diff --git a/src/boot/ksdk1.1.0/devSI4705.c b/src/boot/ksdk1.1.0/devSI4705.c index c845df8d0..434809016 100644 --- a/src/boot/ksdk1.1.0/devSI4705.c +++ b/src/boot/ksdk1.1.0/devSI4705.c @@ -57,16 +57,16 @@ extern volatile WarpI2CDeviceState deviceSI4705State; -extern volatile uint32_t gWarpI2cBaudRateKbps; -extern volatile uint32_t gWarpI2cTimeoutMilliseconds; -extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; +extern volatile uint32_t gWarpI2cBaudRateKbps; +extern volatile uint32_t gWarpI2cTimeoutMilliseconds; +extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; void initSI4705(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) { - deviceSI4705State.i2cAddress = i2cAddress; + deviceSI4705State.i2cAddress = i2cAddress; deviceSI4705State.operatingVoltageMillivolts = operatingVoltageMillivolts; return; @@ -81,7 +81,7 @@ readSensorRegisterSI4705(uint8_t deviceRegister, int numberOfBytes) USED(numberOfBytes); i2c_device_t slave = - { + { .address = deviceSI4705State.i2cAddress, .baudRate_kbps = gWarpI2cBaudRateKbps }; diff --git a/src/boot/ksdk1.1.0/devSI7021.c b/src/boot/ksdk1.1.0/devSI7021.c index d8bd2d364..9101f60a0 100644 --- a/src/boot/ksdk1.1.0/devSI7021.c +++ b/src/boot/ksdk1.1.0/devSI7021.c @@ -57,16 +57,16 @@ extern volatile WarpI2CDeviceState deviceSI7021State; -extern volatile uint32_t gWarpI2cBaudRateKbps; -extern volatile uint32_t gWarpI2cTimeoutMilliseconds; -extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; +extern volatile uint32_t gWarpI2cBaudRateKbps; +extern volatile uint32_t gWarpI2cTimeoutMilliseconds; +extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; void initSI7021(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) { - deviceSI7021State.i2cAddress = i2cAddress; + deviceSI7021State.i2cAddress = i2cAddress; deviceSI7021State.operatingVoltageMillivolts = operatingVoltageMillivolts; return; @@ -90,7 +90,7 @@ readSensorRegisterSI7021(uint8_t deviceRegister, int numberOfBytes) */ i2c_device_t slave = - { + { .address = deviceSI7021State.i2cAddress, .baudRate_kbps = gWarpI2cBaudRateKbps }; @@ -149,7 +149,7 @@ readSensorRegisterSI7021(uint8_t deviceRegister, int numberOfBytes) numberOfBytes, gWarpI2cTimeoutMilliseconds); - if ( (status1 != kStatus_I2C_Success) || + if ((status1 != kStatus_I2C_Success) || (status2 != kStatus_I2C_Success) || (status3 != kStatus_I2C_Success) || (status4 != kStatus_I2C_Success) diff --git a/src/boot/ksdk1.1.0/devTCS34725.c b/src/boot/ksdk1.1.0/devTCS34725.c index 0b3b44253..0a13e30ac 100644 --- a/src/boot/ksdk1.1.0/devTCS34725.c +++ b/src/boot/ksdk1.1.0/devTCS34725.c @@ -56,15 +56,15 @@ #include "warp.h" extern volatile WarpI2CDeviceState deviceTCS34725State; -extern volatile uint32_t gWarpI2cBaudRateKbps; -extern volatile uint32_t gWarpI2cTimeoutMilliseconds; -extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; +extern volatile uint32_t gWarpI2cBaudRateKbps; +extern volatile uint32_t gWarpI2cTimeoutMilliseconds; +extern volatile uint32_t gWarpSupplySettlingDelayMilliseconds; void initTCS34725(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts) { - deviceTCS34725State.i2cAddress = i2cAddress; + deviceTCS34725State.i2cAddress = i2cAddress; deviceTCS34725State.operatingVoltageMillivolts = operatingVoltageMillivolts; return; @@ -82,7 +82,7 @@ readSensorRegisterTCS34725(uint8_t deviceRegister) } i2c_device_t slave = - { + { .address = deviceTCS34725State.i2cAddress, .baudRate_kbps = gWarpI2cBaudRateKbps }; diff --git a/src/boot/ksdk1.1.0/devTCS34725.h b/src/boot/ksdk1.1.0/devTCS34725.h index ed4689689..362ce1ec3 100644 --- a/src/boot/ksdk1.1.0/devTCS34725.h +++ b/src/boot/ksdk1.1.0/devTCS34725.h @@ -37,5 +37,4 @@ // void initTCS34725(const uint8_t i2cAddress, WarpI2CDeviceState volatile * deviceStatePointer, uint16_t operatingVoltageMillivolts); void initTCS34725(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts); - WarpStatus readSensorRegisterTCS34725(uint8_t deviceRegister, int numberOfBytes); diff --git a/src/boot/ksdk1.1.0/glaux.h b/src/boot/ksdk1.1.0/glaux.h index 624fd1b78..aceed83e3 100644 --- a/src/boot/ksdk1.1.0/glaux.h +++ b/src/boot/ksdk1.1.0/glaux.h @@ -39,6 +39,6 @@ typedef enum { - kGlauxSleepSecondsBetweenSensorRepetitions = 3600, + kGlauxSleepSecondsBetweenSensorRepetitions = 10, kGlauxSensorRepetitionsPerSleepIteration = 1, } Glaux; diff --git a/src/boot/ksdk1.1.0/gpio_pins.c b/src/boot/ksdk1.1.0/gpio_pins.c index 0d4ad29fa..3e31bf337 100644 --- a/src/boot/ksdk1.1.0/gpio_pins.c +++ b/src/boot/ksdk1.1.0/gpio_pins.c @@ -27,7 +27,10 @@ * */ -gpio_output_pin_user_config_t outputPins[] = { + + +gpio_output_pin_user_config_t outputPins[] = +{ /* * Set unused pins as outputs */ @@ -165,6 +168,8 @@ gpio_output_pin_user_config_t outputPins[] = { .config.slewRate = kPortSlowSlewRate, .config.driveStrength = kPortLowDriveStrength, }, + + #elif (WARP_BUILD_ENABLE_FRDMKL03) #endif @@ -192,7 +197,8 @@ gpio_output_pin_user_config_t outputPins[] = { * * NOTE: The semantics is that pins that are excluded are disabled (TODO: double check). */ -gpio_input_pin_user_config_t inputPins[] = { +gpio_input_pin_user_config_t inputPins[] = +{ { .pinName = GPIO_PINS_OUT_OF_RANGE, } @@ -203,10 +209,11 @@ gpio_input_pin_user_config_t inputPins[] = { * * **NOTE**: The semantics is that pins that are excluded are disabled (TODO: double check). */ -gpio_input_pin_user_config_t wakeupPins[] = { +gpio_input_pin_user_config_t wakeupPins[] = +{ { .pinName = kWarpPinUnusedPTA0, - .config.isPullEnable = true, + .config.isPullEnable = false, .config.pullSelect = kPortPullUp, .config.isPassiveFilterEnabled = false, .config.interrupt = kPortIntDisabled, diff --git a/src/boot/ksdk1.1.0/gpio_pins.h b/src/boot/ksdk1.1.0/gpio_pins.h index 3c76bfd3b..c0fc99abb 100644 --- a/src/boot/ksdk1.1.0/gpio_pins.h +++ b/src/boot/ksdk1.1.0/gpio_pins.h @@ -106,7 +106,8 @@ enum _gpio_pins kWarpPinTPS62740_VSEL3 = GPIO_MAKE_PIN(HW_GPIOB, 7), kWarpPinTPS62740_VSEL2 = GPIO_MAKE_PIN(HW_GPIOB, 10), kWarpPinTPS62740_VSEL1 = GPIO_MAKE_PIN(HW_GPIOB, 11), - kWarpPinCLKOUT32K = GPIO_MAKE_PIN(HW_GPIOB, 13), + kWarpPinCLKOUT32K = GPIO_MAKE_PIN(HW_GPIOB, 13), + #endif }; diff --git a/src/boot/ksdk1.1.0/warp.h b/src/boot/ksdk1.1.0/warp.h index 6f566fc85..e90cff454 100644 --- a/src/boot/ksdk1.1.0/warp.h +++ b/src/boot/ksdk1.1.0/warp.h @@ -25,14 +25,13 @@ #define BOARD_SW_HAS_LLWU_PIN 1 #define BOARD_SW_LLWU_EXT_PIN 7 #define BOARD_SW_LLWU_PIN 0 -#define BOARD_SW_LLWU_BASE PORTA_BASE +#define BOARD_SW_LLWU_BASE PORTA_BASE #define BOARD_SW_LLWU_IRQ_HANDLER PORTA_IRQHandler #define BOARD_SW_LLWU_IRQ_NUM PORTA_IRQn typedef enum { kWarpStatusOK = 0, - kWarpStatusDeviceNotInitialized, kWarpStatusDeviceCommunicationFailed, kWarpStatusBadDeviceCommand, @@ -85,6 +84,7 @@ typedef enum kWarpSensorADXL362, kWarpSensorMMA8451Q, kWarpSensorBME680, + kWarpSensorBNO055, kWarpSensorBMX055accel, kWarpSensorBMX055gyro, kWarpSensorBMX055mag, @@ -102,6 +102,7 @@ typedef enum kWarpSensorAS7262, kWarpSensorAS7263, kWarpSensorSCD30, + kWarpSensorRF430CL331H, } WarpSensorDevice; typedef enum @@ -111,17 +112,41 @@ typedef enum typedef enum { - kWarpSensorConfigurationRegisterMMA8451QF_SETUP = 0x09, - kWarpSensorConfigurationRegisterMMA8451QCTRL_REG1 = 0x2A, - - kWarpSensorConfigurationRegisterMAG3110CTRL_REG1 = 0x10, - kWarpSensorConfigurationRegisterMAG3110CTRL_REG2 = 0x11, + kWarpSensorConfigurationRegisterMMA8451QF_SETUP = 0x09, + kWarpSensorConfigurationRegisterMMA8451QCTRL_REG1 = 0x2A, + + kWarpSensorConfigurationRegisterMAG3110CTRL_REG1 = 0x10, + kWarpSensorConfigurationRegisterMAG3110CTRL_REG2 = 0x11, + + kWarpSensorConfigurationRegisterBNO055_OPR_MODE = 0x3D, + kWarpSensorConfigurationRegisterBNO055_PWR_MODE = 0x3E, + kWarpSensorConfigurationRegisterBNO055accelConf = 0x08, + kWarpSensorConfigurationRegisterBNO055magConf = 0x09, + kWarpSensorConfigurationRegisterBNO055gyroConf_Power_Mode = 0x0A, + kWarpSensorConfigurationRegisterBNO055gyroConf_BW_Range = 0x0B, + kWarpSensorConfigurationRegisterBNO055Page_ID = 0x07, + + kWarpSensorConfigureationRegisterRF430CL331H_Genral = 0xFFFE, + kWarpSensorConfigureationRegisterRF430CL331H_INT = 0xFFFA, + kWarpSensorConfigureationRegisterRF430CL331H_INTFlag = 0xFFF8, + kWarpSensorConfigureationRegisterRF430CL331H_CRC = 0xFFF6, + kWarpSensorConfigureationRegisterRF430CL331H_CRC_LengthHigh = 0xFFF5, + kWarpSensorConfigureationRegisterRF430CL331HL_CRC_LengthLow = 0xFFF4, + kWarpSensorConfigureationRegisterRF430CL331H_CRC_StartAddressHigh = 0xFFF3, + kWarpSensorConfigureationRegisterRF430CL331H_CRC_StartAddressLow = 0xFFF2, + kWarpSensorConfigureationRegisterRF430CL331H_Watchdog = 0xFFF0, + kWarpSensorConfigureationRegisterRF430CL331H_NDEF_File_Identifier = 0xFFEC, + kWarpSensorConfigureationRegisterRF430CL331HL_HostResp = 0xFFEA, + kWarpSensorConfigureationRegisterRF430CL331H_Buffer_Start_MSB = 0xFFE5, + kWarpSensorConfigureationRegisterRF430CL331H_Buffer_Start_LSB = 0xFFE4, + kWarpSensorConfigureationRegisterRF430CL331H_SWTX = 0xFFDE, + kWarpSensorConfigurationRegisterHDC1000Configuration = 0x02, - kWarpSensorConfigurationRegisterAMG8834PCTL = 0x00, - kWarpSensorConfigurationRegisterAMG8834RST = 0x01, - kWarpSensorConfigurationRegisterAMG8834FPSC = 0x02, + kWarpSensorConfigurationRegisterAMG8834PCTL = 0x00, + kWarpSensorConfigurationRegisterAMG8834RST = 0x01, + kWarpSensorConfigurationRegisterAMG8834FPSC = 0x02, kWarpSensorConfigurationRegisterCCS811MEAS_MODE = 0x01, kWarpSensorConfigurationRegisterCCS811APP_START = 0xF4, @@ -130,24 +155,24 @@ typedef enum kWarpSensorConfigurationRegisterBMX055accelPMU_BW = 0x10, kWarpSensorConfigurationRegisterBMX055accelPMU_LPW = 0x11, kWarpSensorConfigurationRegisterBMX055accelPMU_LOW_POWER = 0x12, - kWarpSensorConfigurationRegisterBMX055accelACCD_HBW = 0x13, - kWarpSensorConfigurationRegisterBMX055magPowerCtrl = 0x4B, - kWarpSensorConfigurationRegisterBMX055magOpMode = 0x4C, - kWarpSensorConfigurationRegisterBMX055gyroRANGE = 0x0F, - kWarpSensorConfigurationRegisterBMX055gyroBW = 0x10, - kWarpSensorConfigurationRegisterBMX055gyroLPM1 = 0x11, - kWarpSensorConfigurationRegisterBMX055gyroRATE_HBW = 0x13, - - kWarpSensorConfigurationRegisterL3GD20HCTRL1 = 0x20, - kWarpSensorConfigurationRegisterL3GD20HCTRL2 = 0x21, - kWarpSensorConfigurationRegisterL3GD20HCTRL5 = 0x24, - - kWarpSensorConfigurationRegisterBME680Reset = 0xE0, - kWarpSensorConfigurationRegisterBME680Config = 0x75, - kWarpSensorConfigurationRegisterBME680Ctrl_Meas = 0x74, - kWarpSensorConfigurationRegisterBME680Ctrl_Hum = 0x72, - kWarpSensorConfigurationRegisterBME680Ctrl_Gas_1 = 0x71, - kWarpSensorConfigurationRegisterBME680Ctrl_Gas_0 = 0x70, + kWarpSensorConfigurationRegisterBMX055accelACCD_HBW = 0x13, + kWarpSensorConfigurationRegisterBMX055magPowerCtrl = 0x4B, + kWarpSensorConfigurationRegisterBMX055magOpMode = 0x4C, + kWarpSensorConfigurationRegisterBMX055gyroRANGE = 0x0F, + kWarpSensorConfigurationRegisterBMX055gyroBW = 0x10, + kWarpSensorConfigurationRegisterBMX055gyroLPM1 = 0x11, + kWarpSensorConfigurationRegisterBMX055gyroRATE_HBW = 0x13, + + kWarpSensorConfigurationRegisterL3GD20HCTRL1 = 0x20, + kWarpSensorConfigurationRegisterL3GD20HCTRL2 = 0x21, + kWarpSensorConfigurationRegisterL3GD20HCTRL5 = 0x24, + + kWarpSensorConfigurationRegisterBME680Reset = 0xE0, + kWarpSensorConfigurationRegisterBME680Config = 0x75, + kWarpSensorConfigurationRegisterBME680Ctrl_Meas = 0x74, + kWarpSensorConfigurationRegisterBME680Ctrl_Hum = 0x72, + kWarpSensorConfigurationRegisterBME680Ctrl_Gas_1 = 0x71, + kWarpSensorConfigurationRegisterBME680Ctrl_Gas_0 = 0x70, kWarpSensorConfigurationRegisterBME680CalibrationRegion1Start = 0x89, kWarpSensorConfigurationRegisterBME680CalibrationRegion1End = 0xA2, @@ -189,6 +214,31 @@ typedef enum kWarpSensorOutputRegisterHDC1000Temperature = 0x00, kWarpSensorOutputRegisterHDC1000Humidity = 0x01, + kWarpSensourOutputRegisterBNO055EUL_HEADING_LSB = 0x1A, + kWarpSensourOutputRegisterBNO055EUL_HEADING_MSB = 0x1B, + kWarpSensourOutputRegisterBNO055EUL_ROLL_LSB = 0x1C, + kWarpSensourOutputRegisterBNO055EUL_ROLL_MSB = 0x1D, + kWarpSensourOutputRegisterBNO055EUL_PITCH_LSB = 0x1E, + kWarpSensourOutputRegisterBNO055EUL_PITCH_MSB = 0x1F, + kWarpSensourOutputRegisterBNO055Accel_Data_X_LSB = 0x08, + kWarpSensourOutputRegisterBNO055Accel_Data_X_MSB = 0x09, + kWarpSensourOutputRegisterBNO055Accel_Data_Y_LSB = 0x0A, + kWarpSensourOutputRegisterBNO055Accel_Data_Y_MSB = 0x0B, + kWarpSensourOutputRegisterBNO055Accel_Data_Z_LSB = 0x0C, + kWarpSensourOutputRegisterBNO055Accel_Data_Z_MSB = 0x0D, + kWarpSensourOutputRegisterBNO055Mag_Data_X_LSB = 0x0E, + kWarpSensourOutputRegisterBNO055Mag_Data_X_MSB = 0x0F, + kWarpSensourOutputRegisterBNO055Mag_Data_Y_LSB = 0x10, + kWarpSensourOutputRegisterBNO055Mag_Data_Y_MSB = 0x11, + kWarpSensourOutputRegisterBNO055Mag_Data_Z_LSB = 0x12, + kWarpSensourOutputRegisterBNO055Mag_Data_Z_MSB = 0x13, + kWarpSensourOutputRegisterBNO055Gyro_Data_X_LSB = 0x14, + kWarpSensourOutputRegisterBNO055Gyro_Data_X_MSB = 0x15, + kWarpSensourOutputRegisterBNO055Gyro_Data_Y_LSB = 0x16, + kWarpSensourOutputRegisterBNO055Gyro_Data_Y_MSB = 0x17, + kWarpSensourOutputRegisterBNO055Gyro_Data_Z_LSB = 0x18, + kWarpSensourOutputRegisterBNO055Gyro_Data_Z_MSB = 0x19, + kWarpSensorOutputRegisterAMG8834TTHL = 0x0E, kWarpSensorOutputRegisterAMG8834TTHH = 0x0F, kWarpSensorOutputRegisterAMG8834T01L = 0x80, @@ -198,19 +248,19 @@ typedef enum kWarpSensorOutputRegisterCCS811RAW_DATA = 0x03, kWarpSensorOutputRegisterCCS811RAW_REF_NTC = 0x06, - kWarpSensorOutputRegisterBMX055accelACCD_X_LSB = 0x02, - kWarpSensorOutputRegisterBMX055accelACCD_X_MSB = 0x03, - kWarpSensorOutputRegisterBMX055accelACCD_Y_LSB = 0x04, - kWarpSensorOutputRegisterBMX055accelACCD_Y_MSB = 0x05, - kWarpSensorOutputRegisterBMX055accelACCD_Z_LSB = 0x06, - kWarpSensorOutputRegisterBMX055accelACCD_Z_MSB = 0x07, - kWarpSensorOutputRegisterBMX055accelACCD_TEMP = 0x08, - kWarpSensorOutputRegisterBMX055gyroRATE_X_LSB = 0x02, - kWarpSensorOutputRegisterBMX055gyroRATE_X_MSB = 0x03, - kWarpSensorOutputRegisterBMX055gyroRATE_Y_LSB = 0x04, - kWarpSensorOutputRegisterBMX055gyroRATE_Y_MSB = 0x05, - kWarpSensorOutputRegisterBMX055gyroRATE_Z_LSB = 0x06, - kWarpSensorOutputRegisterBMX055gyroRATE_Z_MSB = 0x07, + kWarpSensorOutputRegisterBMX055accelACCD_X_LSB = 0x02, + kWarpSensorOutputRegisterBMX055accelACCD_X_MSB = 0x03, + kWarpSensorOutputRegisterBMX055accelACCD_Y_LSB = 0x04, + kWarpSensorOutputRegisterBMX055accelACCD_Y_MSB = 0x05, + kWarpSensorOutputRegisterBMX055accelACCD_Z_LSB = 0x06, + kWarpSensorOutputRegisterBMX055accelACCD_Z_MSB = 0x07, + kWarpSensorOutputRegisterBMX055accelACCD_TEMP = 0x08, + kWarpSensorOutputRegisterBMX055gyroRATE_X_LSB = 0x02, + kWarpSensorOutputRegisterBMX055gyroRATE_X_MSB = 0x03, + kWarpSensorOutputRegisterBMX055gyroRATE_Y_LSB = 0x04, + kWarpSensorOutputRegisterBMX055gyroRATE_Y_MSB = 0x05, + kWarpSensorOutputRegisterBMX055gyroRATE_Z_LSB = 0x06, + kWarpSensorOutputRegisterBMX055gyroRATE_Z_MSB = 0x07, kWarpSensorOutputRegisterBMX055magX_LSB = 0x42, kWarpSensorOutputRegisterBMX055magX_MSB = 0x43, kWarpSensorOutputRegisterBMX055magY_LSB = 0x44, @@ -246,14 +296,22 @@ typedef enum kWarpSensorOutputRegisterADXL362TEMP_L = 0x14, kWarpSensorOutputRegisterADXL362TEMP_H = 0x15, kWarpSensorOutputRegisterADXL362STATUS = 0x0B, - kWarpSensorOutputRegisterADXL362FIFO_ENTRIES_L = 0x0C, - kWarpSensorOutputRegisterADXL362FIFO_ENTRIES_H = 0x0D, - kWarpSensorOutputRegisterADXL362ACT_INACT_CTL = 0x27, - kWarpSensorOutputRegisterADXL362FIFO_CONTROL = 0x28, - kWarpSensorOutputRegisterADXL362FIFO_SAMPLES = 0x29, + kWarpSensorOutputRegisterADXL362FIFO_ENTRIES_L = 0x0C, + kWarpSensorOutputRegisterADXL362FIFO_ENTRIES_H = 0x0D, + kWarpSensorOutputRegisterADXL362ACT_INACT_CTL = 0x27, + kWarpSensorOutputRegisterADXL362FIFO_CONTROL = 0x28, + kWarpSensorOutputRegisterADXL362FIFO_SAMPLES = 0x29, kWarpSensorOutputRegisterADXL362FILTER_CTL = 0x2C, kWarpSensorOutputRegisterADXL362POWER_CTL = 0x2D, + kWarpSensorOutputRegisterRF430CL331H_Status = 0xFFFC, + kWarpSensorOutputRegisterRF430CL331H_version = 0xFFEE, + kWarpSensorOutputRegisterRF430CL331H_NDEF_Block_Length_MSB = 0xFFE9, + kWarpSensorOutputRegisterRF430CL331H_NDEF_Block_Length_LSB = 0xFFE8, + kWarpSensorOutputRegisterRF430CL331H_NDEF_File_Offset = 0xFFE6, + kWarpSensorOutputRegisterRF430CL331H_Custom_Status_Word = 0xFFDA, + + } WarpSensorOutputRegister; @@ -263,6 +321,8 @@ typedef enum kWarpSensorConfigConstADXL362registerReadRegister = 0x0B, kWarpSensorConfigConstADXL362registerFIFORead = 0x0D, kWarpSensorConfigConstADXL362resetCode = 0x52, + kWarpSensorConfigConstBNO055registerAMGMode = 0x01, + kWarpSensorConfigConstBNO055registerNDOFMode = 0x0C, } WarpSensorConfigConst; typedef enum @@ -317,5 +377,5 @@ void warpEnableSPIpins(void); void warpDisableSPIpins(void); void warpDeasserAllSPIchipSelects(void); void warpPrint(const char *fmt, ...); -int warpWaitKey(void); +int warpWaitKey(void);