本文整理汇总了C++中APP_ERROR_CHECK函数 的典型用法代码示例。如果您正苦于以下问题:C++ APP_ERROR_CHECK函数的具体用法?C++ APP_ERROR_CHECK怎么用?C++ APP_ERROR_CHECK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了APP_ERROR_CHECK函数 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: process_message_address_available
/**@brief Processes an ANT messages while in the address available state.
*
* @param[in] Pointer to the raw ant message received.
*/
static void process_message_address_available(uint8_t * p_ant_message)
{
uint32_t err_code;
switch (p_ant_message[ANT_MESSAGE_ID_OFFSET])
{
case MESG_RESPONSE_EVENT_ID:
{
if(p_ant_message[ANT_MESSAGE_DATA0_OFFSET] == MESG_EVENT_ID) //Channel event
{
switch(p_ant_message[ANT_MESSAGE_DATA1_OFFSET])
{
case EVENT_TX:
{
if(m_is_command_pending == true)
{
ascm_set_state(SENDING_COMMAND);
}
else if(m_device_registry.count > 0 && ++m_msg_counter_address_available > MAX_TX_MESSAGES_ADDRESS_AVAILABLE)
{
m_msg_counter_address_available = 0;
ascm_set_state(POLLING);
}
break;
}
}
}
break;
}
case MESG_BROADCAST_DATA_ID:
//fall-through
case MESG_ACKNOWLEDGED_DATA_ID:
{
//Process by page
switch (p_ant_message[DECODE_PAGE_ID_BYTE])
{
case REQUEST_ADDRESS_PID:
{
if(m_is_address_available)
{
uint32_t* p_serial_number = &(m_handshaking_device.serial_number);
err_code = asc_decode_request_address_page(p_serial_number, p_ant_message);
APP_ERROR_CHECK(err_code);
ascm_set_state(HANDSHAKING);
}
break;
}
case UPDATE_DATA_PID:
{
process_device_update(p_ant_message);
break;
}
default:
{
break;
}
}
break;
}
default:
break;
}
}
开发者ID:RobinLin, 项目名称:Espruino, 代码行数:68, 代码来源:asc_master.c
示例2: power_manage
/** @brief Function for the Power manager.
*/
static void power_manage(void)
{
uint32_t err_code = sd_app_evt_wait();
APP_ERROR_CHECK(err_code);
}
开发者ID:JulianYG, 项目名称:WNR, 代码行数:8, 代码来源:main.c
示例3: handle_data_packet
static void handle_data_packet(dfu_packet_t* p_packet, uint16_t length)
{
mesh_packet_t* p_cache_packet = packet_cache_entry_get(p_packet);
if (p_cache_packet)
{
transport_tx_skip(p_cache_packet);
}
bool do_relay = false;
if (p_packet->payload.data.transaction_id == m_transaction.transaction_id)
{
/* check and add to cache */
if (data_packet_in_cache(p_packet))
{
return;
}
m_data_cache[(m_data_index++) & (DATA_CACHE_SIZE - 1)] = p_packet->payload.data.segment;
if (m_state == BL_STATE_DFU_READY)
{
if (p_packet->payload.start.segment == 0)
{
bl_info_segment_t* p_segment = NULL;
switch (m_transaction.type)
{
case DFU_TYPE_APP:
p_segment = m_bl_info_pointers.p_segment_app;
break;
case DFU_TYPE_SD:
p_segment = m_bl_info_pointers.p_segment_sd;
break;
case DFU_TYPE_BOOTLOADER:
p_segment = m_bl_info_pointers.p_segment_bl;
break;
default:
APP_ERROR_CHECK(NRF_ERROR_NOT_SUPPORTED);
}
m_transaction.p_indicated_start_addr = (uint32_t*) p_packet->payload.start.start_address;
uint32_t start_address = p_packet->payload.start.start_address;
/* if the host doesn't know the start address, we use start of segment: */
if (start_address == START_ADDRESS_UNKNOWN)
{
start_address = p_segment->start;
}
uint32_t segment_count = ((p_packet->payload.start.length * 4) + (start_address & 0x0F) - 1) / 16 + 1;
if (p_packet->payload.start.signature_length != 0)
{
segment_count += p_packet->payload.start.signature_length / SEGMENT_LENGTH;
}
if (segment_count > 0xFFFF)
{
/* can't have more than 65536 segments in a transmission */
segment_count = 0xFFFF;
}
m_transaction.segments_remaining = segment_count;
m_transaction.segment_count = segment_count;
m_transaction.p_start_addr = (uint32_t*) start_address;
m_transaction.length = p_packet->payload.start.length * 4;
m_transaction.signature_length = p_packet->payload.start.signature_length;
m_transaction.segment_is_valid_after_transfer = p_packet->payload.start.last;
m_transaction.p_last_requested_entry = NULL;
m_transaction.signature_bitmap = 0;
if (m_transaction.type == DFU_TYPE_BOOTLOADER)
{
m_transaction.p_bank_addr = (uint32_t*) (
(m_bl_info_pointers.p_segment_app->start) +
(m_bl_info_pointers.p_segment_app->length) -
(m_transaction.length & ((uint32_t) ~(PAGE_SIZE - 1))) -
(PAGE_SIZE)
);
}
else
{
m_transaction.p_bank_addr = m_transaction.p_start_addr;
}
if ((uint32_t) m_transaction.p_start_addr >= p_segment->start &&
(uint32_t) m_transaction.p_start_addr + m_transaction.length <= p_segment->start + p_segment->length)
{
start_target();
do_relay = true;
}
}
else
{
m_tid_cache[(m_tid_index++) & (TRANSACTION_ID_CACHE_SIZE - 1)] = m_transaction.transaction_id;
start_req(m_transaction.type, true); /* go back to req, we've missed packet 0 */
}
}
else if (m_state == BL_STATE_DFU_TARGET)
{
if (p_packet->payload.data.segment > 0 &&
p_packet->payload.data.segment <= m_transaction.segment_count)
//.........这里部分代码省略.........
开发者ID:glenne, 项目名称:nRF51-ble-bcast-mesh, 代码行数:101, 代码来源:bootloader_mesh.c
示例4: on_ble_evt
/**@brief Function for handling the Application's BLE Stack events.
*
* @param[in] p_ble_evt Bluetooth stack event.
*/
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code;
static uint16_t s_conn_handle = BLE_CONN_HANDLE_INVALID;
static ble_gap_sec_keyset_t s_sec_keyset;
ble_gap_enc_info_t * p_enc_info;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
APP_ERROR_CHECK(err_code);
s_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
break;
case BLE_GAP_EVT_DISCONNECTED:
err_code = bsp_indication_set(BSP_INDICATE_IDLE);
APP_ERROR_CHECK(err_code);
advertising_start();
break;
case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
s_sec_keyset.keys_central.p_enc_key = NULL;
s_sec_keyset.keys_central.p_id_key = NULL;
s_sec_keyset.keys_central.p_enc_key = NULL;
err_code = sd_ble_gap_sec_params_reply(s_conn_handle,
BLE_GAP_SEC_STATUS_SUCCESS,
&m_sec_params,
&s_sec_keyset);
APP_ERROR_CHECK(err_code);
break;
case BLE_GAP_EVT_AUTH_STATUS:
break;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
err_code = sd_ble_gatts_sys_attr_set(s_conn_handle, NULL, 0, 0);
APP_ERROR_CHECK(err_code);
break;
case BLE_GAP_EVT_SEC_INFO_REQUEST:
if (s_sec_keyset.keys_periph.p_enc_key != NULL)
{
p_enc_info = &s_sec_keyset.keys_periph.p_enc_key->enc_info;
err_code = sd_ble_gap_sec_info_reply(s_conn_handle, p_enc_info, NULL, NULL);
APP_ERROR_CHECK(err_code);
}
else
{
// No keys found for this device.
err_code = sd_ble_gap_sec_info_reply(s_conn_handle, NULL, NULL, NULL);
APP_ERROR_CHECK(err_code);
}
break;
case BLE_GAP_EVT_TIMEOUT:
if (p_ble_evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_ADVERTISING)
{
err_code = bsp_indication_set(BSP_INDICATE_IDLE);
APP_ERROR_CHECK(err_code);
err_code = app_button_disable();
APP_ERROR_CHECK(err_code);
if (err_code == NRF_SUCCESS)
{
// Configure buttons with sense level low as wakeup source.
// err_code = bsp_buttons_enable((1 << BLE_BUTTON_ID) | (1 << GZLL_BUTTON_ID));
// nrf_gpio_cfg_sense_input(BLE_BUTTON_PIN_NO,
// BUTTON_PULL,
// NRF_GPIO_PIN_SENSE_LOW);
//
// nrf_gpio_cfg_sense_input(GZLL_BUTTON_PIN_NO,
// BUTTON_PULL,
// NRF_GPIO_PIN_SENSE_LOW);
// Go to system-off mode.
// (this function will not return; wakeup will cause a reset)
err_code = sd_power_system_off();
APP_ERROR_CHECK(err_code);
}
}
break;
default:
// No implementation needed.
break;
}
}
开发者ID:RobinLin, 项目名称:Espruino, 代码行数:95, 代码来源:ble_app_gzll_hr.c
示例5: on_ble_evt
/**@brief Function for handling the Application's BLE Stack events.
*
* @param[in] p_ble_evt Bluetooth stack event.
*/
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code;
const ble_gap_evt_t * p_gap_evt = &p_ble_evt->evt.gap_evt;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_ADV_REPORT:
{
data_t adv_data;
data_t type_data;
// Initialize advertisement report for parsing.
adv_data.p_data = (uint8_t *)p_gap_evt->params.adv_report.data;
adv_data.data_len = p_gap_evt->params.adv_report.dlen;
err_code = adv_report_parse(BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE,
&adv_data,
&type_data);
if (err_code != NRF_SUCCESS)
{
// Compare short local name in case complete name does not match.
err_code = adv_report_parse(BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE,
&adv_data,
&type_data);
}
// Verify if short or complete name matches target.
if (err_code == NRF_SUCCESS)
{
uint16_t extracted_uuid;
// UUIDs found, look for matching UUID
for (uint32_t u_index = 0; u_index < (type_data.data_len / UUID16_SIZE); u_index++)
{
UUID16_EXTRACT(&extracted_uuid, &type_data.p_data[u_index * UUID16_SIZE]);
APPL_LOG("\t[APPL]: %x\r\n", extracted_uuid);
if (extracted_uuid == TARGET_UUID)
{
// Stop scanning.
err_code = sd_ble_gap_scan_stop();
if (err_code != NRF_SUCCESS)
{
APPL_LOG("[APPL]: Scan stop failed, reason %d\r\n", err_code);
}
err_code = bsp_indication_set(BSP_INDICATE_IDLE);
APP_ERROR_CHECK(err_code);
m_scan_param.selective = 0;
// Initiate connection.
err_code = sd_ble_gap_connect(&p_gap_evt->params.adv_report.peer_addr,
&m_scan_param,
&m_connection_param);
m_whitelist_temporarily_disabled = false;
if (err_code != NRF_SUCCESS)
{
APPL_LOG("[APPL]: Connection Request Failed, reason %d\r\n", err_code);
}
break;
}
}
}
break;
}
case BLE_GAP_EVT_TIMEOUT:
if (p_gap_evt->params.timeout.src == BLE_GAP_TIMEOUT_SRC_SCAN)
{
APPL_LOG("[APPL]: Scan timed out.\r\n");
scan_start();
}
else if (p_gap_evt->params.timeout.src == BLE_GAP_TIMEOUT_SRC_CONN)
{
APPL_LOG("[APPL]: Connection Request timed out.\r\n");
}
break;
case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST:
// Accepting parameters requested by peer.
err_code = sd_ble_gap_conn_param_update(p_gap_evt->conn_handle,
&p_gap_evt->params.conn_param_update_request.conn_params);
APP_ERROR_CHECK(err_code);
break;
default:
break;
}
}
开发者ID:JulianYG, 项目名称:WNR, 代码行数:99, 代码来源:main.c
示例6: sensor_timer_stop
static void sensor_timer_stop(void)
{
uint32_t err_code = app_timer_stop(iss_struct.meas_timer);
APP_ERROR_CHECK(err_code);
iss_struct.timer_running = false;
}
开发者ID:EnergyFutures, 项目名称:ITU_BLE_Measurement_Service, 代码行数:6, 代码来源:motion_sensor.c
示例7: services_init
/**@brief Function for initializing services that will be used by the application.
*/
static void services_init(void)
{
uint32_t err_code = bluetooth_init();
APP_ERROR_CHECK(err_code);
}
开发者ID:dhavalengg06, 项目名称:Probe-Dongle-Firmware, 代码行数:7, 代码来源:main.c
示例8: on_ble_evt
/**@brief Function for handling the Application's BLE Stack events.
*
* @param[in] p_ble_evt Bluetooth stack event.
*/
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code = NRF_SUCCESS;
ble_gatts_rw_authorize_reply_params_t auth_reply;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
APP_ERROR_CHECK(err_code);
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
break;
case BLE_GAP_EVT_DISCONNECTED:
err_code = bsp_indication_set(BSP_INDICATE_IDLE);
APP_ERROR_CHECK(err_code);
advertising_start();
break;
case BLE_GAP_EVT_TIMEOUT:
if (p_ble_evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_ADVERTISING)
{
err_code = bsp_indication_set(BSP_INDICATE_IDLE);
APP_ERROR_CHECK(err_code);
// enable buttons to wake-up from power off
err_code = bsp_buttons_enable( (1 << WAKEUP_BUTTON_ID)
|(1 << BOND_DELETE_ALL_BUTTON_ID) );
APP_ERROR_CHECK(err_code);
// Go to system-off mode (this function will not return; wakeup will cause a reset).
err_code = sd_power_system_off();
APP_ERROR_CHECK(err_code);
}
break;
case BLE_GAP_EVT_PASSKEY_DISPLAY:
{
char passkey[PASSKEY_LENGTH+1];
memcpy(passkey,p_ble_evt->evt.gap_evt.params.passkey_display.passkey,PASSKEY_LENGTH);
passkey[PASSKEY_LENGTH] = 0;
// Don't send delayed Security Request if security procedure is already in progress.
err_code = app_timer_stop(m_sec_req_timer_id);
APP_ERROR_CHECK(err_code);
printf("Passkey: %s\n",passkey);
break;
}
case BLE_EVT_USER_MEM_REQUEST:
err_code = sd_ble_user_mem_reply(m_conn_handle, NULL);
APP_ERROR_CHECK(err_code);
break;
case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
if(p_ble_evt->evt.gatts_evt.params.authorize_request.type
!= BLE_GATTS_AUTHORIZE_TYPE_INVALID)
{
if ((p_ble_evt->evt.gatts_evt.params.authorize_request.request.write.op
== BLE_GATTS_OP_PREP_WRITE_REQ)
|| (p_ble_evt->evt.gatts_evt.params.authorize_request.request.write.op
== BLE_GATTS_OP_EXEC_WRITE_REQ_NOW)
|| (p_ble_evt->evt.gatts_evt.params.authorize_request.request.write.op
== BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL))
{
if (p_ble_evt->evt.gatts_evt.params.authorize_request.type
== BLE_GATTS_AUTHORIZE_TYPE_WRITE)
{
auth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE;
}
else
{
auth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_READ;
}
auth_reply.params.write.gatt_status = APP_FEATURE_NOT_SUPPORTED;
err_code = sd_ble_gatts_rw_authorize_reply(m_conn_handle,&auth_reply);
APP_ERROR_CHECK(err_code);
}
}
break;
case BLE_GAP_EVT_AUTH_STATUS:
case BLE_GAP_EVT_CONN_SEC_UPDATE:
break;
default:
// No implementation needed.
break;
}
}
开发者ID:dhruvkakadiya, 项目名称:OpenSJ_Bluz, 代码行数:96, 代码来源:main.c
示例9: main
/*
* Function for bootloader main entry.
*/
int main(void)
{
uint32_t err_code;
bool dfu_start = false;
bool app_reset = (NRF_POWER->GPREGRET == BOOTLOADER_DFU_START);
if (app_reset) {
NRF_POWER->GPREGRET = 0;
}
leds_init();
#if defined(DBGLOG_SUPPORT)
uart_init();
#endif
PUTS("\nBootloader *** " __DATE__ " " __TIME__ " ***");
// This check ensures that the defined fields in the bootloader
// corresponds with actual setting in the nRF51 chip.
APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
APP_ERROR_CHECK_BOOL(NRF_FICR->CODEPAGESIZE == CODE_PAGE_SIZE);
// Initialize.
timers_init();
#if defined(BUTTON_SUPPORT)
buttons_init();
#endif
(void)bootloader_init();
if (bootloader_dfu_sd_in_progress()) {
nrf_gpio_pin_clear(UPDATE_IN_PROGRESS_LED);
err_code = bootloader_dfu_sd_update_continue();
APP_ERROR_CHECK(err_code);
ble_stack_init(!app_reset);
scheduler_init();
err_code = bootloader_dfu_sd_update_finalize();
APP_ERROR_CHECK(err_code);
nrf_gpio_pin_set(UPDATE_IN_PROGRESS_LED);
}
else {
// If stack is present then continue initialization of bootloader.
ble_stack_init(!app_reset);
scheduler_init();
dis_init();
}
dfu_start = app_reset;
#if defined(BUTTON_SUPPORT)
dfu_start |= ((nrf_gpio_pin_read(BOOTLOADER_BUTTON) == 0) ? true: false);
#endif
if (dfu_start || (!bootloader_app_is_valid(DFU_BANK_0_REGION_START))) {
nrf_gpio_pin_clear(UPDATE_IN_PROGRESS_LED);
PUTS("Start DFU");
// Initiate an update of the firmware.
err_code = bootloader_dfu_start();
APP_ERROR_CHECK(err_code);
nrf_gpio_pin_set(UPDATE_IN_PROGRESS_LED);
}
if (bootloader_app_is_valid(DFU_BANK_0_REGION_START) && !bootloader_dfu_sd_in_progress()) {
PUTS("Start App");
// Select a bank region to use as application region.
// @note: Only applications running from DFU_BANK_0_REGION_START is supported.
bootloader_app_start(DFU_BANK_0_REGION_START);
}
NVIC_SystemReset();
}
开发者ID:foldedtoad, 项目名称:eddystone, 代码行数:86, 代码来源:main.c
示例10: ir_ppi_init
/** @brief Function for initializing PPI used in infrared signal decoding
* The PPI is needed to convert the timer event into a task.
*/
uint32_t ir_ppi_init(void)
{
uint32_t gpiote_event_addr;
uint32_t timer_task_addr;
nrf_ppi_channel_t ppi_channel;
ret_code_t err_code;
nrf_drv_gpiote_in_config_t config;
config.sense = NRF_GPIOTE_POLARITY_HITOLO;
config.pull = NRF_GPIO_PIN_PULLUP;
config.hi_accuracy = false;
config.is_watcher = false;
nrf_drv_timer_config_t timer_config;
timer_config.frequency = NRF_TIMER_FREQ_1MHz;
timer_config.mode = NRF_TIMER_MODE_TIMER;
timer_config.bit_width = NRF_TIMER_BIT_WIDTH_32;
timer_config.interrupt_priority = 3;
err_code = nrf_drv_timer_init(&ir_timer, &timer_config, timer_dummy_handler);
APP_ERROR_CHECK(err_code);
// Set up GPIOTE
err_code = nrf_drv_gpiote_in_init(IR_RECEIVER_PIN_1, &config, ir_in_pin_handler);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_gpiote_in_init(IR_RECEIVER_PIN_2, &config, ir_in_pin_handler);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_gpiote_in_init(IR_RECEIVER_PIN_3, &config, ir_in_pin_handler);
APP_ERROR_CHECK(err_code);
// Set up timer for capturing
nrf_drv_timer_capture_get(&ir_timer, NRF_TIMER_CC_CHANNEL0);
// Set up PPI channel
err_code = nrf_drv_ppi_channel_alloc(&ppi_channel);
APP_ERROR_CHECK(err_code);
timer_task_addr = nrf_drv_timer_capture_task_address_get(&ir_timer, NRF_TIMER_CC_CHANNEL0);
gpiote_event_addr = nrf_drv_gpiote_in_event_addr_get(IR_RECEIVER_PIN_1);
//err_code = nrf_drv_ppi_channel_assign(ppi_channel, gpiote_event_addr, timer_task_addr);
//APP_ERROR_CHECK(err_code);
//err_code = nrf_drv_ppi_channel_enable(ppi_channel);
//APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_event_enable(IR_RECEIVER_PIN_1, true);
nrf_drv_gpiote_in_event_enable(IR_RECEIVER_PIN_2, true);
nrf_drv_gpiote_in_event_enable(IR_RECEIVER_PIN_3, true);
// Enable timer
nrf_drv_timer_enable(&ir_timer);
return 0;
}
开发者ID:jtguggedal, 项目名称:Physical_Web_Toy_SDK_11, 代码行数:66, 代码来源:main.c
示例11: main
/** @brief Function for main application entry.
*/
int main(void)
{
TaskHandle_t compress_task_handle;
TimerHandle_t spi_timer_handle;
uint32_t err_code;
err_code = nrf_drv_clock_init();
APP_ERROR_CHECK(err_code);
// Setup bsp module.
//bsp_configuration();
//uart initialization
const app_uart_comm_params_t comm_params =
{
RX_PIN_NUMBER,
TX_PIN_NUMBER,
RTS_PIN_NUMBER,
CTS_PIN_NUMBER,
APP_UART_FLOW_CONTROL_ENABLED,
false,
UART_BAUDRATE_BAUDRATE_Baud38400
};
APP_UART_FIFO_INIT(&comm_params,
UART_RX_BUF_SIZE,
UART_TX_BUF_SIZE,
uart_error_handle,
APP_IRQ_PRIORITY_LOW,
err_code);
APP_ERROR_CHECK(err_code);
//nrf_drv_gpiote_out_config_t config = GPIOTE_CONFIG_OUT_TASK_HIGH;
//config.init_state = true;
//err_code = nrf_drv_gpiote_out_init(20, &config);
//while(app_uart_put(65) != NRF_SUCCESS);
//printf("1 ms = %d\n", pdMS_TO_TICKS(1));
intan_setup();
//while(app_uart_put(65) != NRF_SUCCESS);
compression_init();
uesb_config_t uesb_config = UESB_DEFAULT_CONFIG;
uesb_config.event_handler = uesb_event_handler;
if (uesb_init(&uesb_config)!= UESB_SUCCESS) {
printf("ESB init messed up\r\n");
}
tx_payload.length = UESB_CORE_MAX_PAYLOAD_LENGTH;
tx_payload.pipe = 0;
while(app_uart_put(66) != NRF_SUCCESS);
//printf("yo\n");
UNUSED_VARIABLE(xTaskCreate(compress_task, "c_task", configMINIMAL_STACK_SIZE + 200, NULL, 1, &compress_task_handle));
if(compress_task_handle == NULL)
{
printf("compression task init messed up\r\n");
}
while(app_uart_put(67) != NRF_SUCCESS);
//Test read intan company ID timer
//spi_timer_handle = xTimerCreate("s_timer", 1, pdTRUE, NULL, spi_intan_id_handler);
// Sample timer
spi_timer_handle = xTimerCreate("s_timer", 1, pdTRUE, NULL, spi_data_collection_evt_handler); // LED1 timer creation
if(spi_timer_handle == NULL)
{
printf("SPI timer init messed up\r\n");
}
while(app_uart_put(68) != NRF_SUCCESS);
if(xTimerStart(spi_timer_handle, 0) != pdPASS)
{
printf("Timer could not be started\r\n");
}
while(app_uart_put(69) != NRF_SUCCESS);
/* Activate deep sleep mode */
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
// Start FreeRTOS scheduler.
vTaskStartScheduler();
//timers_init();
//while(app_uart_put(67) != NRF_SUCCESS);
//data_collection_timers_start();
//while(app_uart_put(68) != NRF_SUCCESS);
for (;;)
{
printf("Messed up\r\n");
//.........这里部分代码省略.........
开发者ID:JulianYG, 项目名称:WNR, 代码行数:101, 代码来源:main.c
示例12: spi_write
static inline void spi_write(const void * data, size_t size)
{
APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, data, size, NULL, 0));
}
开发者ID:TanekLiang, 项目名称:rt-thread, 代码行数:4, 代码来源:ili9341.c
示例13: process_message_sending_command
/**@brief Processes an ANT messages while in the sending command state.
*
* @param[in] Pointer to the raw ant message received.
*/
static void process_message_sending_command(uint8_t* p_ant_message)
{
uint32_t err_code;
switch (p_ant_message[ANT_MESSAGE_ID_OFFSET])
{
case MESG_RESPONSE_EVENT_ID:
{
if(p_ant_message[ANT_MESSAGE_DATA0_OFFSET] == MESG_EVENT_ID) //Channel event
{
switch(p_ant_message[ANT_MESSAGE_DATA1_OFFSET])
{
case EVENT_TX:
{
//This event will be received if broadcast messages were used
//Automatically retry to increase the chances of a successful transmission
asc_encode_command_page(m_current_command_data, m_tx_buffer);
if(m_send_command_as_ack)
{
err_code = sd_ant_acknowledge_message_tx(m_channel_number, ANT_STANDARD_DATA_PAYLOAD_SIZE, m_tx_buffer);
}
else
{
err_code = sd_ant_broadcast_message_tx(m_channel_number, ANT_STANDARD_DATA_PAYLOAD_SIZE, m_tx_buffer);
}
APP_ERROR_CHECK(err_code);
if(++m_msg_counter_sending_command > m_retries)
{
m_is_command_pending = false;
ascm_set_state(m_previous_state);
}
break;
}
case EVENT_TRANSFER_TX_COMPLETED:
{
//The message was successfully received. No need to resend
m_is_command_pending = false;
ascm_set_state(m_previous_state);
break;
}
case EVENT_TRANSFER_TX_FAILED:
{
asc_encode_command_page(m_current_command_data, m_tx_buffer);
err_code = sd_ant_acknowledge_message_tx(m_channel_number, ANT_STANDARD_DATA_PAYLOAD_SIZE, m_tx_buffer);
APP_ERROR_CHECK(err_code);
//retry untitl success, or until too many retries have occured
if(++m_msg_counter_sending_command > m_retries)
{
m_is_command_pending = false;
ascm_set_state(m_previous_state);
}
break;
}
default:
{
break;
}
}
}
break;
}
case MESG_ACKNOWLEDGED_DATA_ID:
//fall-through
case MESG_BROADCAST_DATA_ID:
{
//Process by page
switch (p_ant_message[DECODE_PAGE_ID_BYTE])
{
case UPDATE_DATA_PID:
{
process_device_update(p_ant_message);
break;
}
default:
{
break;
}
}
break;
}
default:
{
break;
}
}
}
开发者ID:RobinLin, 项目名称:Espruino, 代码行数:94, 代码来源:asc_master.c
示例14: process_message_handshaking
/**@brief Processes an ANT messages while in the handshaking state.
*
* @param[in] Pointer to the raw ant message received.
*/
static void process_message_handshaking(uint8_t * p_ant_message)
{
uint32_t err_code;
switch (p_ant_message[ANT_MESSAGE_ID_OFFSET])
{
case MESG_RESPONSE_EVENT_ID:
{
if(p_ant_message[ANT_MESSAGE_DATA0_OFFSET] == MESG_EVENT_ID) //Channel event
{
switch(p_ant_message[ANT_MESSAGE_DATA1_OFFSET])
{
case EVENT_TX:
if(++m_msg_counter_handshaking > MAX_TX_MESSAGES_HANDSHAKING)
{
m_msg_counter_handshaking = 0;
//lint --e{534}
deviceregistry_remove_device(pm_device_registry, m_handshaking_device.shared_address);
ascm_set_state(ADDRESS_AVAILABLE);
}
break;
default:
break;
}
}
break;
}
case MESG_BROADCAST_DATA_ID:
//fall-through
case MESG_ACKNOWLEDGED_DATA_ID:
//Process by page
switch (p_ant_message[DECODE_PAGE_ID_BYTE])
{
case CONFIRM_ACQUIRE_PID:
{
asc_confirm_acquire_paramters_t params;
bool is_from_handshaking_device;
err_code = asc_decode_confirm_acquire_page(m_handshaking_device.serial_number,
&is_from_handshaking_device,
¶ms,
p_ant_message);
APP_ERROR_CHECK(err_code);
//Confirm that it is the correct device
if(is_from_handshaking_device)
{
m_handshaking_device.serial_number = params.serial_number;
m_handshaking_device.model_number = params.model_number;
m_handshaking_device.hw_revision = params.hw_revision;
m_handshaking_device.sw_revision = params.sw_revision;
//lint --e{534}
deviceregistry_add_device(pm_device_registry, &m_handshaking_device);
ascm_set_state(ADDRESS_AVAILABLE); //This ensures that after requesting the page we are returned back to Address Available
}
break;
}
default:
break;
}
break;
default:
break;
}
}
开发者ID:RobinLin, 项目名称:Espruino, 代码行数:68, 代码来源:asc_master.c
示例15: sensor_timer_init
static void sensor_timer_init(void)
{
uint32_t err_code;
err_code = app_timer_create(&iss_struct.meas_timer,APP_TIMER_MODE_SINGLE_SHOT,update_value_timer_handler);
APP_ERROR_CHECK(err_code);
}
开发者ID:EnergyFutures, 项目名称:ITU_BLE_Measurement_Service, 代码行数:6, 代码来源:motion_sensor.c
示例16: on_ble_evt
/**@brief Function for handling the Application's BLE Stack events.
*
* @param[in] p_ble_evt Bluetooth stack event.
*/
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code;
static ble_gap_evt_auth_status_t m_auth_status;
bool master_id_matches;
ble_gap_sec_kdist_t * p_distributed_keys;
ble_gap_enc_info_t * p_enc_info;
ble_gap_irk_t * p_id_info;
ble_gap_sign_info_t * p_sign_info;
static ble_gap_enc_key_t m_enc_key; /**< Encryption Key (Encryption Info and Master ID). */
static ble_gap_id_key_t m_id_key; /**< Identity Key (IRK and address). */
static ble_gap_sign_info_t m_sign_key; /**< Signing Key (Connection Signature Resolving Key). */
static ble_gap_sec_keyset_t m_keys = {.keys_periph = {&m_enc_key, &m_id_key, &m_sign_key}};
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
APP_ERROR_CHECK(err_code);
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
/* YOUR_JOB: Uncomment this part if you are using the app_button module to handle button
events (assuming that the button events are only needed in connected
state). If this is uncommented out here,
1. Make sure that app_button_disable() is called when handling
BLE_GAP_EVT_DISCONNECTED below.
2. Make sure the app_button module is initialized.
err_code = app_button_enable();
APP_ERROR_CHECK(err_code);
*/
break;
case BLE_GAP_EVT_DISCONNECTED:
m_conn_handle = BLE_CONN_HANDLE_INVALID;
/* YOUR_JOB: Uncomment this part if you are using the app_button module to handle button
events. This should be done to save power when not connected
to a peer.
err_code = app_button_disable();
APP_ERROR_CHECK(err_code);
*/
break;
case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
err_code = sd_ble_gap_sec_params_reply(m_conn_handle,
BLE_GAP_SEC_STATUS_SUCCESS,
&m_sec_params,
&m_keys);
APP_ERROR_CHECK(err_code);
break;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
err_code = sd_ble_gatts_sys_attr_set(m_conn_handle,
NULL,
0,
BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS | BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS);
APP_ERROR_CHECK(err_code);
break;
case BLE_GAP_EVT_AUTH_STATUS:
m_auth_status = p_ble_evt->evt.gap_evt.params.auth_status;
break;
case BLE_GAP_EVT_SEC_INFO_REQUEST:
master_id_matches = memcmp(&p_ble_evt->evt.gap_evt.params.sec_info_request.master_id,
&m_enc_key.master_id,
sizeof(ble_gap_master_id_t)) == 0;
p_distributed_keys = &m_auth_status.kdist_periph;
p_enc_info = (p_distributed_keys->enc && master_id_matches) ? &m_enc_key.enc_info : NULL;
p_id_info = (p_distributed_keys->id && master_id_matches) ? &m_id_key.id_info : NULL;
p_sign_info = (p_distributed_keys->sign && master_id_matches) ? &m_sign_key : NULL;
err_code = sd_ble_gap_sec_info_reply(m_conn_handle, p_enc_info, p_id_info, p_sign_info);
APP_ERROR_CHECK(err_code);
break;
default:
// No implementation needed.
break;
}
}
开发者ID:portwaypoint, 项目名称:pc-ble-driver, 代码行数:87, 代码来源:main.c
示例17: sensor_timer_start
static void sensor_timer_start(uint16_t offset)
{
uint32_t err_code = app_timer_start(iss_struct.meas_timer, APP_TIMER_TICKS(offset ? offset : iss_struct.samp_freq_in_m_sec, APP_TIMER_PRESCALER), &iss_struct);
APP_ERROR_CHECK(err_code);
iss_struct.timer_running = true;
}
开发者ID:EnergyFutures, 项目名称:ITU_BLE_Measurement_Service, 代码行数:6, 代码来源:motion_sensor.c
示例18: main
/**@brief Function for application main entry, does not return.
*/
int main(void)
{
uint32_t err_code;
// Setup UART.
#if defined(TRACE_UART)
const app_uart_comm_params_t comm_params =
{
RX_PIN_NUMBER,
TX_PIN_NUMBER,
RTS_PIN_NUMBER,
CTS_PIN_NUMBER,
APP_UART_FLOW_CONTROL_DISABLED,
false,
UART_BAUDRATE_BAUDRATE_Baud38400
};
APP_UART_FIFO_INIT(&comm_params,
UART_RX_BUF_SIZE,
UART_TX_BUF_SIZE,
uart_error_handle,
APP_IRQ_PRIORITY_LOW,
err_code);
APP_ERROR_CHECK(err_code);
#endif
err_code = sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_50_PPM, softdevice_assert_callback);
APP_ERROR_CHECK(err_code);
// Set application IRQ to lowest priority.
err_code = sd_nvic_SetPriority(PROTOCOL_EVENT_IRQn, NRF_APP_PRIORITY_LOW);
APP_ERROR_CHECK(err_code);
// Enable application IRQ (triggered from protocol).
err_code = sd_nvic_EnableIRQ(PROTOCOL_EVENT_IRQn);
APP_ERROR_CHECK(err_code);
// Open HRM RX channel.
hrm_rx_open();
uint8_t event;
uint8_t ant_channel;
uint8_t event_message_buffer[ANT_EVENT_MSG_BUFFER_MIN_SIZE];
printf("Enter hrm rx main processing loop...\n");
// Main loop.
for (;;)
{
err_code = sd_app_event_wait();
APP_ERROR_CHECK(err_code);
// Extract and process all pending ANT events.
do
{
err_code = sd_ant_event_get(&ant_channel, &event, event_message_buffer);
if (err_code == NRF_SUCCESS)
{
if (event == EVENT_RX)
{
// We are only interested of RX events.
hrm_rx_channel_event_handle(event_message_buffer);
}
}
}
while (err_code == NRF_SUCCESS);
}
}
开发者ID:jiang175, 项目名称:freeze-network, 代码行数:70, 代码来源:main_hrm_rx.c
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:19126| 2023-10-27
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:9971| 2022-11-06
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8317| 2022-11-06
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8686| 2022-11-06
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8626| 2022-11-06
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9643| 2022-11-06
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8611| 2022-11-06
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:7991| 2022-11-06
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8640| 2022-11-06
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7527| 2022-11-06
请发表评论