本文整理匯總了C++中APP_ERROR_CHECK函數的典型用法代碼示例。如果您正苦於以下問題:C++ APP_ERROR_CHECK函數的具體用法?C++ APP_ERROR_CHECK怎麽用?C++ APP_ERROR_CHECK使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了APP_ERROR_CHECK函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
}
示例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);
}
示例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)
//.........這裏部分代碼省略.........
示例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;
}
}
示例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;
}
}
示例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;
}
示例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);
}
示例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;
}
}
示例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();
}
示例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;
}
示例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");
//.........這裏部分代碼省略.........
示例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));
}
示例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;
}
}
}
示例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;
}
}
示例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);
}