From 1e9674d9b40129b9336a5360b020de91da088aa7 Mon Sep 17 00:00:00 2001 From: Nguyen Hoan Hoang Date: Sun, 12 Feb 2017 22:40:03 -0500 Subject: [PATCH 1/9] CMSIS 5 --- include/atomic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/atomic.h b/include/atomic.h index 222aa70f..fdbeaacf 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -76,7 +76,7 @@ Hoan 17 nov. 2014 Adapt to GNU GCC #endif #endif -#include "core_cmFunc.h" +#include "cmsis_gcc.h" #endif #else From a44e38db77cd4eed6961dd3159129f4ba7cb0a19 Mon Sep 17 00:00:00 2001 From: Nguyen Hoan Hoang Date: Thu, 16 Feb 2017 09:02:26 -0500 Subject: [PATCH 2/9] Remove unsued code --- src/isha256.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/isha256.c b/src/isha256.c index 81870e43..3534683f 100755 --- a/src/isha256.c +++ b/src/isha256.c @@ -286,7 +286,7 @@ char *Sha256(uint8_t *pData, int DataLen, bool bLast, char *pRes) if (pRes) digest = pRes; - sprintf(digest, "%08lX%08lX%08lX%08lX%08lX%08lX%08lX%08lX", H[0], H[1], H[2], H[3], H[4], H[5], H[6], H[7]); + //sprintf(digest, "%08lX%08lX%08lX%08lX%08lX%08lX%08lX%08lX", H[0], H[1], H[2], H[3], H[4], H[5], H[6], H[7]); // Reset memory, ready for new processing From d37937bff285b119d29365cc0706084743d15c3d Mon Sep 17 00:00:00 2001 From: Nguyen Hoan Hoang Date: Thu, 16 Feb 2017 09:03:56 -0500 Subject: [PATCH 3/9] Add gpio event sensing (interrupt) --- include/iopincfg.h | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/include/iopincfg.h b/include/iopincfg.h index e8bcd349..7d262e58 100755 --- a/include/iopincfg.h +++ b/include/iopincfg.h @@ -53,11 +53,18 @@ typedef enum _iopin_dir { } IOPINDIR; // I/O pin type -typedef enum { +typedef enum _iopin_type { IOPINTYPE_NORMAL = 0, IOPINTYPE_OPENDRAIN = 1 } IOPINTYPE; +typedef enum _iopin_sense { + IOPINSENSE_LOW_TRANSISTION, // Event on falling edge + IOPINSENSE_HIGH_TRANSITION, // Event on raising edge + IOPINSENSE_TOGGLE, // Event on state change + IOPINSENSE_COUNT // Count max number of enum +} IOPINSENSE; + #pragma pack(push,4) typedef struct _iopin_cfg { @@ -71,12 +78,14 @@ typedef struct _iopin_cfg { #pragma pack(pop) +typedef void (*IOPINEVT_CB)(int PortMask, int PinMask, IOPINSENSE Sense); + #ifdef __cplusplus extern "C" { #endif -/* - * Configure individual I/O pin. +/** + * @brief Configure individual I/O pin. * * Note : This function is MCU dependent. Needs to be implemented per MCU * @@ -90,16 +99,12 @@ extern "C" { */ void IOPinConfig(int PortNo, int PinNo, int PinOp, IOPINDIR Dir, IOPINRES Resistor, IOPINTYPE Type); -#ifdef __cplusplus -} -#endif - -/* - * Configure I/O pin with IOPIN_CFG data structure. Can be used for batch config +/** + * @brief Configure I/O pin with IOPIN_CFG data structure. Can be used for batch configuration * * @param pCfg : Pointer to an array gpio pin configuration * NbPins : Number of gpio pins to configure -*/ + */ static inline void IOPinCfg(const IOPINCFG *pCfg, int NbPins) { if (pCfg == NULL || NbPins <= 0) return; @@ -111,6 +116,21 @@ static inline void IOPinCfg(const IOPINCFG *pCfg, int NbPins) { } } +/** + * @brief Register for I/O pin sensing interrupt event + * + * Note : Only one callback per event. Setting the same event will overwrite the previous + * setting. + * + * @param PortMask : Bit position represent port number (up to 32 ports) + * PinMask : Bit position represent pin number (up to 32 pins) + * Sense : Sense type of event on the I/O pin + * pEvtCB : Pointer to callback funtion when event occurs + */ +void IOPinSenseEvent(int PortMask, int PinMask, IOPINSENSE Sense, IOPINEVT_CB pEvtCB); +#ifdef __cplusplus +} +#endif #endif // __IOPINCFG_H__ From 5abee738e8e7286b0635b34d6208f163f00abceb Mon Sep 17 00:00:00 2001 From: Nguyen Hoan Hoang Date: Fri, 17 Feb 2017 07:38:37 -0500 Subject: [PATCH 4/9] I/O pin sense interrupt Implementation on nRF5x --- ARM/Nordic/src/iopincfg_nrf5x.c | 81 +++++++++++++++++++++++++++++++++ include/iopincfg.h | 39 +++++++++------- 2 files changed, 104 insertions(+), 16 deletions(-) diff --git a/ARM/Nordic/src/iopincfg_nrf5x.c b/ARM/Nordic/src/iopincfg_nrf5x.c index 5aed0fd0..0ac7f1d9 100755 --- a/ARM/Nordic/src/iopincfg_nrf5x.c +++ b/ARM/Nordic/src/iopincfg_nrf5x.c @@ -33,6 +33,8 @@ Modified by Date Description ----------------------------------------------------------------------------*/ #include +#include + #ifdef NRF51 #include "nrf51.h" #include "nrf51_bitfields.h" @@ -41,8 +43,19 @@ Modified by Date Description #include "nrf52_bitfields.h" #define NRF_GPIO NRF_P0 #endif +#include "nrf_gpiote.h" + #include "iopincfg.h" +#define IOPIN_MAX_INT (GPIOTE_CH_NUM) + +typedef struct { + IOPINSENSE Sense; + IOPINEVT_CB SensEvtCB; +} IOPINSENS_EVTHOOK; + +IOPINSENS_EVTHOOK s_GpIOSenseEvt[IOPIN_MAX_INT] = { {0, NULL}, }; + /* * Configure individual I/O pin. nRF51 only have 1 port so PortNo is not used * @@ -87,3 +100,71 @@ void IOPinConfig(int PortNo, int PinNo, int PinOp, IOPINDIR Dir, IOPINRES Resist NRF_GPIO->PIN_CNF[PinNo] = cnf; } + +void IOPinDisbleInterrupt(int IntNo) +{ + if (IntNo >= 0 && IntNo < 8) + { + NRF_GPIOTE->CONFIG[IntNo] = 0; + s_GpIOSenseEvt[IntNo].SensEvtCB = NULL; + } +} + +bool IOPinEnableInterrupt(int IntNo, int IntPrio, int PortNo, int PinNo, IOPINSENSE Sense, IOPINEVT_CB pEvtCB) +{ + if (IntNo < 0 || IntNo >= IOPIN_MAX_INT) + return false; + + //NRF_GPIOTE->CONFIG[IntNo] &= ~(GPIOTE_CONFIG_PORT_PIN_Msk | GPIOTE_CONFIG_POLARITY_Msk); + switch (Sense) + { + case IOPINSENSE_LOW_TRANSITION: + NRF_GPIOTE->CONFIG[IntNo] = ((GPIOTE_CONFIG_POLARITY_HiToLo << GPIOTE_CONFIG_POLARITY_Pos) & GPIOTE_CONFIG_POLARITY_Msk) + | ((PinNo << GPIOTE_CONFIG_PSEL_Pos) & GPIOTE_CONFIG_PORT_PIN_Msk) + | (GPIOTE_CONFIG_MODE_Event << GPIOTE_CONFIG_MODE_Pos); + NRF_GPIO->PIN_CNF[PinNo] |= (GPIO_PIN_CNF_SENSE_Low << GPIO_PIN_CNF_SENSE_Pos); + break; + case IOPINSENSE_HIGH_TRANSITION: + NRF_GPIOTE->CONFIG[IntNo] = ((GPIOTE_CONFIG_POLARITY_LoToHi << GPIOTE_CONFIG_POLARITY_Pos) & GPIOTE_CONFIG_POLARITY_Msk) + | ((PinNo << GPIOTE_CONFIG_PSEL_Pos) & GPIOTE_CONFIG_PORT_PIN_Msk) + | (GPIOTE_CONFIG_MODE_Event << GPIOTE_CONFIG_MODE_Pos); + NRF_GPIO->PIN_CNF[PinNo] |= (GPIO_PIN_CNF_SENSE_High << GPIO_PIN_CNF_SENSE_Pos); + break; + case IOPINSENSE_TOGGLE: + NRF_GPIOTE->CONFIG[IntNo] = ((GPIOTE_CONFIG_POLARITY_Toggle << GPIOTE_CONFIG_POLARITY_Pos) & GPIOTE_CONFIG_POLARITY_Msk) + | ((PinNo << GPIOTE_CONFIG_PSEL_Pos) & GPIOTE_CONFIG_PORT_PIN_Msk) + | (GPIOTE_CONFIG_MODE_Event << GPIOTE_CONFIG_MODE_Pos); + NRF_GPIO->PIN_CNF[PinNo] |= (3 << GPIO_PIN_CNF_SENSE_Pos); + break; + } + + s_GpIOSenseEvt[IntNo].SensEvtCB = pEvtCB; + + NRF_GPIOTE->INTENCLR = 0xFFFFFFFF; + + NVIC_ClearPendingIRQ(GPIOTE_IRQn); + NVIC_SetPriority(GPIOTE_IRQn, IntPrio); + NVIC_EnableIRQ(GPIOTE_IRQn); + + NRF_GPIOTE->EVENTS_PORT = 0; + + NRF_GPIOTE->INTENSET |= (1 << IntNo); + NRF_GPIOTE->INTENSET |= GPIOTE_INTENSET_PORT_Msk; + + return true; +} + +void GPIOTE_IRQHandler(void) +{ + for (int i = 0; i < IOPIN_MAX_INT; i++) + { + if (NRF_GPIOTE->EVENTS_IN[i] || NRF_GPIOTE->EVENTS_PORT) + { + if (s_GpIOSenseEvt[i].SensEvtCB) + s_GpIOSenseEvt[i].SensEvtCB(i); + NRF_GPIOTE->EVENTS_IN[i] = 0; + } + } + NRF_GPIOTE->EVENTS_PORT = 0; +} + diff --git a/include/iopincfg.h b/include/iopincfg.h index 7d262e58..cb9b1fa9 100755 --- a/include/iopincfg.h +++ b/include/iopincfg.h @@ -36,9 +36,10 @@ Modified by Date Description #include #include +#include // I/O pin resistor config -typedef enum _iopin_resistor { +typedef enum __iopin_resistor { IOPINRES_NONE, IOPINRES_PULLUP, IOPINRES_PULLDOWN, @@ -46,28 +47,27 @@ typedef enum _iopin_resistor { } IOPINRES; // I/O pin direction config -typedef enum _iopin_dir { +typedef enum __iopin_dir { IOPINDIR_INPUT = 0, IOPINDIR_OUTPUT = 1, IOPINDIR_BI = 2, // Bidirectional } IOPINDIR; // I/O pin type -typedef enum _iopin_type { +typedef enum __iopin_type { IOPINTYPE_NORMAL = 0, IOPINTYPE_OPENDRAIN = 1 } IOPINTYPE; -typedef enum _iopin_sense { - IOPINSENSE_LOW_TRANSISTION, // Event on falling edge +typedef enum __iopin_sense { + IOPINSENSE_LOW_TRANSITION, // Event on falling edge IOPINSENSE_HIGH_TRANSITION, // Event on raising edge IOPINSENSE_TOGGLE, // Event on state change - IOPINSENSE_COUNT // Count max number of enum } IOPINSENSE; #pragma pack(push,4) -typedef struct _iopin_cfg { +typedef struct __iopin_cfg { int PortNo; // Port number int PinNo; // Pin number int PinOp; // Pin function select index from 0, MCU dependent @@ -78,7 +78,7 @@ typedef struct _iopin_cfg { #pragma pack(pop) -typedef void (*IOPINEVT_CB)(int PortMask, int PinMask, IOPINSENSE Sense); +typedef void (*IOPINEVT_CB)(int IntNo); #ifdef __cplusplus extern "C" { @@ -117,17 +117,24 @@ static inline void IOPinCfg(const IOPINCFG *pCfg, int NbPins) { } /** - * @brief Register for I/O pin sensing interrupt event + * @brief Diable I/O pin sense interrupt + * + * @param IntNo : Interrupt number to disable + */ +void IOPinDisbleInterrupt(int IntNo); + +/** + * @brief Enable I/O pin sensing interrupt event * - * Note : Only one callback per event. Setting the same event will overwrite the previous - * setting. * - * @param PortMask : Bit position represent port number (up to 32 ports) - * PinMask : Bit position represent pin number (up to 32 pins) - * Sense : Sense type of event on the I/O pin - * pEvtCB : Pointer to callback funtion when event occurs + * @param IntNo : Interrupt number + * IntPrio : Interrupt priority + * PortNo : Port number (up to 32 ports) + * PinNo : Pin number (up to 32 pins) + * Sense : Sense type of event on the I/O pin + * pEvtCB : Pointer to callback function when event occurs */ -void IOPinSenseEvent(int PortMask, int PinMask, IOPINSENSE Sense, IOPINEVT_CB pEvtCB); +bool IOPinEnableInterrupt(int IntNo, int IntPrio, int PortNo, int PinNo, IOPINSENSE Sense, IOPINEVT_CB pEvtCB); #ifdef __cplusplus } From d03ecb6621525457fc06dba6f31a10de5e3f4202 Mon Sep 17 00:00:00 2001 From: Nguyen Hoan Hoang Date: Sun, 19 Feb 2017 09:51:04 -0500 Subject: [PATCH 5/9] Allows overwrite --- ARM/Nordic/src/iopincfg_nrf5x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ARM/Nordic/src/iopincfg_nrf5x.c b/ARM/Nordic/src/iopincfg_nrf5x.c index 0ac7f1d9..05467d38 100755 --- a/ARM/Nordic/src/iopincfg_nrf5x.c +++ b/ARM/Nordic/src/iopincfg_nrf5x.c @@ -154,7 +154,7 @@ bool IOPinEnableInterrupt(int IntNo, int IntPrio, int PortNo, int PinNo, IOPINSE return true; } -void GPIOTE_IRQHandler(void) +void __WEAK GPIOTE_IRQHandler(void) { for (int i = 0; i < IOPIN_MAX_INT; i++) { From ed8e2dd38ef76afab1777d069435f495fc8861ff Mon Sep 17 00:00:00 2001 From: Nguyen Hoan Hoang Date: Sun, 19 Feb 2017 09:52:06 -0500 Subject: [PATCH 6/9] Notfity callback & more flexible config --- ARM/Nordic/include/blueio_blesrvc.h | 13 ++++++ ARM/Nordic/src/blueio_blesrvc.c | 64 +++++++++++++++++------------ 2 files changed, 50 insertions(+), 27 deletions(-) diff --git a/ARM/Nordic/include/blueio_blesrvc.h b/ARM/Nordic/include/blueio_blesrvc.h index 61e87c95..4d891331 100755 --- a/ARM/Nordic/include/blueio_blesrvc.h +++ b/ARM/Nordic/include/blueio_blesrvc.h @@ -37,6 +37,7 @@ Modified by Date Description #define __BLUEIO_BLESRVC_H__ #include "ble_srv_common.h" +#include "serialintrf.h" // Default BlueIO UUID. User should use privately generated UUID // UUID : 00000000-287c-11e4-ab74-0002a5d5c51b @@ -54,11 +55,20 @@ Modified by Date Description #define BLUEIOSVC_CHAR_PROP_NOTIFY (1<<1) #define BLUEIOSVC_CHAR_PROP_WRITEWORESP (1<<2) #define BLUEIOSVC_CHAR_PROP_WRITE (1<<3) +#define BLUEIOSVC_CHAR_PROP_VARLEN (1<<4) typedef struct __BlueIOBLEService BLUEIOSRVC; +/** + * Callback on write + */ typedef void (*BLUEIOSRVC_WRCB) (BLUEIOSRVC *pBlueIOSvc, uint8_t *pData, int Offset, int Len); +/** + * Callback on set notification + */ +typedef void (*BLUEIOSRVC_SETNOTCB)(BLUEIOSRVC *pBlueIOSvc, bool bEnable); + // Service connection security types typedef enum { BLUEIOSRVC_SECTYPE_NONE, // open, no security @@ -78,6 +88,9 @@ typedef struct { const char *pDesc; // char UTF-8 description string BLUEIOSRVC_WRCB WrCB; // Callback for write char, set to NULL for read char bool bNotify; // Notify flag for read characteristic + BLUEIOSRVC_SETNOTCB SetNotifCB; // Callback on set notification + uint8_t *pDefValue; // pointer to char default values + uint16_t ValueLen; // Default value length in bytes ble_gatts_char_handles_t Hdl; // char handle } BLUEIOSRVC_CHAR; diff --git a/ARM/Nordic/src/blueio_blesrvc.c b/ARM/Nordic/src/blueio_blesrvc.c index 797a6a2b..fe5c094c 100755 --- a/ARM/Nordic/src/blueio_blesrvc.c +++ b/ARM/Nordic/src/blueio_blesrvc.c @@ -113,6 +113,9 @@ void BlueIOBleSvcEvtHandler(BLUEIOSRVC *pSrvc, ble_evt_t *pBleEvt) { pSrvc->pCharArray[i].bNotify = false; } + // Set notify callback + if (pSrvc->pCharArray[i].SetNotifCB) + pSrvc->pCharArray[i].SetNotifCB(pSrvc, pSrvc->pCharArray[i].bNotify); } else if ((p_evt_write->handle == pSrvc->pCharArray[i].Hdl.value_handle) && (pSrvc->pCharArray[i].WrCB != NULL)) @@ -176,14 +179,14 @@ static void BlueIOBleSrvcEncSec(ble_gap_conn_sec_mode_t *pSecMode, BLUEIOSRVC_SE /**@brief Add control characteristic. * - * @param[in] p_blueios LEDButton Service structure. - * @param[in] p_iodata_init Information needed to initialize the service. + * @param[in] pSrvc : Service data. + * @param[in/out] pChar : characteristic to initialize. + * @param[in] SecType : Security type * * @return NRF_SUCCESS on success, otherwise an error code. */ -static uint32_t BlueIOBleSrvcCharAdd(BLUEIOSRVC *pSrvc, uint16_t CharUuid, - int MaxDataLen, uint32_t CharProp, const char *pDesc, - ble_gatts_char_handles_t *pCharHdl, BLUEIOSRVC_SECTYPE SecType) +static uint32_t BlueIOBleSrvcCharAdd(BLUEIOSRVC *pSrvc, BLUEIOSRVC_CHAR *pChar, + BLUEIOSRVC_SECTYPE SecType) { ble_gatts_char_md_t char_md; ble_gatts_attr_md_t cccd_md; @@ -197,18 +200,18 @@ static uint32_t BlueIOBleSrvcCharAdd(BLUEIOSRVC *pSrvc, uint16_t CharUuid, cccd_md.vloc = BLE_GATTS_VLOC_STACK; - char_md.p_char_user_desc = (uint8_t*)pDesc; - if (pDesc != NULL) + char_md.p_char_user_desc = (uint8_t*)pChar->pDesc; + if (pChar->pDesc != NULL) { - char_md.char_user_desc_max_size = strlen(pDesc) + 1; - char_md.char_user_desc_size = strlen(pDesc) + 1; + char_md.char_user_desc_max_size = strlen(pChar->pDesc) + 1; + char_md.char_user_desc_size = strlen(pChar->pDesc) + 1; } char_md.p_char_pf = NULL; char_md.p_user_desc_md = NULL; char_md.p_cccd_md = NULL; char_md.p_sccd_md = NULL; - if (CharProp & BLUEIOSVC_CHAR_PROP_NOTIFY) + if (pChar->Property & BLUEIOSVC_CHAR_PROP_NOTIFY) { char_md.char_props.notify = 1; BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); @@ -217,21 +220,21 @@ static uint32_t BlueIOBleSrvcCharAdd(BLUEIOSRVC *pSrvc, uint16_t CharUuid, char_md.p_cccd_md = &cccd_md; } - if (CharProp & BLUEIOSVC_CHAR_PROP_READ) + if (pChar->Property & BLUEIOSVC_CHAR_PROP_READ) { char_md.char_props.read = 1; BlueIOBleSrvcEncSec(&attr_md.read_perm, SecType); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.write_perm); } - if (CharProp & BLUEIOSVC_CHAR_PROP_WRITE) + if (pChar->Property & BLUEIOSVC_CHAR_PROP_WRITE) { char_md.char_props.write = 1; BlueIOBleSrvcEncSec(&attr_md.write_perm, SecType); BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.read_perm); } - if (CharProp & BLUEIOSVC_CHAR_PROP_WRITEWORESP) + if (pChar->Property & BLUEIOSVC_CHAR_PROP_WRITEWORESP) { char_md.char_props.write_wo_resp = 1; BlueIOBleSrvcEncSec(&attr_md.write_perm, SecType); @@ -239,27 +242,40 @@ static uint32_t BlueIOBleSrvcCharAdd(BLUEIOSRVC *pSrvc, uint16_t CharUuid, } ble_uuid.type = pSrvc->UuidType; - ble_uuid.uuid = CharUuid; + ble_uuid.uuid = pChar->Uuid; attr_md.vloc = BLE_GATTS_VLOC_STACK; attr_md.rd_auth = 0; attr_md.wr_auth = 0; - attr_md.vlen = 1; // Variable length + if (pChar->Property & BLUEIOSVC_CHAR_PROP_VARLEN) + { + attr_md.vlen = 1; // Variable length + } + else + { + attr_md.vlen = 0; // Fixed length + } memset(&attr_char_value, 0, sizeof(attr_char_value)); attr_char_value.p_uuid = &ble_uuid; attr_char_value.p_attr_md = &attr_md; - attr_char_value.init_len = 0; attr_char_value.init_offs = 0; - attr_char_value.max_len = MaxDataLen; - attr_char_value.p_value = NULL; + attr_char_value.max_len = pChar->MaxDataLen; + attr_char_value.init_len = pChar->ValueLen; + attr_char_value.p_value = pChar->pDefValue; - return sd_ble_gatts_characteristic_add(pSrvc->SrvcHdl, &char_md, &attr_char_value, pCharHdl); + return sd_ble_gatts_characteristic_add(pSrvc->SrvcHdl, &char_md, &attr_char_value, &pChar->Hdl); } +/** + * @brief Create BLE service + * + * @param [in/out] pSrvc : Service handle + * @param [in] pCfg : Service configuraton data + */ uint32_t BlueIOBleSrvcInit(BLUEIOSRVC *pSrvc, const BLUEIOSRVC_CFG *pCfg) { uint32_t err; @@ -286,17 +302,11 @@ uint32_t BlueIOBleSrvcInit(BLUEIOSRVC *pSrvc, const BLUEIOSRVC_CFG *pCfg) pSrvc->NbChar = pCfg->NbChar; - //memcpy(pSrvc->pCharArray, pCfg->pCharArray, pCfg->NbChar); - pSrvc->pCharArray = pCfg->pCharArray; - for (pSrvc->NbChar = 0; pSrvc->NbChar < pCfg->NbChar; pSrvc->NbChar++) + for (int i = 0; i < pCfg->NbChar; i++) { - err = BlueIOBleSrvcCharAdd(pSrvc, pSrvc->pCharArray[pSrvc->NbChar].Uuid, - pSrvc->pCharArray[pSrvc->NbChar].MaxDataLen, - pSrvc->pCharArray[pSrvc->NbChar].Property, - pSrvc->pCharArray[pSrvc->NbChar].pDesc, - &pSrvc->pCharArray[pSrvc->NbChar].Hdl, + err = BlueIOBleSrvcCharAdd(pSrvc, &pSrvc->pCharArray[i], pCfg->SecType); if (err != NRF_SUCCESS) { From 2e369f8d22df247d386ebfed0d2ce593d9536bb9 Mon Sep 17 00:00:00 2001 From: Nguyen Hoan Hoang Date: Wed, 22 Feb 2017 15:49:33 -0500 Subject: [PATCH 7/9] Add interrupt sensing on I/O pins --- ARM/Nordic/src/iopincfg_nrf5x.c | 37 ++++++++++++++++++++++++++++++++- include/iopincfg.h | 20 ++++++++++++++++-- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/ARM/Nordic/src/iopincfg_nrf5x.c b/ARM/Nordic/src/iopincfg_nrf5x.c index 05467d38..18200c30 100755 --- a/ARM/Nordic/src/iopincfg_nrf5x.c +++ b/ARM/Nordic/src/iopincfg_nrf5x.c @@ -56,7 +56,7 @@ typedef struct { IOPINSENS_EVTHOOK s_GpIOSenseEvt[IOPIN_MAX_INT] = { {0, NULL}, }; -/* +/** * Configure individual I/O pin. nRF51 only have 1 port so PortNo is not used * * @Param PortNo : Port number @@ -101,6 +101,26 @@ void IOPinConfig(int PortNo, int PinNo, int PinOp, IOPINDIR Dir, IOPINRES Resist NRF_GPIO->PIN_CNF[PinNo] = cnf; } +/** + * @brief Disable I/O pin + * + * Some hardware such as low power mcu allow I/O pin to be disconnected + * in order to save power. There is no enable function. Reconfigure the + * I/O pin to re-enable it. + * + * @param PortNo : Port number + * @param PinNo : Pin Number + */ +void IOPinDisable(int PortNo, int PinNo) +{ + // TODO : Implement disconnect pin +} + +/** + * @brief Disable I/O pin sense interrupt + * + * @param IntNo : Interrupt number to disable + */ void IOPinDisbleInterrupt(int IntNo) { if (IntNo >= 0 && IntNo < 8) @@ -110,6 +130,21 @@ void IOPinDisbleInterrupt(int IntNo) } } +/** + * @brief Enable I/O pin sensing interrupt event + * + * Generate an interrupt when I/O sense a state change. + * The IntNo (interrupt number) parameter is processor dependent. Some is + * directly the hardware interrupt number other is just an index in an array + * + * + * @param IntNo : Interrupt number. + * IntPrio : Interrupt priority + * PortNo : Port number (up to 32 ports) + * PinNo : Pin number (up to 32 pins) + * Sense : Sense type of event on the I/O pin + * pEvtCB : Pointer to callback function when event occurs + */ bool IOPinEnableInterrupt(int IntNo, int IntPrio, int PortNo, int PinNo, IOPINSENSE Sense, IOPINEVT_CB pEvtCB) { if (IntNo < 0 || IntNo >= IOPIN_MAX_INT) diff --git a/include/iopincfg.h b/include/iopincfg.h index cb9b1fa9..60e8ab3c 100755 --- a/include/iopincfg.h +++ b/include/iopincfg.h @@ -117,7 +117,19 @@ static inline void IOPinCfg(const IOPINCFG *pCfg, int NbPins) { } /** - * @brief Diable I/O pin sense interrupt + * @brief Disable I/O pin + * + * Some hardware such as low power mcu allow I/O pin to be disconnected + * in order to save power. There is no enable function. Reconfigure the + * I/O pin to re-enable it. + * + * @param PortNo : Port number + * @param PinNo : Pin Number + */ +void IOPinDisable(int PortNo, int PinNo); + +/** + * @brief Disable I/O pin sense interrupt * * @param IntNo : Interrupt number to disable */ @@ -126,8 +138,12 @@ void IOPinDisbleInterrupt(int IntNo); /** * @brief Enable I/O pin sensing interrupt event * + * Generate an interrupt when I/O sense a state change. + * The IntNo (interrupt number) parameter is processor dependent. Some is + * directly the hardware interrupt number other is just an index in an array + * * - * @param IntNo : Interrupt number + * @param IntNo : Interrupt number. * IntPrio : Interrupt priority * PortNo : Port number (up to 32 ports) * PinNo : Pin number (up to 32 pins) From 75e4c6f19c27497a12800849a42449bbc3b7128c Mon Sep 17 00:00:00 2001 From: Nguyen Hoan Hoang Date: Fri, 24 Feb 2017 09:02:22 -0500 Subject: [PATCH 8/9] Renaming. added central support --- .../include/{ble_periph_app.h => ble_app.h} | 84 ++++++--- .../src/{ble_periph_app.cpp => ble_app.cpp} | 171 ++++++++++-------- ARM/Nordic/src/ble_app_handler.c | 63 +++++++ 3 files changed, 224 insertions(+), 94 deletions(-) rename ARM/Nordic/include/{ble_periph_app.h => ble_app.h} (63%) rename ARM/Nordic/src/{ble_periph_app.cpp => ble_app.cpp} (90%) create mode 100644 ARM/Nordic/src/ble_app_handler.c diff --git a/ARM/Nordic/include/ble_periph_app.h b/ARM/Nordic/include/ble_app.h similarity index 63% rename from ARM/Nordic/include/ble_periph_app.h rename to ARM/Nordic/include/ble_app.h index a88d52c6..287dd498 100644 --- a/ARM/Nordic/include/ble_periph_app.h +++ b/ARM/Nordic/include/ble_app.h @@ -1,5 +1,5 @@ /*-------------------------------------------------------------------------- -File : ble_periph_app.h +File : ble_app.h Author : Hoang Nguyen Hoan Dec 26, 2016 @@ -31,8 +31,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Modified by Date Description ----------------------------------------------------------------------------*/ -#ifndef __BLE_PERIPH_APP_H__ -#define __BLE_PERIPH_APP_H__ +#ifndef __BLE_APP_H__ +#define __BLE_APP_H__ #include @@ -66,20 +66,29 @@ typedef enum { #define BLEAPP_INFOSTR_MAX_SIZE 20 typedef void (*PRIVINITCB)(); +typedef void (*BLEEVTHANDLER)(ble_evt_t *pEvt); #pragma pack(push, 4) +typedef struct _BleAppDevInfo { + const char ModelName[16]; // Model name + const char ManufName[16]; // Manufacturer name + const char *pSerialNoStr;// Serial number string + const char *pFwVerStr; // Firmware version string + const char *pHwVerStr; // Hardware version string +} BLEAPP_DEVDESC; + typedef struct _BleAppConfig { - nrf_clock_lf_cfg_t ClkCfg; - BLEAPP_MODE AppMode; + nrf_clock_lf_cfg_t ClkCfg; // Clock config + int CentLinkCount; // Number of central link + int PeriLinkCount; // Number of peripheral link + BLEAPP_MODE AppMode; // App use scheduler, rtos const char *pDevName; // Device name - const char *pModelName; // Model name - const char *pManufName; // Manufacturer name - const char *pSerialNoStr; // Serial number string - const char *pFwVerStr; // Firmware version string - const char *pHwVerStr; // Hardware version string uint16_t VendorID; // PnP Bluetooth/USB vendor id - uint16_t ProductId; // PnP Product ID + uint16_t ProductId; // PnP product ID + uint16_t ProductVer; // PnP product version + bool bEnDevInfoService; // Enable device information service (DIS) + const BLEAPP_DEVDESC *pDevDesc; // Pointer device info descriptor const uint8_t *pManData; // Manufacture specific data to advertise int ManDataLen; // Length of manufacture specific data BLEAPP_SECTYPE SecType; // Secure connection type @@ -90,35 +99,64 @@ typedef struct _BleAppConfig { uint32_t AdvTimeout; // In sec uint32_t AdvSlowInterval; // Slow advertising interval, if > 0, fallback to // slow interval on adv timeout and advertise until connected - int ConnLedPort; + int ConnLedPort; // Connection LED port & pin number int ConnLedPin; - uint32_t (*SDEvtHandler)(void) ; // Require for BLEAPP_MODE_RTOS + uint32_t (*SDEvtHandler)(void) ;// Require for BLEAPP_MODE_RTOS } BLEAPP_CFG; #pragma pack(pop) #ifdef __cplusplus + +class BleApp { +public: + virtual bool Init(BLEAPP_CFG &CfgData); + + virtual void InitCustomData() = 0; + virtual void InitServices() = 0; + virtual void SrvcEvtDispatch(ble_evt_t * p_ble_evt) = 0; + + virtual void ProcessEvt(); + virtual void EnterDfu(); + virtual void Start(); + +private: +}; + extern "C" { #endif + // *** -// Require implementations per app +// Implementations per app as require // -void BlePeriphAppInitUserData(); -void BlePeriphAppInitServices(); -void BlePeriphAppSrvcEvtDispatch(ble_evt_t * p_ble_evt); +void BleAppInitUserData(); +void BleAppInitUserServices(); +void BlePeriphEvtUserHandler(ble_evt_t * p_ble_evt); +void BleCentralEvtUserHandler(ble_evt_t * p_ble_evt); + +//*** Require implementation if app operating mode is BLEAPP_MODE_RTOS +// This function should normal wait for RTOS to signal an event on sent by +// Softdevice +void BleAppRtosWaitEvt(void); /** - * BLE App initialization + * @brief BLE main App initialization + * + * @param pBleAppCfg : Pointer to app configuration data + * @param bEraseBond : true to force erase all bonding info + * + * @return true - success */ -bool BlePeriphAppInit(const BLEAPP_CFG *pBleAppCfg, bool bEraseBond); -void BlePeriphAppProcessEvt(); -void BlePeriphAppEnterDfu(); -void BlePeriphAppStart(); +bool BleAppInit(const BLEAPP_CFG *pBleAppCfg, bool bEraseBond); +void BleAppProcessEvt(); +void BleAppEnterDfu(); +void BleAppStart(); +uint16_t BleAppGetConnHandle(); #ifdef __cplusplus } #endif -#endif // __BLE_PERIPH_APP_H__ +#endif // __BLE_APP_H__ diff --git a/ARM/Nordic/src/ble_periph_app.cpp b/ARM/Nordic/src/ble_app.cpp similarity index 90% rename from ARM/Nordic/src/ble_periph_app.cpp rename to ARM/Nordic/src/ble_app.cpp index b1ca3c4a..327c6098 100644 --- a/ARM/Nordic/src/ble_periph_app.cpp +++ b/ARM/Nordic/src/ble_app.cpp @@ -1,5 +1,5 @@ /*-------------------------------------------------------------------------- -File : ble_periph_app.cpp +File : ble_app.cpp Author : Hoang Nguyen Hoan Dec 26, 2016 @@ -65,7 +65,7 @@ Modified by Date Description #include "custom_board.h" #include "iopincfg.h" #include "iopinctrl.h" -#include "ble_periph_app.h" +#include "ble_app.h" //#define IS_SRVC_CHANGED_CHARACT_PRESENT 1 /**< Include the service_changed characteristic. If not enabled, the server's database cannot be changed for the lifetime of the device. */ @@ -77,8 +77,8 @@ Modified by Date Description #define APP_FEATURE_NOT_SUPPORTED BLE_GATT_STATUS_ATTERR_APP_BEGIN + 2 /**< Reply when unsupported features are requested. */ -#define CENTRAL_LINK_COUNT 0 /**< Number of central links used by the application. When changing this number remember to adjust the RAM settings*/ -#define PERIPHERAL_LINK_COUNT 1 /**< Number of peripheral links used by the application. When changing this number remember to adjust the RAM settings*/ +//#define CENTRAL_LINK_COUNT 0 /**< Number of central links used by the application. When changing this number remember to adjust the RAM settings*/ +//#define PERIPHERAL_LINK_COUNT 1 /**< Number of peripheral links used by the application. When changing this number remember to adjust the RAM settings*/ #define APP_ADV_INTERVAL MSEC_TO_UNITS(64, UNIT_0_625_MS) /**< The advertising interval (in units of 0.625 ms. This value corresponds to 40 ms). */ #define APP_ADV_TIMEOUT_IN_SECONDS 180 /**< The advertising timeout (in units of seconds). */ @@ -214,7 +214,7 @@ static inline void BleConnLedOn() { IOPinClear(g_BleAppData.ConnLedPort, g_BleAppData.ConnLedPin); } -void BlePeriphAppDfuCallback(fs_evt_t const * const evt, fs_ret_t result) +void BleAppDfuCallback(fs_evt_t const * const evt, fs_ret_t result) { if (result == FS_SUCCESS) { @@ -222,7 +222,7 @@ void BlePeriphAppDfuCallback(fs_evt_t const * const evt, fs_ret_t result) } } -void BlePeriphAppEnterDfu() +void BleAppEnterDfu() { uint32_t err_code = nrf_dfu_flash_init(true); @@ -230,7 +230,7 @@ void BlePeriphAppEnterDfu() s_dfu_settings.enter_buttonless_dfu = true; - err_code = nrf_dfu_settings_write(BlePeriphAppDfuCallback); + err_code = nrf_dfu_settings_write(BleAppDfuCallback); if (err_code != NRF_SUCCESS) { @@ -457,6 +457,7 @@ static void on_ble_evt(ble_evt_t * p_ble_evt) (req.request.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_NOW) || (req.request.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL)) { + printf("BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST\r\n"); if (req.type == BLE_GATTS_AUTHORIZE_TYPE_WRITE) { auth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE; @@ -649,12 +650,43 @@ static void pm_evt_handler(pm_evt_t const * p_evt) */ static void ble_evt_dispatch(ble_evt_t * p_ble_evt) { + uint16_t role = ble_conn_state_role(p_ble_evt->evt.gap_evt.conn_handle); + ble_conn_state_on_ble_evt(p_ble_evt); pm_on_ble_evt(p_ble_evt); - BlePeriphAppSrvcEvtDispatch(p_ble_evt); - ble_conn_params_on_ble_evt(p_ble_evt); + on_ble_evt(p_ble_evt); - ble_advertising_on_ble_evt(p_ble_evt); + if (role == BLE_GAP_ROLE_PERIPH) + { + ble_advertising_on_ble_evt(p_ble_evt); + ble_conn_params_on_ble_evt(p_ble_evt); + BlePeriphEvtUserHandler(p_ble_evt); + } + else if ((role == BLE_GAP_ROLE_CENTRAL) || (p_ble_evt->header.evt_id == BLE_GAP_EVT_ADV_REPORT)) + { + BleCentralEvtUserHandler(p_ble_evt); +#if 0 + /** on_ble_central_evt will update the connection handles, so we want to execute it + * after dispatching to the central applications upon disconnection. */ + if (p_ble_evt->header.evt_id != BLE_GAP_EVT_DISCONNECTED) + { + on_ble_central_evt(p_ble_evt); + } + + if (conn_handle < NRF_BLE_LINK_COUNT) + { + ble_db_discovery_on_ble_evt(&m_ble_db_discovery[conn_handle], p_ble_evt); + } + ble_hrs_c_on_ble_evt(&m_ble_hrs_c, p_ble_evt); + + // If the peer disconnected, we update the connection handles last. + if (p_ble_evt->header.evt_id == BLE_GAP_EVT_DISCONNECTED) + { + on_ble_central_evt(p_ble_evt); + } +#endif + } + } /**@brief Function for dispatching a system event to interested modules. @@ -683,7 +715,7 @@ static void sys_evt_dispatch(uint32_t sys_evt) * @param[in] erase_bonds Indicates whether bonding information should be cleared from * persistent storage during initialization of the Peer Manager. */ -static void BlePeriphAppPeerMngrInit(BLEAPP_SECTYPE SecType, uint8_t SecKeyExchg, bool bEraseBond) +static void BleAppPeerMngrInit(BLEAPP_SECTYPE SecType, uint8_t SecKeyExchg, bool bEraseBond) { ble_gap_sec_params_t sec_param; ret_code_t err_code; @@ -786,7 +818,7 @@ static void sec_req_timeout_handler(void * p_context) /**@brief Function for initializing the Advertising functionality. */ -void BlePeriphAppAdvInit(const BLEAPP_CFG *pCfg) +void BleAppAdvInit(const BLEAPP_CFG *pCfg) { uint32_t err_code; ble_advdata_t advdata; @@ -826,11 +858,44 @@ void BlePeriphAppAdvInit(const BLEAPP_CFG *pCfg) APP_ERROR_CHECK(err_code); } -/**@brief Function for the SoftDevice initialization. +void BleAppDisInit(const BLEAPP_CFG *pBleAppCfg) +{ + ble_dis_init_t dis_init; + ble_dis_pnp_id_t pnp_id; + + // Initialize Device Information Service. + memset(&dis_init, 0, sizeof(dis_init)); + + if (pBleAppCfg->pDevDesc) + { + ble_srv_ascii_to_utf8(&dis_init.manufact_name_str, (char*)pBleAppCfg->pDevDesc->ManufName); + ble_srv_ascii_to_utf8(&dis_init.model_num_str, (char*)pBleAppCfg->pDevDesc->ModelName); + if (pBleAppCfg->pDevDesc->pSerialNoStr) + ble_srv_ascii_to_utf8(&dis_init.serial_num_str, (char*)pBleAppCfg->pDevDesc->pSerialNoStr); + if (pBleAppCfg->pDevDesc->pFwVerStr) + ble_srv_ascii_to_utf8(&dis_init.fw_rev_str, (char*)pBleAppCfg->pDevDesc->pFwVerStr); + if (pBleAppCfg->pDevDesc->pHwVerStr) + ble_srv_ascii_to_utf8(&dis_init.hw_rev_str, (char*)pBleAppCfg->pDevDesc->pHwVerStr); + } + + pnp_id.vendor_id = pBleAppCfg->VendorID; + pnp_id.product_id = pBleAppCfg->ProductId; + dis_init.p_pnp_id = &pnp_id; + + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&dis_init.dis_attr_md.read_perm); + BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&dis_init.dis_attr_md.write_perm); + + uint32_t err_code = ble_dis_init(&dis_init); + APP_ERROR_CHECK(err_code); + +} + +/** + * @brief Function for the SoftDevice initialization. * * @details This function initializes the SoftDevice and the BLE event interrupt. */ -bool BlePeriphAppInit(const BLEAPP_CFG *pBleAppCfg, bool bEraseBond) +bool BleAppInit(const BLEAPP_CFG *pBleAppCfg, bool bEraseBond) { uint32_t err_code; @@ -865,8 +930,8 @@ bool BlePeriphAppInit(const BLEAPP_CFG *pBleAppCfg, bool bEraseBond) // Initialize SoftDevice. ble_enable_params_t ble_enable_params; - err_code = softdevice_enable_get_default_config(CENTRAL_LINK_COUNT, - PERIPHERAL_LINK_COUNT, + err_code = softdevice_enable_get_default_config(pBleAppCfg->CentLinkCount, + pBleAppCfg->PeriLinkCount, &ble_enable_params); APP_ERROR_CHECK(err_code); @@ -887,7 +952,7 @@ bool BlePeriphAppInit(const BLEAPP_CFG *pBleAppCfg, bool bEraseBond) err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch); APP_ERROR_CHECK(err_code); - BlePeriphAppPeerMngrInit(pBleAppCfg->SecType, pBleAppCfg->SecExchg, bEraseBond); + BleAppPeerMngrInit(pBleAppCfg->SecType, pBleAppCfg->SecExchg, bEraseBond); nrf_crypto_init(); @@ -908,77 +973,41 @@ bool BlePeriphAppInit(const BLEAPP_CFG *pBleAppCfg, bool bEraseBond) gap_params_init(pBleAppCfg); - BlePeriphAppInitUserData(); - - BlePeriphAppInitServices(); - - ble_dis_init_t dis_init; - ble_dis_pnp_id_t pnp_id; - - // Initialize Device Information Service. - memset(&dis_init, 0, sizeof(dis_init)); - - if (pBleAppCfg->pManufName) - { - ble_srv_ascii_to_utf8(&dis_init.manufact_name_str, (char*)pBleAppCfg->pManufName); - } + BleAppInitUserData(); - if (pBleAppCfg->pModelName) - { - ble_srv_ascii_to_utf8(&dis_init.model_num_str, (char*)pBleAppCfg->pModelName); - } + BleAppInitUserServices(); - if (pBleAppCfg->pSerialNoStr) - { - ble_srv_ascii_to_utf8(&dis_init.serial_num_str, (char*)pBleAppCfg->pSerialNoStr); - } + if (pBleAppCfg->bEnDevInfoService) + BleAppDisInit(pBleAppCfg); - if (pBleAppCfg->pFwVerStr) - { - ble_srv_ascii_to_utf8(&dis_init.fw_rev_str, (char*)pBleAppCfg->pFwVerStr); - } - - if (pBleAppCfg->pHwVerStr) - { - ble_srv_ascii_to_utf8(&dis_init.hw_rev_str, (char*)pBleAppCfg->pHwVerStr); - } - - pnp_id.vendor_id = pBleAppCfg->VendorID; - dis_init.p_pnp_id = &pnp_id; - - BLE_GAP_CONN_SEC_MODE_SET_OPEN(&dis_init.dis_attr_md.read_perm); - BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&dis_init.dis_attr_md.write_perm); - - err_code = ble_dis_init(&dis_init); - APP_ERROR_CHECK(err_code); - - BlePeriphAppAdvInit(pBleAppCfg); + BleAppAdvInit(pBleAppCfg); conn_params_init(); return true; } -void BlePeriphAppStart() +void BleAppStart() { uint32_t err_code = ble_advertising_start(BLE_ADV_MODE_FAST); APP_ERROR_CHECK(err_code); -} -void BlePeriphAppProcessEvt() -{ - if (g_BleAppData.AppMode == BLEAPP_MODE_RTOS) + while (1) { - intern_softdevice_events_execute(); - } - else - { - if (g_BleAppData.AppMode == BLEAPP_MODE_APPSCHED) + if (g_BleAppData.AppMode == BLEAPP_MODE_RTOS) + { + BleAppRtosWaitEvt(); + intern_softdevice_events_execute(); + } + else { - app_sched_execute(); + if (g_BleAppData.AppMode == BLEAPP_MODE_APPSCHED) + { + app_sched_execute(); + } + sd_app_evt_wait(); } - sd_app_evt_wait(); } } diff --git a/ARM/Nordic/src/ble_app_handler.c b/ARM/Nordic/src/ble_app_handler.c new file mode 100644 index 00000000..106ba0f3 --- /dev/null +++ b/ARM/Nordic/src/ble_app_handler.c @@ -0,0 +1,63 @@ +/*-------------------------------------------------------------------------- +File : ble_app_handler.cpp + +Author : Hoang Nguyen Hoan Feb. 23, 2017 + +Desc : Nordic SDK based BLE peripheral application creation helper + Dummy user app handler. + All functions can be overloaded + +Copyright (c) 2017, I-SYST inc., all rights reserved + +Permission to use, copy, modify, and distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright +notice and this permission notice appear in all copies, and none of the +names : I-SYST or its contributors may be used to endorse or +promote products derived from this software without specific prior written +permission. + +For info or contributing contact : hnhoan at i-syst dot com + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +---------------------------------------------------------------------------- +Modified by Date Description + +----------------------------------------------------------------------------*/ +#include "ble_app.h" + +void __WEAK BleAppInitUserData() +{ + +} + +void __WEAK BleAppInitUserServices() +{ + +} + +void __WEAK BlePeriphEvtUserHandler(ble_evt_t * p_ble_evt) +{ + +} + +void __WEAK BleCentralEvtUserHandler(ble_evt_t * p_ble_evt) +{ + +} + +void __WEAK BleAppRtosWaitEvt(void) +{ + +} + + From 5c93879d13dc436d3b11db9e8a8c61fa4ffa42fc Mon Sep 17 00:00:00 2001 From: Nguyen Hoan Hoang Date: Tue, 28 Feb 2017 22:05:34 -0500 Subject: [PATCH 9/9] project updated for new files name --- ARM/Nordic/nRF51/EHAL/.project | 23 +++++++++++++++++++---- ARM/Nordic/nRF52/EHAL/.project | 25 +++++++++++++++---------- ARM/Nordic/nRF52/EHAL/src/sdk_config.h | 4 ++-- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/ARM/Nordic/nRF51/EHAL/.project b/ARM/Nordic/nRF51/EHAL/.project index 0d0cc9ef..f76cb795 100755 --- a/ARM/Nordic/nRF51/EHAL/.project +++ b/ARM/Nordic/nRF51/EHAL/.project @@ -36,9 +36,9 @@ PARENT-3-WORKSPACE_LOC/include/base64.h - include/ble_periph_app.h + include/ble_app.h 1 - PARENT-2-PROJECT_LOC/include/ble_periph_app.h + PARENT-2-PROJECT_LOC/include/ble_app.h include/blueio_blesrvc.h @@ -50,6 +50,11 @@ 1 PARENT-2-PROJECT_LOC/include/blueio_board.h + + include/bme280.h + 1 + PARENT-4-PROJECT_LOC/include/bme280.h + include/cfifo.h 1 @@ -100,6 +105,11 @@ 1 PARENT-3-PROJECT_LOC/include/idelay.h + + include/idevice.h + 1 + PARENT-4-PROJECT_LOC/include/idevice.h + include/intelhex.h 1 @@ -206,9 +216,14 @@ PARENT-4-PROJECT_LOC/src/base64.c - src/ble_periph_app.cpp + src/ble_app.cpp + 1 + PARENT-2-PROJECT_LOC/src/ble_app.cpp + + + src/ble_app_handler.c 1 - PARENT-2-PROJECT_LOC/src/ble_periph_app.cpp + PARENT-2-PROJECT_LOC/src/ble_app_handler.c src/blueio_blesrvc.c diff --git a/ARM/Nordic/nRF52/EHAL/.project b/ARM/Nordic/nRF52/EHAL/.project index a98d1673..12c5807d 100755 --- a/ARM/Nordic/nRF52/EHAL/.project +++ b/ARM/Nordic/nRF52/EHAL/.project @@ -36,9 +36,9 @@ PARENT-4-PROJECT_LOC/include/base64.h - include/ble_periph_app.h + include/ble_app.h 1 - PARENT-2-PROJECT_LOC/include/ble_periph_app.h + PARENT-2-PROJECT_LOC/include/ble_app.h include/blueio_blesrvc.h @@ -216,9 +216,14 @@ PARENT-4-PROJECT_LOC/src/base64.c - src/ble_periph_app.cpp + src/ble_app.cpp 1 - PARENT-2-PROJECT_LOC/src/ble_periph_app.cpp + PARENT-2-PROJECT_LOC/src/ble_app.cpp + + + src/ble_app_handler.c + 1 + PARENT-2-PROJECT_LOC/src/ble_app_handler.c src/blueio_blesrvc.c @@ -295,6 +300,11 @@ 2 virtual:/virtual + + src/nrf_log_backend_printf.c + 1 + PARENT-2-PROJECT_LOC/src/nrf_log_backend_printf.c + src/prbs.c 1 @@ -600,11 +610,6 @@ 2 virtual:/virtual - - src/nRF5_SDK_12/libraries/sha256 - 2 - virtual:/virtual - src/nRF5_SDK_12/libraries/svc 2 @@ -1033,7 +1038,7 @@ src/nRF5_SDK_12/libraries/sha256/sha256.c 1 - PARENT-5-PROJECT_LOC/external/nRF5_SDK_12/components/libraries/sha256/sha256.c + $%7BPARENT-5-PROJECT_LOC%7D/external/nRF5_SDK_12/components/libraries/sha256/sha256.c src/nRF5_SDK_12/libraries/svc/nrf_svc_handler.c diff --git a/ARM/Nordic/nRF52/EHAL/src/sdk_config.h b/ARM/Nordic/nRF52/EHAL/src/sdk_config.h index a0dd621b..98022725 100644 --- a/ARM/Nordic/nRF52/EHAL/src/sdk_config.h +++ b/ARM/Nordic/nRF52/EHAL/src/sdk_config.h @@ -3573,7 +3573,7 @@ // NRF_LOG_ENABLED - nrf_log - Logging //========================================================== #ifndef NRF_LOG_ENABLED -#define NRF_LOG_ENABLED 1 +#define NRF_LOG_ENABLED 0 #endif #if NRF_LOG_ENABLED // NRF_LOG_USES_COLORS - If enabled then ANSI escape code for colors is prefixed to every string @@ -3650,7 +3650,7 @@ // Log data is buffered and can be processed in idle. //========================================================== #ifndef NRF_LOG_DEFERRED -#define NRF_LOG_DEFERRED 1 +#define NRF_LOG_DEFERRED 0 #endif #if NRF_LOG_DEFERRED // NRF_LOG_DEFERRED_BUFSIZE - Size of the buffer for logs in words.