From 607ccb6e274d3738ee7e024d74c6b1f0ea2dfdf8 Mon Sep 17 00:00:00 2001 From: Roy Date: Wed, 12 Jul 2023 14:26:36 +0800 Subject: [PATCH] [update] clear code --- .../cc26xx/app/HAL/cc2650_driver/spi_ctrl_c.h | 32 +++++++------ .../cc26xx/app/simple_peripheral.c | 45 ++++++++++--------- 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/HAL/cc2650_driver/spi_ctrl_c.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/HAL/cc2650_driver/spi_ctrl_c.h index dd5a2e3..ebc06a3 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/HAL/cc2650_driver/spi_ctrl_c.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/HAL/cc2650_driver/spi_ctrl_c.h @@ -2,20 +2,24 @@ #include #include "HAL/cc2650_driver/spi_ctrl.h" /* -SPI bit rate in Hz. - -Maximum bit rates supported by hardware: - -+---------------+-----------------+------------------+ -| Device Family | Slave Max (MHz) | Master Max (MHz) | -+---------------+-----------------+------------------+ -| MSP432P4 | 16 MHz | 24 MHz | -| MSP432E4 | 10 MHz | 60 MHz | -| CC13XX/CC26XX | 4 MHz | 12 MHz | -| CC32XX | 20 MHz | 20 MHz | -+---------------+-----------------+------------------+ -Please note that depending on the specific use case, the driver may not support the hardware's maximum bit rate. -*/ + * Read SPI example in + * http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/tirtos/2_14_02_22/ + * exports/tirtos_full_2_14_02_22/docs/doxygen/html/_s_p_i_c_c26_x_x_d_m_a_8h.html + * + * SPI bit rate in Hz. + * + * Maximum bit rates supported by hardware: + * + * +---------------+-----------------+------------------+ + * | Device Family | Slave Max (MHz) | Master Max (MHz) | + * +---------------+-----------------+------------------+ + * | MSP432P4 | 16 MHz | 24 MHz | + * | MSP432E4 | 10 MHz | 60 MHz | + * | CC13XX/CC26XX | 4 MHz | 12 MHz | + * | CC32XX | 20 MHz | 20 MHz | + * +---------------+-----------------+------------------+ + * Please note that depending on the specific use case, the driver may not support the hardware's maximum bit rate. + */ /* system use SPI parameters */ static SPI_Handle spiHandle0 = NULL; diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/simple_peripheral.c b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/simple_peripheral.c index 9eeefd4..4bb2f6a 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/simple_peripheral.c +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/simple_peripheral.c @@ -92,9 +92,6 @@ #include "simple_peripheral.h" -// #include "EliteGPTimer.h" - - #include #include #include @@ -110,26 +107,31 @@ static GPTimerCC26XX_Handle gptimer_handle; static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask); -#define elite_gptimer_start() GPTimerCC26XX_start(gptimer_handle) -#define elite_gptimer_stop() GPTimerCC26XX_stop(gptimer_handle) -#define elite_gptimer_close() GPTimerCC26XX_close(gptimer_handle) #define CLOCK_FREQ 4769 // clock freq = 0.1 ms(4800), Measured(4769) -#define elite_gptimer_open() \ - do { \ - GPTimerCC26XX_Params params; \ - GPTimerCC26XX_Params_init(¶ms); \ - params.width = GPT_CONFIG_16BIT; \ - params.mode = GPT_MODE_PERIODIC_UP; \ - params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF; \ - gptimer_handle = GPTimerCC26XX_open(Board_GPTIMER0A, ¶ms); \ - Types_FreqHz freq; \ - BIOS_getCpuFreq(&freq); \ - GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; /*47999*/ \ - GPTimerCC26XX_setLoadValue(gptimer_handle, loadVal); \ - GPTimerCC26XX_setLoadValue(gptimer_handle, CLOCK_FREQ); /* 0.1 ms*/ \ - GPTimerCC26XX_registerInterrupt(gptimer_handle, elite_gptimer_callback, GPT_INT_TIMEOUT); \ - } while (0) +void elite_gptimer_open() +{ + GPTimerCC26XX_Params params; + GPTimerCC26XX_Params_init(¶ms); + params.width = GPT_CONFIG_16BIT; + params.mode = GPT_MODE_PERIODIC_UP; + params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF; + gptimer_handle = GPTimerCC26XX_open(Board_GPTIMER0A, ¶ms); + if (gptimer_handle == NULL) { + Task_exit(); + } + + Types_FreqHz freq; + BIOS_getCpuFreq(&freq); + GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; //47999 = 1ms + loadVal = CLOCK_FREQ; //0.1ms + GPTimerCC26XX_setLoadValue(gptimer_handle, loadVal); + GPTimerCC26XX_registerInterrupt(gptimer_handle, elite_gptimer_callback, GPT_INT_TIMEOUT); + + GPTimerCC26XX_start(gptimer_handle); + + return; +} #include #include @@ -1157,7 +1159,6 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) i2c0_open(I2C_400K); elite_gptimer_open(); - elite_gptimer_start(); InitEliteInstruction();