123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679 |
- extern "C" {
- enum BLE_COMMON_SVCS
- {
- SD_BLE_ENABLE = BLE_SVC_BASE,
- SD_BLE_EVT_GET,
- SD_BLE_UUID_VS_ADD,
- SD_BLE_UUID_DECODE,
- SD_BLE_UUID_ENCODE,
- SD_BLE_VERSION_GET,
- SD_BLE_USER_MEM_REPLY,
- SD_BLE_OPT_SET,
- SD_BLE_OPT_GET,
- SD_BLE_CFG_SET,
- SD_BLE_UUID_VS_REMOVE,
- };
- enum BLE_COMMON_EVTS
- {
- BLE_EVT_USER_MEM_REQUEST = BLE_EVT_BASE + 0,
- BLE_EVT_USER_MEM_RELEASE = BLE_EVT_BASE + 1,
- };
- enum BLE_CONN_CFGS
- {
- BLE_CONN_CFG_GAP = BLE_CONN_CFG_BASE + 0,
- BLE_CONN_CFG_GATTC = BLE_CONN_CFG_BASE + 1,
- BLE_CONN_CFG_GATTS = BLE_CONN_CFG_BASE + 2,
- BLE_CONN_CFG_GATT = BLE_CONN_CFG_BASE + 3,
- BLE_CONN_CFG_L2CAP = BLE_CONN_CFG_BASE + 4,
- };
- enum BLE_COMMON_CFGS
- {
- BLE_COMMON_CFG_VS_UUID = BLE_CFG_BASE,
- };
- enum BLE_COMMON_OPTS
- {
- BLE_COMMON_OPT_PA_LNA = BLE_OPT_BASE + 0,
- BLE_COMMON_OPT_CONN_EVT_EXT = BLE_OPT_BASE + 1,
- BLE_COMMON_OPT_EXTENDED_RC_CAL = BLE_OPT_BASE + 2,
- };
- offsetof(ble_evt_t, evt.gattc_evt.params.prim_srvc_disc_rsp.services) + ((ATT_MTU) - 1) / 4 * sizeof(ble_gattc_service_t) \
- )
- typedef struct
- {
- uint8_t *p_mem;
- uint16_t len;
- } ble_user_mem_block_t;
- typedef struct
- {
- uint8_t type;
- } ble_evt_user_mem_request_t;
- typedef struct
- {
- uint8_t type;
- ble_user_mem_block_t mem_block;
- } ble_evt_user_mem_release_t;
- typedef struct
- {
- uint16_t conn_handle;
- union
- {
- ble_evt_user_mem_request_t user_mem_request;
- ble_evt_user_mem_release_t user_mem_release;
- } params;
- } ble_common_evt_t;
- typedef struct
- {
- uint16_t evt_id;
- uint16_t evt_len;
- } ble_evt_hdr_t;
- typedef struct
- {
- ble_evt_hdr_t header;
- union
- {
- ble_common_evt_t common_evt;
- ble_gap_evt_t gap_evt;
- ble_gattc_evt_t gattc_evt;
- ble_gatts_evt_t gatts_evt;
- ble_l2cap_evt_t l2cap_evt;
- } evt;
- } ble_evt_t;
- typedef struct
- {
- uint8_t version_number;
- uint16_t company_id;
- uint16_t subversion_number;
- } ble_version_t;
- typedef struct
- {
- uint8_t enable :1;
- uint8_t active_high :1;
- uint8_t gpio_pin :6;
- } ble_pa_lna_cfg_t;
- typedef struct
- {
- ble_pa_lna_cfg_t pa_cfg;
- ble_pa_lna_cfg_t lna_cfg;
- uint8_t ppi_ch_id_set;
- uint8_t ppi_ch_id_clr;
- uint8_t gpiote_ch_id;
- } ble_common_opt_pa_lna_t;
- typedef struct
- {
- uint8_t enable : 1;
- } ble_common_opt_conn_evt_ext_t;
- typedef struct
- {
- uint8_t enable : 1;
- } ble_common_opt_extended_rc_cal_t;
- typedef union
- {
- ble_common_opt_pa_lna_t pa_lna;
- ble_common_opt_conn_evt_ext_t conn_evt_ext;
- ble_common_opt_extended_rc_cal_t extended_rc_cal;
- } ble_common_opt_t;
- typedef union
- {
- ble_common_opt_t common_opt;
- ble_gap_opt_t gap_opt;
- ble_gattc_opt_t gattc_opt;
- } ble_opt_t;
- typedef struct
- {
- uint8_t conn_cfg_tag;
- union {
- ble_gap_conn_cfg_t gap_conn_cfg;
- ble_gattc_conn_cfg_t gattc_conn_cfg;
- ble_gatts_conn_cfg_t gatts_conn_cfg;
- ble_gatt_conn_cfg_t gatt_conn_cfg;
- ble_l2cap_conn_cfg_t l2cap_conn_cfg;
- } params;
- } ble_conn_cfg_t;
- typedef struct
- {
- uint8_t vs_uuid_count;
- } ble_common_cfg_vs_uuid_t;
- typedef union
- {
- ble_common_cfg_vs_uuid_t vs_uuid_cfg;
- } ble_common_cfg_t;
- typedef union
- {
- ble_conn_cfg_t conn_cfg;
- ble_common_cfg_t common_cfg;
- ble_gap_cfg_t gap_cfg;
- ble_gatts_cfg_t gatts_cfg;
- } ble_cfg_t;
- SVCALL(SD_BLE_ENABLE, uint32_t, sd_ble_enable(uint32_t * p_app_ram_base));
- SVCALL(SD_BLE_CFG_SET, uint32_t, sd_ble_cfg_set(uint32_t cfg_id, ble_cfg_t const * p_cfg, uint32_t app_ram_base));
- SVCALL(SD_BLE_EVT_GET, uint32_t, sd_ble_evt_get(uint8_t *p_dest, uint16_t *p_len));
- SVCALL(SD_BLE_UUID_VS_ADD, uint32_t, sd_ble_uuid_vs_add(ble_uuid128_t const *p_vs_uuid, uint8_t *p_uuid_type));
- SVCALL(SD_BLE_UUID_VS_REMOVE, uint32_t, sd_ble_uuid_vs_remove(uint8_t *p_uuid_type));
- SVCALL(SD_BLE_UUID_DECODE, uint32_t, sd_ble_uuid_decode(uint8_t uuid_le_len, uint8_t const *p_uuid_le, ble_uuid_t *p_uuid));
- SVCALL(SD_BLE_UUID_ENCODE, uint32_t, sd_ble_uuid_encode(ble_uuid_t const *p_uuid, uint8_t *p_uuid_le_len, uint8_t *p_uuid_le));
- SVCALL(SD_BLE_VERSION_GET, uint32_t, sd_ble_version_get(ble_version_t *p_version));
- SVCALL(SD_BLE_USER_MEM_REPLY, uint32_t, sd_ble_user_mem_reply(uint16_t conn_handle, ble_user_mem_block_t const *p_block));
- SVCALL(SD_BLE_OPT_SET, uint32_t, sd_ble_opt_set(uint32_t opt_id, ble_opt_t const *p_opt));
- SVCALL(SD_BLE_OPT_GET, uint32_t, sd_ble_opt_get(uint32_t opt_id, ble_opt_t *p_opt));
- }
|