├── BaiduWristbandTester-v1.apk ├── LICENSE ├── README.md ├── Wearable.apk ├── bootloader ├── Source │ ├── inc │ │ ├── bootloader.h │ │ ├── bootloader_types.h │ │ ├── bootloader_util.h │ │ ├── dfu.h │ │ ├── dfu_transport.h │ │ └── dfu_types.h │ └── src │ │ ├── arm_startup_nrf51.s │ │ ├── bootloader.c │ │ ├── bootloader_util_arm.c │ │ ├── dfu_dual_bank.c │ │ ├── dfu_single_bank.c │ │ ├── dfu_transport_ble.c │ │ ├── dfu_transport_serial.c │ │ ├── hci_transport_config.h │ │ └── main.c ├── nrf51822 │ ├── Include │ │ ├── app_common │ │ │ ├── app_button.h │ │ │ ├── app_error.h │ │ │ ├── app_fifo.h │ │ │ ├── app_gpiote.h │ │ │ ├── app_scheduler.h │ │ │ ├── app_timer.h │ │ │ ├── app_uart.h │ │ │ ├── app_util.h │ │ │ ├── crc16.h │ │ │ ├── hci_mem_pool.h │ │ │ ├── hci_mem_pool_internal.h │ │ │ ├── hci_slip.h │ │ │ └── hci_transport.h │ │ ├── ble │ │ │ ├── ble_advdata.h │ │ │ ├── ble_bondmngr.h │ │ │ ├── ble_conn_params.h │ │ │ ├── ble_date_time.h │ │ │ ├── ble_debug_assert_handler.h │ │ │ ├── ble_dtm.h │ │ │ ├── ble_error_log.h │ │ │ ├── ble_eval_board_pins.h │ │ │ ├── ble_flash.h │ │ │ ├── ble_nrf6310_pins.h │ │ │ ├── ble_racp.h │ │ │ ├── ble_radio_notification.h │ │ │ ├── ble_sensorsim.h │ │ │ ├── ble_services │ │ │ │ ├── ble_ans_c.h │ │ │ │ ├── ble_bas.h │ │ │ │ ├── ble_bps.h │ │ │ │ ├── ble_cscs.h │ │ │ │ ├── ble_dfu.h │ │ │ │ ├── ble_dis.h │ │ │ │ ├── ble_gls.h │ │ │ │ ├── ble_gls_db.h │ │ │ │ ├── ble_hids.h │ │ │ │ ├── ble_hrs.h │ │ │ │ ├── ble_hts.h │ │ │ │ ├── ble_ias.h │ │ │ │ ├── ble_ias_c.h │ │ │ │ ├── ble_lls.h │ │ │ │ ├── ble_rscs.h │ │ │ │ ├── ble_sc_ctrlpt.h │ │ │ │ ├── ble_sensor_location.h │ │ │ │ ├── ble_srv_common.h │ │ │ │ └── ble_tps.h │ │ │ ├── ble_stack_handler.h │ │ │ ├── rpc │ │ │ │ ├── ble_rpc_cmd_decoder.h │ │ │ │ ├── ble_rpc_cmd_decoder_gap.h │ │ │ │ ├── ble_rpc_cmd_decoder_gatts.h │ │ │ │ ├── ble_rpc_cmd_encoder.h │ │ │ │ ├── ble_rpc_defines.h │ │ │ │ ├── ble_rpc_event_decoder.h │ │ │ │ ├── ble_rpc_event_decoder_gap.h │ │ │ │ ├── ble_rpc_event_decoder_gatts.h │ │ │ │ ├── ble_rpc_event_encoder.h │ │ │ │ ├── ble_rpc_event_encoder_gap.h │ │ │ │ ├── ble_rpc_event_encoder_gatts.h │ │ │ │ └── ble_rpc_pkt_receiver.h │ │ │ └── softdevice │ │ │ │ ├── ble.h │ │ │ │ ├── ble_err.h │ │ │ │ ├── ble_gap.h │ │ │ │ ├── ble_gatt.h │ │ │ │ ├── ble_gattc.h │ │ │ │ ├── ble_gatts.h │ │ │ │ ├── ble_hci.h │ │ │ │ ├── ble_l2cap.h │ │ │ │ ├── ble_ranges.h │ │ │ │ ├── ble_types.h │ │ │ │ ├── nrf_error.h │ │ │ │ ├── nrf_error_sdm.h │ │ │ │ ├── nrf_error_soc.h │ │ │ │ ├── nrf_sdm.h │ │ │ │ ├── nrf_soc.h │ │ │ │ ├── nrf_svc.h │ │ │ │ └── softdevice_assert.h │ │ ├── boards.h │ │ ├── boards │ │ │ ├── WT1000.h │ │ │ └── nrf6310.h │ │ ├── common.h │ │ ├── compiler_abstraction.h │ │ ├── console.h │ │ ├── esb │ │ │ ├── nrf_esb.h │ │ │ └── nrf_esb_constants.h │ │ ├── ext_sensors │ │ │ ├── adns2080.h │ │ │ ├── cherry8x16.h │ │ │ ├── ds1624.h │ │ │ ├── mpu6050.h │ │ │ ├── nRF6350.h │ │ │ ├── sdio.h │ │ │ └── synaptics_touchpad.h │ │ ├── gcc │ │ │ ├── core_cm0.h │ │ │ ├── core_cmFunc.h │ │ │ └── core_cmInstr.h │ │ ├── gzll │ │ │ ├── nrf_gzll.h │ │ │ └── nrf_gzll_constants.h │ │ ├── gzp │ │ │ └── nrf_gzp.h │ │ ├── nordic_common.h │ │ ├── nrf.h │ │ ├── nrf51.h │ │ ├── nrf51_bitfields.h │ │ ├── nrf51_deprecated.h │ │ ├── nrf_assert.h │ │ ├── nrf_delay.h │ │ ├── nrf_ecb.h │ │ ├── nrf_gpio.h │ │ ├── nrf_gpiote.h │ │ ├── nrf_nvmc.h │ │ ├── nrf_temp.h │ │ ├── simple_uart.h │ │ ├── spi_master.h │ │ ├── system_nrf51.h │ │ └── twi_master.h │ └── Source │ │ ├── app_common │ │ ├── app_button.c │ │ ├── app_fifo.c │ │ ├── app_gpiote.c │ │ ├── app_scheduler.c │ │ ├── app_timer.c │ │ ├── app_uart.c │ │ ├── app_uart_fifo.c │ │ ├── crc16.c │ │ ├── hci_mem_pool.c │ │ ├── hci_slip.c │ │ └── hci_transport.c │ │ ├── ble │ │ ├── ble_advdata.c │ │ ├── ble_bondmngr.c │ │ ├── ble_conn_params.c │ │ ├── ble_debug_assert_handler.c │ │ ├── ble_dtm.c │ │ ├── ble_error_log.c │ │ ├── ble_flash.c │ │ ├── ble_racp.c │ │ ├── ble_radio_notification.c │ │ ├── ble_sensorsim.c │ │ ├── ble_services │ │ │ ├── ble_ans_c.c │ │ │ ├── ble_bas.c │ │ │ ├── ble_bps.c │ │ │ ├── ble_cscs.c │ │ │ ├── ble_dfu.c │ │ │ ├── ble_dis.c │ │ │ ├── ble_gls.c │ │ │ ├── ble_gls_db.c │ │ │ ├── ble_hids.c │ │ │ ├── ble_hrs.c │ │ │ ├── ble_hts.c │ │ │ ├── ble_ias.c │ │ │ ├── ble_ias_c.c │ │ │ ├── ble_lls.c │ │ │ ├── ble_rscs.c │ │ │ ├── ble_sc_ctrlpt.c │ │ │ ├── ble_srv_common.c │ │ │ └── ble_tps.c │ │ ├── ble_stack_handler.c │ │ └── rpc │ │ │ ├── ble_rpc_cmd_decoder.c │ │ │ ├── ble_rpc_cmd_decoder_gap.c │ │ │ ├── ble_rpc_cmd_decoder_gatts.c │ │ │ ├── ble_rpc_cmd_encoder.c │ │ │ ├── ble_rpc_cmd_encoder_gap.c │ │ │ ├── ble_rpc_cmd_encoder_gatts.c │ │ │ ├── ble_rpc_event_decoder.c │ │ │ ├── ble_rpc_event_decoder_gap.c │ │ │ ├── ble_rpc_event_decoder_gatts.c │ │ │ ├── ble_rpc_event_encoder.c │ │ │ ├── ble_rpc_event_encoder_gap.c │ │ │ ├── ble_rpc_event_encoder_gatts.c │ │ │ ├── ble_rpc_pkt_receiver.c │ │ │ └── ble_rpc_sd_stub.c │ │ ├── console │ │ └── console.c │ │ ├── ext_sensors │ │ ├── adns2080 │ │ │ └── adns2080.c │ │ ├── cherry8x16 │ │ │ └── cherry8x16.c │ │ ├── ds1624 │ │ │ └── ds1624.c │ │ ├── mpu6050 │ │ │ └── mpu6050.c │ │ ├── nRF6350 │ │ │ └── nRF6350.c │ │ ├── sdio │ │ │ └── sdio.c │ │ └── synaptics_touchpad │ │ │ └── synaptics_touchpad.c │ │ ├── gzp │ │ ├── nrf_gzp.c │ │ ├── nrf_gzp_device.c │ │ ├── nrf_gzp_host.c │ │ └── nrf_gzp_host_nrf51.c │ │ ├── keil_arm_uv4.lnt │ │ ├── nrf_assert │ │ └── nrf_assert.c │ │ ├── nrf_delay │ │ └── nrf_delay.c │ │ ├── nrf_ecb │ │ └── nrf_ecb.c │ │ ├── nrf_nvmc │ │ └── nrf_nvmc.c │ │ ├── simple_uart │ │ └── simple_uart.c │ │ ├── spi_master │ │ └── spi_master.c │ │ ├── templates │ │ ├── arm │ │ │ ├── arm_startup_nrf51.s │ │ │ └── uicr_config.h │ │ ├── gcc │ │ │ ├── Makefile.common │ │ │ ├── Makefile.windows │ │ │ ├── gcc_nrf51_blank_xxaa.ld │ │ │ ├── gcc_nrf51_blank_xxab.ld │ │ │ ├── gcc_nrf51_common.ld │ │ │ ├── gcc_nrf51_s110_xxaa.ld │ │ │ ├── gcc_nrf51_s110_xxab.ld │ │ │ ├── gcc_nrf51_s210_xxaa.ld │ │ │ └── gcc_startup_nrf51.s │ │ ├── iar │ │ │ └── iar_startup_nrf51.s │ │ └── system_nrf51.c │ │ └── twi_master │ │ ├── twi_hw_master.c │ │ └── twi_sw_master.c └── project │ ├── Baidu-Nordic-OTA.uvopt │ ├── Baidu-Nordic-OTA.uvproj │ └── JLinkSettings.ini ├── doc ├── nRF51822_Developer_Kit_User_Guide v1.2.pdf └── 手环硬件资料 │ └── 手环硬件资料 │ ├── SCH_PCB.pdf │ ├── 参考设计BOM.xls │ ├── 手环版图源文件V6.DDB │ └── 芯片手册 │ ├── AS1130_Datasheet_EN_v5.pdf │ ├── BAL-NR_datasheet.pdf │ ├── LIS3DH.pdf │ ├── S8211C_C.pdf │ ├── bq24040.pdf │ ├── drv2605.pdf │ ├── nRF51 Series Reference manual v2.0.pdf │ ├── nRF51822 PS v1 3.pdf │ ├── tps3898.pdf │ └── tps62260.pdf └── wrist-rom-open ├── Source ├── algorithm_inc │ ├── click-algorithm.h │ └── health-algorithm.h ├── inc │ ├── bd_battery.h │ ├── bd_ble_nus.h │ ├── bd_bluetooth_log.h │ ├── bd_buzzer.h │ ├── bd_charging.h │ ├── bd_communicate_protocol.h │ ├── bd_crc16.h │ ├── bd_data_manager.h │ ├── bd_factory_test.h │ ├── bd_input_event_source.h │ ├── bd_interaction.h │ ├── bd_interrupt_notify.h │ ├── bd_led_flash.h │ ├── bd_level_drive_motor.h │ ├── bd_lis3dh_driver.h │ ├── bd_low_power_mode.h │ ├── bd_private_bond.h │ ├── bd_spi_master.h │ ├── bd_square_root.h │ ├── bd_stack_dump_repoter.h │ ├── bd_switch_sleep.h │ ├── bd_sync_data.h │ ├── bd_wall_clock_timer.h │ ├── bd_wdt.h │ ├── bd_work_state.h │ ├── ble_bondmngr_cfg.h │ ├── board_config_pins.h │ ├── config.h │ ├── drv2605.h │ ├── dvk6310_board_config_pins.h │ ├── hal_acc.h │ ├── hal_vibrate.h │ ├── spi_master_config.h │ ├── step_counter.h │ └── wx1000_board_config_pins.h ├── libs │ └── AlgorithmLibFornrf51.lib └── src │ ├── bd_battery.c │ ├── bd_ble_nus.c │ ├── bd_bluetooth_log.c │ ├── bd_buzzer.c │ ├── bd_charging.c │ ├── bd_communicate_protocol.c │ ├── bd_crc16.c │ ├── bd_data_manager.c │ ├── bd_drv2605.c │ ├── bd_factory_test.c │ ├── bd_hal_acc.c │ ├── bd_hal_vibrate.c │ ├── bd_input_event_source.c │ ├── bd_interaction.c │ ├── bd_interrupt_notify.c │ ├── bd_led_flash.c │ ├── bd_level_drive_motor.c │ ├── bd_lis3dh_driver.c │ ├── bd_low_power_mode.c │ ├── bd_nrf_delay.c │ ├── bd_private_bond.c │ ├── bd_spi_master.c │ ├── bd_square_root.c │ ├── bd_stack_dump_repoter.c │ ├── bd_step_counter.c │ ├── bd_switch_sleep.c │ ├── bd_sync_data.c │ ├── bd_twi_hw_master.c │ ├── bd_wall_clock_timer.c │ ├── bd_wdt.c │ └── main.c ├── nrf51822 ├── Include │ ├── app_common │ │ ├── app_button.h │ │ ├── app_error.h │ │ ├── app_fifo.h │ │ ├── app_gpiote.h │ │ ├── app_scheduler.h │ │ ├── app_timer.h │ │ ├── app_uart.h │ │ ├── app_util.h │ │ ├── crc16.h │ │ ├── hci_mem_pool.h │ │ ├── hci_mem_pool_internal.h │ │ ├── hci_slip.h │ │ └── hci_transport.h │ ├── ble │ │ ├── ble_advdata.h │ │ ├── ble_bondmngr.h │ │ ├── ble_conn_params.h │ │ ├── ble_date_time.h │ │ ├── ble_debug_assert_handler.h │ │ ├── ble_dtm.h │ │ ├── ble_error_log.h │ │ ├── ble_eval_board_pins.h │ │ ├── ble_flash.h │ │ ├── ble_racp.h │ │ ├── ble_radio_notification.h │ │ ├── ble_sensorsim.h │ │ ├── ble_services │ │ │ ├── ble_ans_c.h │ │ │ ├── ble_bas.h │ │ │ ├── ble_bps.h │ │ │ ├── ble_cscs.h │ │ │ ├── ble_dfu.h │ │ │ ├── ble_dis.h │ │ │ ├── ble_gls.h │ │ │ ├── ble_gls_db.h │ │ │ ├── ble_hids.h │ │ │ ├── ble_hrs.h │ │ │ ├── ble_hts.h │ │ │ ├── ble_ias.h │ │ │ ├── ble_ias_c.h │ │ │ ├── ble_lls.h │ │ │ ├── ble_rscs.h │ │ │ ├── ble_sc_ctrlpt.h │ │ │ ├── ble_sensor_location.h │ │ │ ├── ble_srv_common.h │ │ │ └── ble_tps.h │ │ ├── ble_stack_handler.h │ │ ├── rpc │ │ │ ├── ble_rpc_cmd_decoder.h │ │ │ ├── ble_rpc_cmd_decoder_gap.h │ │ │ ├── ble_rpc_cmd_decoder_gatts.h │ │ │ ├── ble_rpc_cmd_encoder.h │ │ │ ├── ble_rpc_defines.h │ │ │ ├── ble_rpc_event_decoder.h │ │ │ ├── ble_rpc_event_decoder_gap.h │ │ │ ├── ble_rpc_event_decoder_gatts.h │ │ │ ├── ble_rpc_event_encoder.h │ │ │ ├── ble_rpc_event_encoder_gap.h │ │ │ ├── ble_rpc_event_encoder_gatts.h │ │ │ └── ble_rpc_pkt_receiver.h │ │ └── softdevice │ │ │ ├── ble.h │ │ │ ├── ble_err.h │ │ │ ├── ble_gap.h │ │ │ ├── ble_gatt.h │ │ │ ├── ble_gattc.h │ │ │ ├── ble_gatts.h │ │ │ ├── ble_hci.h │ │ │ ├── ble_l2cap.h │ │ │ ├── ble_ranges.h │ │ │ ├── ble_types.h │ │ │ ├── nrf_error.h │ │ │ ├── nrf_error_sdm.h │ │ │ ├── nrf_error_soc.h │ │ │ ├── nrf_sdm.h │ │ │ ├── nrf_soc.h │ │ │ ├── nrf_svc.h │ │ │ └── softdevice_assert.h │ ├── boards.h │ ├── common.h │ ├── compiler_abstraction.h │ ├── console.h │ ├── esb │ │ ├── nrf_esb.h │ │ └── nrf_esb_constants.h │ ├── ext_sensors │ │ ├── adns2080.h │ │ ├── cherry8x16.h │ │ ├── ds1624.h │ │ ├── mpu6050.h │ │ ├── nRF6350.h │ │ ├── sdio.h │ │ └── synaptics_touchpad.h │ ├── gzll │ │ ├── nrf_gzll.h │ │ └── nrf_gzll_constants.h │ ├── gzp │ │ └── nrf_gzp.h │ ├── nordic_common.h │ ├── nrf.h │ ├── nrf51.h │ ├── nrf51_bitfields.h │ ├── nrf51_deprecated.h │ ├── nrf_assert.h │ ├── nrf_delay.h │ ├── nrf_ecb.h │ ├── nrf_gpio.h │ ├── nrf_gpiote.h │ ├── nrf_nvmc.h │ ├── nrf_temp.h │ ├── simple_uart.h │ ├── spi_master.h │ ├── system_nrf51.h │ └── twi_master.h ├── Lib │ ├── esb │ │ └── arm │ │ │ └── esb_arm.lib │ └── gzll │ │ └── arm │ │ └── gzll_arm.lib ├── SVD │ └── nrf51.xml └── Source │ ├── app_common │ ├── app_button.c │ ├── app_fifo.c │ ├── app_gpiote.c │ ├── app_scheduler.c │ ├── app_timer.c │ ├── app_uart.c │ ├── app_uart_fifo.c │ ├── crc16.c │ ├── hci_mem_pool.c │ ├── hci_slip.c │ └── hci_transport.c │ ├── ble │ ├── ble_advdata.c │ ├── ble_bondmngr.c │ ├── ble_conn_params.c │ ├── ble_debug_assert_handler.c │ ├── ble_dtm.c │ ├── ble_error_log.c │ ├── ble_flash.c │ ├── ble_racp.c │ ├── ble_radio_notification.c │ ├── ble_sensorsim.c │ ├── ble_services │ │ ├── ble_ans_c.c │ │ ├── ble_bas.c │ │ ├── ble_bps.c │ │ ├── ble_cscs.c │ │ ├── ble_dfu.c │ │ ├── ble_dis.c │ │ ├── ble_gls.c │ │ ├── ble_gls_db.c │ │ ├── ble_hids.c │ │ ├── ble_hrs.c │ │ ├── ble_hts.c │ │ ├── ble_ias.c │ │ ├── ble_ias_c.c │ │ ├── ble_lls.c │ │ ├── ble_rscs.c │ │ ├── ble_sc_ctrlpt.c │ │ ├── ble_srv_common.c │ │ └── ble_tps.c │ ├── ble_stack_handler.c │ └── rpc │ │ ├── ble_rpc_cmd_decoder.c │ │ ├── ble_rpc_cmd_decoder_gap.c │ │ ├── ble_rpc_cmd_decoder_gatts.c │ │ ├── ble_rpc_cmd_encoder.c │ │ ├── ble_rpc_cmd_encoder_gap.c │ │ ├── ble_rpc_cmd_encoder_gatts.c │ │ ├── ble_rpc_event_decoder.c │ │ ├── ble_rpc_event_decoder_gap.c │ │ ├── ble_rpc_event_decoder_gatts.c │ │ ├── ble_rpc_event_encoder.c │ │ ├── ble_rpc_event_encoder_gap.c │ │ ├── ble_rpc_event_encoder_gatts.c │ │ ├── ble_rpc_pkt_receiver.c │ │ └── ble_rpc_sd_stub.c │ ├── console │ └── console.c │ ├── ext_sensors │ ├── adns2080 │ │ └── adns2080.c │ ├── cherry8x16 │ │ └── cherry8x16.c │ ├── ds1624 │ │ └── ds1624.c │ ├── mpu6050 │ │ └── mpu6050.c │ ├── nRF6350 │ │ └── nRF6350.c │ ├── sdio │ │ └── sdio.c │ └── synaptics_touchpad │ │ └── synaptics_touchpad.c │ ├── gzp │ ├── nrf_gzp.c │ ├── nrf_gzp_device.c │ ├── nrf_gzp_host.c │ └── nrf_gzp_host_nrf51.c │ ├── keil_arm_uv4.lnt │ ├── nrf_assert │ └── nrf_assert.c │ ├── nrf_delay │ └── nrf_delay.c │ ├── nrf_ecb │ └── nrf_ecb.c │ ├── nrf_nvmc │ └── nrf_nvmc.c │ ├── simple_uart │ └── simple_uart.c │ ├── spi_master │ └── spi_master.c │ ├── templates │ ├── arm │ │ ├── arm_startup_nrf51.s │ │ └── uicr_config.h │ └── system_nrf51.c │ └── twi_master │ ├── twi_hw_master.c │ └── twi_sw_master.c └── project ├── Baidu-Nordic.uvopt ├── Baidu-Nordic.uvproj └── JLinkSettings.ini /BaiduWristbandTester-v1.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/BaiduWristbandTester-v1.apk -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | duband 2 | ====== 3 | duband1.0 4 | 5 | 对应的公版版本为 duband1.0 6 | 7 | 官方网站:http://dulife.baidu.com/ 8 | 9 | 联系方式:device-dev@baidu.com 10 | 11 | 手把手教你做手环的教程链接:http://yuedu.baidu.com/ebook/6015724f0b4e767f5acfceb7.html 12 | -------------------------------------------------------------------------------- /Wearable.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/Wearable.apk -------------------------------------------------------------------------------- /bootloader/Source/inc/bootloader.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /**@file 14 | * 15 | * @defgroup nrf_bootloader Bootloader API. 16 | * @{ 17 | * 18 | * @brief Bootloader module interface. 19 | */ 20 | 21 | #ifndef BOOTLOADER_H__ 22 | #define BOOTLOADER_H__ 23 | 24 | #include 25 | #include 26 | #include "bootloader_types.h" 27 | #include "dfu_types.h" 28 | 29 | /**@brief Function for validating application region. 30 | * 31 | * @param[in] app_addr Address to the region where the application is stored. 32 | * 33 | * @retval true If Application region is valid. 34 | * @retval false If Application region is not valid. 35 | */ 36 | bool bootloader_app_is_valid(uint32_t app_addr); 37 | 38 | /**@brief Function for starting the Device Firmware Update. 39 | * 40 | * @retval NRF_SUCCESS If new appliction image was successfully transfered. 41 | */ 42 | uint32_t bootloader_dfu_start(void); 43 | 44 | /**@brief Function for 45 | * 46 | * @param[in] app_addr Address to the region where the application is stored. 47 | */ 48 | void bootloader_app_start(uint32_t app_addr); 49 | 50 | /**@brief Function for retrieving the bootloader settings. 51 | * 52 | * @param[out] p_settings A copy of the current bootloader settings is returned in the structure 53 | * provided. 54 | */ 55 | void bootloader_settings_get(bootloader_settings_t * const p_settings); 56 | 57 | /**@brief Function for processing DFU status update. 58 | * 59 | * @param[in] update_status DFU update status. 60 | */ 61 | void bootloader_dfu_update_process(dfu_update_status_t update_status); 62 | 63 | #endif // BOOTLOADER_H__ 64 | 65 | /**@} */ 66 | -------------------------------------------------------------------------------- /bootloader/Source/inc/bootloader_types.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /**@file 14 | * 15 | * @defgroup nrf_bootloader_types Types and definitions. 16 | * @{ 17 | * 18 | * @ingroup nrf_bootloader 19 | * 20 | * @brief Bootloader module type and definitions. 21 | */ 22 | 23 | #ifndef BOOTLOADER_TYPES_H__ 24 | #define BOOTLOADER_TYPES_H__ 25 | 26 | #include 27 | 28 | /**@brief DFU Bank state code, which indicates wether the bank contains: A valid image, invalid image, or an erased flash. 29 | */ 30 | typedef enum 31 | { 32 | BANK_VALID_APP = 0x01, 33 | BANK_ERASED = 0xFE, 34 | BANK_INVALID_APP = 0xFF, 35 | } bootloader_bank_code_t; 36 | 37 | /**@brief Structure holding bootloader settings for application and bank data. 38 | */ 39 | typedef struct 40 | { 41 | bootloader_bank_code_t bank_0; /**< Variable to store if bank 0 contains a valid application. */ 42 | uint16_t bank_0_crc; /**< If bank is valid, this field will contain a valid CRC of the image. */ 43 | bootloader_bank_code_t bank_1; /**< Variable to store if bank 1 has been erased/prepared for new image. Bank 1 is only used in Banked Update scenario. */ 44 | uint32_t bank_0_size; /**< Size of bank0. */ 45 | } bootloader_settings_t; 46 | 47 | #endif // BOOTLOADER_TYPES_H__ 48 | 49 | /**@} */ 50 | -------------------------------------------------------------------------------- /bootloader/Source/inc/bootloader_util.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /**@file 14 | * 15 | * @defgroup nrf_bootloader_util Bootloader util API. 16 | * @{ 17 | * 18 | * @brief Bootloader util module interface. 19 | */ 20 | 21 | #ifndef BOOTLOADER_UTIL_H__ 22 | #define BOOTLOADER_UTIL_H__ 23 | 24 | #include 25 | #include "bootloader_types.h" 26 | #include "dfu_types.h" 27 | 28 | /**@brief Function for starting the application. 29 | * 30 | * @param[in] start_addr Start address. 31 | */ 32 | void bootloader_util_app_start(uint32_t start_addr); 33 | 34 | /**@brief Function for getting the bootloader settings. 35 | * 36 | * @param[out] pp_bootloader_settings Bootloader settings. 37 | */ 38 | void bootloader_util_settings_get(const bootloader_settings_t ** pp_bootloader_settings); 39 | 40 | #endif // BOOTLOADER_UTIL_H__ 41 | 42 | /**@} */ 43 | -------------------------------------------------------------------------------- /bootloader/Source/inc/dfu.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /**@file 14 | * 15 | * @defgroup nrf_dfu Device Firmware Update API. 16 | * @{ 17 | * 18 | * @brief Device Firmware Update module interface. 19 | */ 20 | 21 | #ifndef DFU_H__ 22 | #define DFU_H__ 23 | 24 | #include "dfu_types.h" 25 | #include 26 | #include 27 | 28 | /**@brief Function for initializing the Device Firmware Update module. 29 | * 30 | * @return NRF_SUCCESS on success, an error_code otherwise. 31 | */ 32 | uint32_t dfu_init(void); 33 | 34 | /**@brief Function for setting the DFU image size. 35 | * 36 | * @details Function sets the DFU image size. This function must be called when an update is started 37 | * in order to notify the DFU of the new image size. 38 | * 39 | * @param[in] image_size Size of the image to be transmitted. 40 | * 41 | * @return NRF_SUCCESS on success, an error_code otherwise. 42 | */ 43 | uint32_t dfu_image_size_set(uint32_t image_size); 44 | 45 | /**@brief Function for handling DFU data packets. 46 | * 47 | * @param[in] p_packet Pointer to the DFU packet. 48 | * 49 | * @return NRF_SUCCESS on success, an error_code otherwise. 50 | */ 51 | uint32_t dfu_data_pkt_handle(dfu_update_packet_t * p_packet); 52 | 53 | /**@brief Function for handling DFU init packets. 54 | * 55 | * @return NRF_SUCCESS on success, an error_code otherwise. 56 | */ 57 | uint32_t dfu_init_pkt_handle(dfu_update_packet_t * p_packet); 58 | 59 | /**@brief Function for validating a transferred image after the transfer has completed. 60 | * 61 | * @return NRF_SUCCESS on success, an error_code otherwise. 62 | */ 63 | uint32_t dfu_image_validate(void); 64 | 65 | /**@brief Function for activating the transfered image after validation has successfully completed. 66 | * 67 | * @return NRF_SUCCESS on success, an error_code otherwise. 68 | */ 69 | uint32_t dfu_image_activate(void); 70 | 71 | #endif // DFU_H__ 72 | 73 | /** @} */ 74 | -------------------------------------------------------------------------------- /bootloader/Source/inc/dfu_transport.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /**@file 14 | * 15 | * @defgroup nrf_dfu_transport DFU transport API. 16 | * @{ 17 | * 18 | * @brief DFU transport module interface. 19 | */ 20 | 21 | #ifndef DFU_TRANSPORT_H__ 22 | #define DFU_TRANSPORT_H__ 23 | 24 | #include 25 | 26 | /**@brief Function for starting the update of Device Firmware. 27 | * 28 | * @retval NRF_SUCCESS Operation success. 29 | */ 30 | uint32_t dfu_transport_update_start(void); 31 | 32 | /**@brief Function for closing the transport layer. 33 | * 34 | * @retval NRF_SUCCESS Operation success. 35 | */ 36 | uint32_t dfu_transport_close(void); 37 | 38 | #endif // DFU_TRANSPORT_H__ 39 | 40 | /**@} */ 41 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/app_common/crc16.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup crc_compute CRC compute 16 | * @{ 17 | * @ingroup hci_transport 18 | * 19 | * @brief This module implements the CRC-16 calculation in the blocks. 20 | */ 21 | 22 | #ifndef CRC16_H__ 23 | #define CRC16_H__ 24 | 25 | #include 26 | 27 | /**@brief Function for calculating CRC-16 in blocks. 28 | * 29 | * Feed each consecutive data block into this function, along with the current value of p_crc as 30 | * returned by the previous call of this function. The first call of this function should pass NULL 31 | * as the initial value of the crc in p_crc. 32 | * 33 | * @param[in] p_data The input data block for computation. 34 | * @param[in] size The size of the input data block in bytes. 35 | * @param[in] p_crc The previous calculated CRC-16 value or NULL if first call. 36 | * 37 | * @return The updated CRC-16 value, based on the input supplied. 38 | */ 39 | uint16_t crc16_compute(const uint8_t * p_data, uint32_t size, const uint16_t * p_crc); 40 | 41 | #endif // CRC16_H__ 42 | 43 | /** @} */ 44 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/app_common/hci_mem_pool_internal.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup memory_pool_internal Memory Pool Internal 16 | * @{ 17 | * @ingroup memory_pool 18 | * 19 | * @brief Memory pool internal definitions 20 | */ 21 | 22 | #ifndef MEM_POOL_INTERNAL_H__ 23 | #define MEM_POOL_INTERNAL_H__ 24 | 25 | #define TX_BUF_SIZE 600u /**< TX buffer size in bytes. */ 26 | #define RX_BUF_SIZE TX_BUF_SIZE /**< RX buffer size in bytes. */ 27 | 28 | #endif // MEM_POOL_INTERNAL_H__ 29 | 30 | /** @} */ 31 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/ble_date_time.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/bootloader/nrf51822/Include/ble/ble_date_time.h -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/ble_debug_assert_handler.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_debug_assert_handler Assert Handler for debug purposes. 16 | * @{ 17 | * @ingroup ble_sdk_lib 18 | * @brief Module for handling of assert during application development when debugging. 19 | * 20 | * @details This module may be used during development of an application to facilitate debugging. 21 | * It contains a function to write file name, line number and the Stack Memory to flash. 22 | * This module is ONLY for debugging purposes and must never be used in final product. 23 | * 24 | */ 25 | 26 | #ifndef BLE_DEBUG_ASSERT_HANDLER_H__ 27 | #define BLE_DEBUG_ASSERT_HANDLER_H__ 28 | 29 | #include 30 | 31 | /**@brief Function for handling the Debug assert, which can be called from an error handler. 32 | * To be used only for debugging purposes. 33 | * 34 | *@details This code will copy the filename and line number into local variables for them to always 35 | * be accessible in Keil debugger. The function will also write the ARM Cortex-M0 stack 36 | * memory into flash where it can be retrieved and manually un-winded in order to 37 | * back-trace the location where the error ocured.
38 | * @warning ALL INTERRUPTS WILL BE DISABLED. 39 | * 40 | * @note This function will never return but loop forever for debug purposes. 41 | * 42 | * @param[in] error_code Error code supplied to the handler. 43 | * @param[in] line_num Line number where the original handler is called. 44 | * @param[in] p_file_name Pointer to the file name. 45 | */ 46 | void ble_debug_assert_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name); 47 | 48 | #endif /* BLE_DEBUG_ASSERT_HANDLER_H__ */ 49 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/ble_eval_board_pins.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_sdk_lib_eval_board_pins Evaluation Board LEDs and Buttons Pin Assignments 16 | * @{ 17 | * @ingroup ble_sdk_lib 18 | * @brief Pin assignments for LEDs and Buttons on the evaluation board 19 | * 20 | * @details Pin assignments for LEDs and Buttons in evaluation board applications. 21 | */ 22 | 23 | #ifndef BLE_EVAL_BOARD_PINS_H__ 24 | #define BLE_EVAL_BOARD_PINS_H__ 25 | 26 | #define EVAL_BOARD_LED_0 18 /**< Pin connected to LED 0 in the pca10001 evaluation board.*/ 27 | #define EVAL_BOARD_LED_1 19 /**< Pin connected to LED 1 in the pca10001 evaluation board.*/ 28 | 29 | #define EVAL_BOARD_BUTTON_0 16 /**< Pin connected to BUTTON 0 in the pca10001 evaluation board.*/ 30 | #define EVAL_BOARD_BUTTON_1 17 /**< Pin connected to BUTTON 1 in the pca10001 evaluation board.*/ 31 | 32 | #define ADVERTISING_LED_PIN_NO EVAL_BOARD_LED_0 /**< Pin that can be used by applications to indicate advertising state.*/ 33 | #define CONNECTED_LED_PIN_NO EVAL_BOARD_LED_1 /**< Pin that can be used by applications to indicate connected state.*/ 34 | 35 | #endif // BLE_EVAL_BOARD_PINS_H__ 36 | 37 | /** @} */ 38 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/ble_nrf6310_pins.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_sdk_lib_nrf6310_pins nRF6310 Board LEDs and Buttons Pin Assignments 16 | * @{ 17 | * @ingroup ble_sdk_lib 18 | * @brief Pin assignments for LEDs and Buttons on the nRF6310 board 19 | * 20 | * @details Pin assignments for LEDs and Buttons to be used in all SDK applications. 21 | */ 22 | 23 | #ifndef BLE_NRF6310_PINS_H__ 24 | #define BLE_NRF6310_PINS_H__ 25 | 26 | #define NRF6310_LED_0 8 27 | #define NRF6310_LED_1 9 28 | #define NRF6310_LED_2 10 29 | #define NRF6310_LED_3 11 30 | #define NRF6310_LED_4 12 31 | #define NRF6310_LED_5 13 32 | #define NRF6310_LED_6 14 33 | #define NRF6310_LED_7 15 34 | 35 | #define NRF6310_BUTTON_0 0 36 | #define NRF6310_BUTTON_1 1 37 | #define NRF6310_BUTTON_2 2 38 | #define NRF6310_BUTTON_3 3 39 | #define NRF6310_BUTTON_4 4 40 | #define NRF6310_BUTTON_5 5 41 | #define NRF6310_BUTTON_6 6 42 | #define NRF6310_BUTTON_7 7 43 | 44 | #define ADVERTISING_LED_PIN_NO NRF6310_LED_0 45 | #define CONNECTED_LED_PIN_NO NRF6310_LED_1 46 | #define ASSERT_LED_PIN_NO NRF6310_LED_7 47 | 48 | #endif // BLE_NRF6310_PINS_H__ 49 | 50 | /** @} */ 51 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/ble_radio_notification.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | */ 11 | 12 | /** @file 13 | * 14 | * @defgroup ble_radio_notification Radio Notification Event Handler 15 | * @{ 16 | * @ingroup ble_sdk_lib 17 | * @brief Module for propagating Radio Notification events to the application. 18 | */ 19 | 20 | #ifndef BLE_RADIO_NOTIFICATION_H__ 21 | #define BLE_RADIO_NOTIFICATION_H__ 22 | 23 | #include 24 | #include 25 | #include "nrf_soc.h" 26 | 27 | /**@brief Application radio notification event handler type. */ 28 | typedef void (*ble_radio_notification_evt_handler_t) (bool radio_active); 29 | 30 | /**@brief Function for initializing the Radio Notification module. 31 | * 32 | * @param[in] irq_priority Interrupt priority for the Radio Notification interrupt handler. 33 | * @param[in] distance The time from an Active event until the radio is activated. 34 | * @param[in] evt_handler Handler to be executed when a radio notification event has been 35 | * received. 36 | * 37 | * @return NRF_SUCCESS on successful initialization, otherwise an error code. 38 | */ 39 | uint32_t ble_radio_notification_init(nrf_app_irq_priority_t irq_priority, 40 | nrf_radio_notification_distance_t distance, 41 | ble_radio_notification_evt_handler_t evt_handler); 42 | 43 | #endif // BLE_RADIO_NOTIFICATION_H__ 44 | 45 | /** @} */ 46 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/ble_sensorsim.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_sdk_lib_sensorsim Sensor Data Simulator 16 | * @{ 17 | * @ingroup ble_sdk_lib 18 | * @brief Functions for simulating sensor data. 19 | * 20 | * @details Currently only a triangular waveform simulator is implemented. 21 | */ 22 | 23 | #ifndef BLE_SENSORSIM_H__ 24 | #define BLE_SENSORSIM_H__ 25 | 26 | #include 27 | #include 28 | 29 | /**@brief Triangular waveform sensor simulator configuration. */ 30 | typedef struct 31 | { 32 | uint32_t min; /**< Minimum simulated value. */ 33 | uint32_t max; /**< Maximum simulated value. */ 34 | uint32_t incr; /**< Increment between each measurement. */ 35 | bool start_at_max; /**< TRUE is measurement is to start at the maximum value, FALSE if it is to start at the minimum. */ 36 | } ble_sensorsim_cfg_t; 37 | 38 | /**@brief Triangular waveform sensor simulator state. */ 39 | typedef struct 40 | { 41 | uint32_t current_val; /**< Current sensor value. */ 42 | bool is_increasing; /**< TRUE if the simulator is in increasing state, FALSE otherwise. */ 43 | } ble_sensorsim_state_t; 44 | 45 | /**@brief Function for initializing a triangular waveform sensor simulator. 46 | * 47 | * @param[out] p_state Current state of simulator. 48 | * @param[in] p_cfg Simulator configuration. 49 | */ 50 | void ble_sensorsim_init(ble_sensorsim_state_t * p_state, 51 | const ble_sensorsim_cfg_t * p_cfg); 52 | 53 | /**@brief Function for generating a simulated sensor measurement using a triangular waveform generator. 54 | * 55 | * @param[in,out] p_state Current state of simulator. 56 | * @param[in] p_cfg Simulator configuration. 57 | * 58 | * @return Simulator output. 59 | */ 60 | uint32_t ble_sensorsim_measure(ble_sensorsim_state_t * p_state, 61 | const ble_sensorsim_cfg_t * p_cfg); 62 | 63 | #endif // BLE_SENSORSIM_H__ 64 | 65 | /** @} */ 66 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/ble_services/ble_sc_ctrlpt.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/bootloader/nrf51822/Include/ble/ble_services/ble_sc_ctrlpt.h -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/ble_services/ble_sensor_location.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/bootloader/nrf51822/Include/ble/ble_services/ble_sensor_location.h -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/rpc/ble_rpc_cmd_decoder_gap.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_rpc_cmd_decoder_gap GAP Command Decoder 16 | * @{ 17 | * @ingroup ble_sdk_lib_serialization 18 | * 19 | * @brief Decoder for serialized GAP commands from Application Chip. 20 | * 21 | * @details This file contains the declaration of the function that decodes the serialized GAP 22 | * commands from Application Chip and calls the appropriate BLE stack API. 23 | */ 24 | 25 | #ifndef BLE_RPC_CMD_DECODER_GAP_H__ 26 | #define BLE_RPC_CMD_DECODER_GAP_H__ 27 | 28 | #include 29 | 30 | /**@brief Function for processing the encoded GAP command from Application Chip. 31 | * 32 | * @details This function will decode the encoded command and call the appropriate BLE Stack 33 | * API. It will then create a Command Response packet with the return value from the 34 | * stack API encoded in it and will send it to the transport layer for transmission to 35 | * the application controller chip. 36 | 37 | * @param[in] p_command The encoded command. 38 | * @param[in] op_code Operation code of the command. 39 | * @param[in] command_len Length of the encoded command. 40 | * 41 | * @retval NRF_SUCCESS If the decoding of the command was successful, the soft device API 42 | * was called, and the command response was sent to peer, otherwise an 43 | * error code. 44 | * If the transport layer returns an error code while sending 45 | * the Command Response, the same error code will be returned by this 46 | * function (see @ref hci_transport_pkt_write for the list of 47 | * error codes). 48 | */ 49 | uint32_t ble_rpc_cmd_gap_decode(uint8_t * p_command, uint8_t op_code, uint32_t command_len); 50 | 51 | #endif // BLE_RPC_CMD_DECODER_GAP_H__ 52 | 53 | /** @} */ 54 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/rpc/ble_rpc_cmd_decoder_gatts.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_rpc_cmd_decoder_gatts GATTS Command Decoder 16 | * @{ 17 | * @ingroup ble_sdk_lib_serialization 18 | * 19 | * @brief Decoder for serialized GATTS commands from Application Chip. 20 | * 21 | * @details This file contains the declaration of the function that decodes the serialized GATTS 22 | * commands from Application Chip and calls the appropriate BLE stack API. 23 | */ 24 | 25 | #ifndef BLE_RPC_CMD_DECODER_GATTS_H__ 26 | #define BLE_RPC_CMD_DECODER_GATTS_H__ 27 | 28 | #include 29 | 30 | /**@brief Function for processing the encoded GATTS command from application chip. 31 | * 32 | * @details This function will decode the encoded command and call the appropriate BLE Stack 33 | * API. It will then create a Command Response packet with the return value from the 34 | * stack API encoded in it and will send it to the transport layer for transmission to 35 | * the application controller chip. 36 | 37 | * @param[in] p_command The encoded command. 38 | * @param[in] op_code Operation code of the command. 39 | * @param[in] command_len Length of the encoded command. 40 | * 41 | * @retval NRF_SUCCESS If the decoding of the command was successful, the soft device API 42 | * was called, and the command response was sent to peer, otherwise an 43 | * error code. 44 | * If the transport layer returns an error code while sending 45 | * the Command Response, the same error code will be returned by this 46 | * function (see @ref hci_transport_pkt_write for the list of 47 | * error codes). 48 | */ 49 | uint32_t ble_rpc_cmd_gatts_decode(uint8_t * p_command, uint8_t op_code, uint32_t command_len); 50 | 51 | #endif // BLE_RPC_CMD_DECODER_GATTS_H__ 52 | 53 | /** @} */ 54 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/rpc/ble_rpc_event_decoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_rpc_evt_decoder Event Decoder 16 | * @{ 17 | * @ingroup ble_sdk_lib_serialization 18 | * 19 | * @brief Decoder for serialized events from nRF51822. 20 | * 21 | * @details This file contains the declaration of the function that initializes the event decoder 22 | * module and processes received events. 23 | */ 24 | 25 | #ifndef BLE_RPC_EVT_DECODER_H__ 26 | #define BLE_RPC_EVT_DECODER_H__ 27 | 28 | #include 29 | 30 | #ifndef SVCALL_AS_NORMAL_FUNCTION 31 | #error "The compiler define SVCALL_AS_NORMAL_FUNCTION is not defined." 32 | #endif 33 | 34 | 35 | /**@brief Function for pushing an encoded packet in the event decoder. 36 | * 37 | * @warning This function is not reentrant safe and should always be called from same interrupt 38 | * context. 39 | * 40 | * @param[in] p_event_packet Pointer to the encoded event received. 41 | * @param[in] event_packet_length Length of received packet. 42 | * 43 | * @retval NRF_SUCCESS Upon success. 44 | * @retval NRF_ERROR_NO_MEM Upon receive queue full. 45 | */ 46 | uint32_t ble_rpc_event_pkt_received(uint8_t * p_event_packet, uint16_t event_packet_length); 47 | 48 | #endif // BLE_RPC_EVT_DECODER_H__ 49 | 50 | /** @} **/ 51 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/rpc/ble_rpc_event_decoder_gap.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_rpc_evt_decoder_gap GAP Event Decoder 16 | * @{ 17 | * @ingroup ble_sdk_lib_serialization 18 | * 19 | * @brief Decoder for serialized GAP events from nRF51822. 20 | * 21 | * @details This file contains declarations of functions used for decoding GAP event packets 22 | * received from the Connectivity Chip. 23 | * 24 | */ 25 | 26 | #ifndef BLE_RPC_EVENT_DECODER_GAP_H__ 27 | #define BLE_RPC_EVENT_DECODER_GAP_H__ 28 | 29 | #include 30 | #include "ble.h" 31 | 32 | /** @brief Function for decoding the length of a BLE GAP event. 33 | * 34 | * @param[in] event_id Event Id for the event to length decode. 35 | * @param[out] p_event_length The pointer for storing the decoded event length. 36 | */ 37 | void ble_rpc_gap_evt_length_decode(uint8_t event_id, uint16_t * p_event_length); 38 | 39 | /** @brief Function for decoding a BLE GAP event. 40 | * 41 | * @param[out] p_ble_evt The pointer for storing the decoded event. 42 | * @param[in] p_packet The pointer to the encoded event. 43 | */ 44 | void ble_rpc_gap_evt_packet_decode(ble_evt_t * p_ble_evt, 45 | uint8_t const * const p_packet); 46 | 47 | #endif // BLE_RPC_EVENT_DECODER_GAP_H__ 48 | 49 | /** @} **/ 50 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/rpc/ble_rpc_event_decoder_gatts.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_rpc_evt_decoder_gatts GATTS Event Decoder 16 | * @{ 17 | * @ingroup ble_sdk_lib_serialization 18 | * 19 | * @brief Decoder for serialized GATT Server events from nRF51822. 20 | * 21 | * @details This file contains declarations of functions used for decoding GATTS event packets 22 | * received from the Connectivity Chip. 23 | * 24 | */ 25 | 26 | #ifndef BLE_RPC_EVENT_DECODER_GATTS_H__ 27 | #define BLE_RPC_EVENT_DECODER_GATTS_H__ 28 | 29 | #include 30 | #include "ble.h" 31 | #include "ble_gatts.h" 32 | 33 | /** @brief Function for decoding the length of a BLE GATTS event. The decoded BLE GATTS event 34 | * length will be returned in p_event_length. 35 | * 36 | * @param[in] event_id Event Id of the event, whose length is to be decoded. 37 | * @param[out] p_event_length The pointer for storing the decoded event length. 38 | * @param[in] p_packet The pointer to the encoded event. 39 | */ 40 | void ble_rpc_gatts_evt_length_decode(uint8_t event_id, 41 | uint16_t * p_event_length, 42 | uint8_t const * const p_packet); 43 | 44 | /** @brief Function for decoding a BLE GATTS event. The decoded BLE GATTS event will be returned in 45 | * the memory pointed to by p_ble_evt. 46 | * 47 | * @param[out] p_ble_evt The pointer for storing the decoded event. 48 | * @param[in] p_packet The pointer to the encoded event. 49 | */ 50 | void ble_rpc_gatts_evt_packet_decode(ble_evt_t * p_ble_evt, 51 | uint8_t const * const p_packet); 52 | 53 | #endif // BLE_RPC_EVENT_DECODER_GATTS_H__ 54 | 55 | /** @} **/ 56 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/rpc/ble_rpc_event_encoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_rpc_event_encoder Events Encoder 16 | * @{ 17 | * @ingroup ble_sdk_lib_serialization 18 | * 19 | * @brief Event encoder for S110 SoftDevice serialization. 20 | * 21 | * @details This module provides a function for serializing S110 SoftDevice events. 22 | * 23 | */ 24 | #ifndef BLE_RPC_EVENT_ENCODER_H__ 25 | #define BLE_RPC_EVENT_ENCODER_H__ 26 | 27 | #include "ble.h" 28 | 29 | /**@brief Function for encoding a @ref ble_evt_t. The function will pass the serialized byte stream to the 30 | * transport layer after encoding. 31 | * 32 | * @param[in] p_ble_evt S110 SoftDevice event to serialize. 33 | */ 34 | void ble_rpc_event_handle(ble_evt_t * p_ble_evt); 35 | 36 | #endif // BLE_RPC_EVENT_ENCODER_H__ 37 | 38 | /** @} */ 39 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/rpc/ble_rpc_event_encoder_gap.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_rpc_event_encoder_gap GAP Event Encoder 16 | * @{ 17 | * @ingroup ble_sdk_lib_serialization 18 | * 19 | * @brief Event encoder for S110 SoftDevice serialization. 20 | * 21 | * @details This module provides functions for serializing S110 SoftDevice events. 22 | * 23 | */ 24 | #ifndef BLE_RPC_EVENT_ENCODER_GAP_H__ 25 | #define BLE_RPC_EVENT_ENCODER_GAP_H__ 26 | 27 | #include 28 | #include 29 | 30 | /**@brief Function for encoding a @ref ble_evt_t GAP event. 31 | * 32 | * @param[in] p_ble_evt S110 SoftDevice event to serialize. 33 | * @param[out] p_buffer Pointer to a buffer for the encoded event. 34 | * 35 | * @return Number of bytes encoded. 36 | */ 37 | uint32_t ble_rpc_evt_gap_encode(ble_evt_t * p_ble_evt, uint8_t * p_buffer); 38 | 39 | #endif // BLE_RPC_EVENT_ENCODER_GAP_H__ 40 | 41 | /** @} */ 42 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/rpc/ble_rpc_event_encoder_gatts.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_rpc_event_encoder_gatts GATTS Events Encoder 16 | * @{ 17 | * @ingroup ble_sdk_lib_serialization 18 | * 19 | * @brief Event encoder for S110 SoftDevice serialization. 20 | * 21 | * @details This module provides functions for serializing S110 SoftDevice events. 22 | * 23 | */ 24 | #ifndef BLE_RPC_EVENT_ENCODER_GATTS_H__ 25 | #define BLE_RPC_EVENT_ENCODER_GATTS_H__ 26 | 27 | #include 28 | #include 29 | 30 | /**@brief Function for encoding a @ref ble_evt_t GATTS event. 31 | * 32 | * @param[in] p_ble_evt S110 SoftDevice event to serialize. 33 | * @param[out] p_buffer Pointer to a buffer for the encoded event. 34 | * 35 | * @return Number of bytes encoded. 36 | */ 37 | uint32_t ble_rpc_evt_gatts_encode(ble_evt_t * p_ble_evt, uint8_t * p_buffer); 38 | 39 | #endif // BLE_RPC_EVENT_ENCODER_GATTS_H__ 40 | 41 | /** @} */ 42 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/rpc/ble_rpc_pkt_receiver.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup rpc_pkt_receiver Packet Receiver 16 | * @{ 17 | * @ingroup ble_sdk_lib_serialization 18 | * 19 | * @brief This module is used for processing the Command Response packets and Event packets. 20 | */ 21 | 22 | #ifndef BLE_RPC_PKT_RECEIVER_H__ 23 | #define BLE_RPC_PKT_RECEIVER_H__ 24 | 25 | #include 26 | 27 | /**@brief Function for initializing the BLE S110 RPC Packet Receiver module. 28 | * 29 | * @return NRF_SUCCESS upon success, any other upon failure. 30 | */ 31 | uint32_t ble_rpc_pkt_receiver_init(void); 32 | 33 | #endif 34 | 35 | /** @} **/ 36 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/softdevice/ble_err.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 3 | * 4 | * The information contained herein is confidential property of Nordic Semiconductor. The use, 5 | * copying, transfer or disclosure of such information is prohibited except by express written 6 | * agreement with Nordic Semiconductor. 7 | * 8 | */ 9 | /** 10 | @addtogroup BLE_COMMON 11 | @{ 12 | @addtogroup nrf_error 13 | @{ 14 | @ingroup BLE_COMMON 15 | @} 16 | 17 | @defgroup ble_err General error codes 18 | @{ 19 | 20 | @brief General error code definitions for the BLE API. 21 | 22 | @ingroup BLE_COMMON 23 | */ 24 | #ifndef NRF_BLE_ERR_H__ 25 | #define NRF_BLE_ERR_H__ 26 | 27 | #include "nrf_error.h" 28 | 29 | /* @defgroup BLE_ERRORS Error Codes 30 | * @{ */ 31 | #define BLE_ERROR_INVALID_CONN_HANDLE (NRF_ERROR_STK_BASE_NUM+0x001) /**< Invalid connection handle. */ 32 | #define BLE_ERROR_INVALID_ATTR_HANDLE (NRF_ERROR_STK_BASE_NUM+0x002) /**< Invalid attribute handle. */ 33 | #define BLE_ERROR_NO_TX_BUFFERS (NRF_ERROR_STK_BASE_NUM+0x003) /**< Buffer capacity exceeded. */ 34 | /** @} */ 35 | 36 | 37 | /** @defgroup BLE_ERROR_SUBRANGES Module specific error code subranges 38 | * @brief Assignment of subranges for module specific error codes. 39 | * @note For specific error codes, see ble_.h or ble_error_.h. 40 | * @{ */ 41 | #define NRF_L2CAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x100) /**< L2CAP specific errors. */ 42 | #define NRF_GAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x200) /**< GAP specific errors. */ 43 | #define NRF_GATTC_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x300) /**< GATT client specific errors. */ 44 | #define NRF_GATTS_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x400) /**< GATT server specific errors. */ 45 | /** @} */ 46 | 47 | #endif 48 | 49 | 50 | /** 51 | @} 52 | @} 53 | */ 54 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/softdevice/ble_ranges.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 3 | 4 | The information contained herein is confidential property of Nordic Semiconductor. The use, 5 | copying, transfer or disclosure of such information is prohibited except by express written 6 | agreement with Nordic Semiconductor. 7 | */ 8 | /** 9 | @addtogroup BLE_COMMON 10 | @{ 11 | @defgroup ble_ranges Module specific SVC and event number subranges 12 | @{ 13 | 14 | @brief Definition of SVC and event number subranges for each API module. 15 | 16 | @note 17 | SVCs and event numbers are split into subranges for each API module. 18 | Each module receives its entire allocated range of SVC calls, whether implemented or not, 19 | but return BLE_ERROR_NOT_SUPPORTED for unimplemented or undefined calls in its range. 20 | 21 | Note that the symbols BLE__SVC_LAST is the end of the allocated SVC range, 22 | rather than the last SVC function call actually defined and implemented. 23 | 24 | Specific SVC and event values are defined in each module's ble_.h file, 25 | which defines names of each individual SVC code based on the range start value. 26 | */ 27 | 28 | #ifndef BLE_RANGES_H__ 29 | #define BLE_RANGES_H__ 30 | 31 | #define BLE_SVC_BASE 0x50 32 | #define BLE_SVC_LAST 0x5B /* Total: 12. */ 33 | 34 | #define BLE_RESERVED_SVC_BASE 0x5C 35 | #define BLE_RESERVED_SVC_LAST 0x5F /* Total: 4. */ 36 | 37 | #define BLE_GAP_SVC_BASE 0x60 38 | #define BLE_GAP_SVC_LAST 0x7F /* Total: 32. */ 39 | 40 | #define BLE_GATTC_SVC_BASE 0x80 41 | #define BLE_GATTC_SVC_LAST 0x9F /* Total: 32. */ 42 | 43 | #define BLE_GATTS_SVC_BASE 0xA0 44 | #define BLE_GATTS_SVC_LAST 0xAF /* Total: 16. */ 45 | 46 | #define BLE_L2CAP_SVC_BASE 0xB0 47 | #define BLE_L2CAP_SVC_LAST 0xBF /* Total: 16. */ 48 | 49 | 50 | #define BLE_EVT_INVALID 0x00 51 | 52 | #define BLE_EVT_BASE 0x01 53 | #define BLE_EVT_LAST 0x0F /* Total: 15. */ 54 | 55 | #define BLE_GAP_EVT_BASE 0x10 56 | #define BLE_GAP_EVT_LAST 0x2F /* Total: 32. */ 57 | 58 | #define BLE_GATTC_EVT_BASE 0x30 59 | #define BLE_GATTC_EVT_LAST 0x4F /* Total: 32. */ 60 | 61 | #define BLE_GATTS_EVT_BASE 0x50 62 | #define BLE_GATTS_EVT_LAST 0x6F /* Total: 32. */ 63 | 64 | #define BLE_L2CAP_EVT_BASE 0x70 65 | #define BLE_L2CAP_EVT_LAST 0x8F /* Total: 32. */ 66 | 67 | #endif /* BLE_RANGES_H__ */ 68 | 69 | /** 70 | @} 71 | @} 72 | */ 73 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/softdevice/nrf_error_sdm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 3 | * 4 | * The information contained herein is confidential property of Nordic Semiconductor. The use, 5 | * copying, transfer or disclosure of such information is prohibited except by express written 6 | * agreement with Nordic Semiconductor. 7 | * 8 | */ 9 | /** 10 | @addtogroup nrf_sdm_api 11 | @{ 12 | @defgroup nrf_sdm_error SoftDevice Manager Error Codes 13 | @{ 14 | 15 | @brief Error definitions for the SDM API 16 | */ 17 | 18 | /* Header guard */ 19 | #ifndef NRF_ERROR_SDM_H__ 20 | #define NRF_ERROR_SDM_H__ 21 | 22 | #include "nrf_error.h" 23 | 24 | #define NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN (NRF_ERROR_SDM_BASE_NUM + 0) ///< Unknown lfclk source 25 | #define NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION (NRF_ERROR_SDM_BASE_NUM + 1) ///< Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts) 26 | #define NRF_ERROR_SDM_INCORRECT_CLENR0 (NRF_ERROR_SDM_BASE_NUM + 2) ///< Incorrect CLENR0 (can be caused by erronous SoftDevice flashing) 27 | 28 | #endif // NRF_ERROR_SDM_H__ 29 | 30 | /** 31 | @} 32 | @} 33 | */ 34 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/softdevice/nrf_error_soc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 3 | * 4 | * The information contained herein is confidential property of Nordic Semiconductor. The use, 5 | * copying, transfer or disclosure of such information is prohibited except by express written 6 | * agreement with Nordic Semiconductor. 7 | * 8 | */ 9 | /** 10 | @addtogroup nrf_soc_api 11 | @{ 12 | @defgroup nrf_soc_error SoC Library Error Codes 13 | @{ 14 | 15 | @brief Error definitions for the SoC library 16 | 17 | */ 18 | 19 | /* Header guard */ 20 | #ifndef NRF_ERROR_SOC_H__ 21 | #define NRF_ERROR_SOC_H__ 22 | 23 | #include "nrf_error.h" 24 | 25 | /* Mutex Errors */ 26 | #define NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN (NRF_ERROR_SOC_BASE_NUM + 0) ///< Mutex already taken 27 | 28 | /* NVIC errors */ 29 | #define NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE (NRF_ERROR_SOC_BASE_NUM + 1) ///< NVIC interrupt not available 30 | #define NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED (NRF_ERROR_SOC_BASE_NUM + 2) ///< NVIC interrupt priority not allowed 31 | #define NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 3) ///< NVIC should not return 32 | 33 | /* Power errors */ 34 | #define NRF_ERROR_SOC_POWER_MODE_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 4) ///< Power mode unknown 35 | #define NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 5) ///< Power POF threshold unknown 36 | #define NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 6) ///< Power off should not return 37 | 38 | /* Rand errors */ 39 | #define NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES (NRF_ERROR_SOC_BASE_NUM + 7) ///< RAND not enough values 40 | 41 | /* PPI errors */ 42 | #define NRF_ERROR_SOC_PPI_INVALID_CHANNEL (NRF_ERROR_SOC_BASE_NUM + 8) ///< Invalid PPI Channel 43 | #define NRF_ERROR_SOC_PPI_INVALID_GROUP (NRF_ERROR_SOC_BASE_NUM + 9) ///< Invalid PPI Group 44 | 45 | #endif // NRF_ERROR_SOC_H__ 46 | /** 47 | @} 48 | @} 49 | */ 50 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/softdevice/nrf_svc.h: -------------------------------------------------------------------------------- 1 | #ifndef NRF_SVC__ 2 | #define NRF_SVC__ 3 | 4 | #ifdef SVCALL_AS_NORMAL_FUNCTION 5 | #define SVCALL(number, return_type, signature) return_type signature 6 | #else 7 | 8 | #ifndef SVCALL 9 | #if defined (__CC_ARM) 10 | #define SVCALL(number, return_type, signature) return_type __svc(number) signature 11 | #elif defined (__GNUC__) 12 | #define SVCALL(number, return_type, signature) \ 13 | _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \ 14 | _Pragma("GCC diagnostic ignored \"-Wunused-function\"") \ 15 | __attribute__((naked)) static return_type signature \ 16 | { \ 17 | __asm( \ 18 | "svc %0\n" \ 19 | "bx r14" : : "I" (number) : "r0" \ 20 | ); \ 21 | } 22 | #elif defined (__ICCARM__) 23 | #define PRAGMA(x) _Pragma(#x) 24 | #define SVCALL(number, return_type, signature) \ 25 | PRAGMA(swi_number = number) \ 26 | __swi return_type signature; 27 | #else 28 | #define SVCALL(number, return_type, signature) return_type signature 29 | #endif 30 | #endif // SVCALL 31 | 32 | #endif // SVCALL_AS_NORMAL_FUNCTION 33 | #endif // NRF_SVC__ 34 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ble/softdevice/softdevice_assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 3 | * 4 | * The information contained herein is confidential property of Nordic Semiconductor. The use, 5 | * copying, transfer or disclosure of such information is prohibited except by express written 6 | * agreement with Nordic Semiconductor. 7 | * 8 | */ 9 | 10 | /** @brief Utilities for verifying program logic 11 | */ 12 | 13 | #ifndef SOFTDEVICE_ASSERT_H_ 14 | #define SOFTDEVICE_ASSERT_H_ 15 | 16 | #include 17 | 18 | /** @brief This function handles assertions. 19 | * 20 | * 21 | * @note 22 | * This function is called when an assertion has triggered. 23 | * 24 | * 25 | * @param line_num The line number where the assertion is called 26 | * @param file_name Pointer to the file name 27 | */ 28 | void assert_softdevice_callback(uint16_t line_num, const uint8_t *file_name); 29 | 30 | 31 | /*lint -emacro(506, ASSERT) */ /* Suppress "Constant value Boolean */ 32 | /*lint -emacro(774, ASSERT) */ /* Suppress "Boolean within 'if' always evaluates to True" */ \ 33 | /** @brief Check intended for production code 34 | * 35 | * Check passes if "expr" evaluates to true. */ 36 | #define ASSERT(expr) \ 37 | if (expr) \ 38 | { \ 39 | } \ 40 | else \ 41 | { \ 42 | assert_softdevice_callback((uint16_t)__LINE__, (uint8_t *)__FILE__); \ 43 | /*lint -unreachable */ \ 44 | } 45 | 46 | #endif /* SOFTDEVICE_ASSERT_H_ */ 47 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/boards.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | #ifndef BOARDS_H 13 | #define BOARDS_H 14 | 15 | #if defined(BOARD_NRF6310) 16 | #include "boards/nrf6310.h" 17 | #elif defined(WT1000) 18 | #include "boards/WT1000.h" 19 | #else 20 | #error "Board is not defined" 21 | #endif 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/boards/WT1000.h: -------------------------------------------------------------------------------- 1 | #ifndef _WT1000_H_ 2 | #define _WT1000_H_ 3 | 4 | #define BAIDU_LED_0 7 5 | #define BAIDU_LED_1 19 6 | #define BAIDU_LED_2 18 7 | #define BAIDU_LED_3 5 8 | #define BAIDU_LED_4 6 9 | #define BAIDU_MOTOR_0 29 10 | 11 | 12 | #define ADVERTISING_LED_PIN_NO BAIDU_LED_0 13 | #define CONNECTED_LED_PIN_NO BAIDU_LED_1 14 | #define ASSERT_LED_PIN_NO BAIDU_LED_2 15 | 16 | #define LED0 BAIDU_LED_0 17 | #define LED1 BAIDU_LED_1 18 | #define LED2 BAIDU_LED_2 19 | #define LED3 BAIDU_LED_3 20 | #define LED4 BAIDU_LED_4 21 | 22 | /* charger */ 23 | #define CHARGER_CONNECTED_PIN 1 24 | #define CHARGER_CHARGING_PIN 17 25 | 26 | #ifdef DEBUG_LOG 27 | #define RX_PIN_NUMBER 25 // UART RX pin number. 28 | #define TX_PIN_NUMBER 23 // UART TX pin number. 29 | //the follow pin is useless 30 | #define CTS_PIN_NUMBER 43 // UART Clear To Send pin number. Not used if HWFC is set to false 31 | #define RTS_PIN_NUMBER 43 // Not used if HWFC is set to false 32 | #define HWFC false // UART hardware flow control 33 | #endif 34 | 35 | #endif //_WT1000_H_ 36 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/boards/nrf6310.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | #ifndef NRF6310_H 13 | #define NRF6310_H 14 | 15 | #define LED_START 8 16 | #define LED_STOP 15 17 | #define LED_PORT NRF_GPIO_PORT_SELECT_PORT1 18 | #define LED_OFFSET 0 19 | 20 | #define LED0 8 21 | #define LED1 9 22 | #define LED2 10 23 | #define LED3 11 24 | #define LED4 12 25 | #define LED5 13 26 | #define LED6 14 27 | #define LED7 15 28 | 29 | #define BUTTON_START 0 30 | #define BUTTON_STOP 7 31 | #define BUTTON0 0 32 | #define BUTTON1 1 33 | #define BUTTON2 2 34 | #define BUTTON3 3 35 | #define BUTTON4 4 36 | #define BUTTON5 5 37 | #define BUTTON6 6 38 | #define BUTTON7 7 39 | 40 | 41 | 42 | #define RX_PIN_NUMBER 16 // UART RX pin number. 43 | #define TX_PIN_NUMBER 17 // UART TX pin number. 44 | #define CTS_PIN_NUMBER 18 // UART Clear To Send pin number. Not used if HWFC is set to false 45 | #define RTS_PIN_NUMBER 19 // Not used if HWFC is set to false 46 | #define HWFC false // UART hardware flow control 47 | 48 | #define BLINKY_STATE_MASK 0x07 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/common.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #ifndef COMMON_H 14 | #define COMMON_H 15 | 16 | /*lint ++flb "Enter library region" */ 17 | 18 | #include 19 | #include 20 | 21 | /* @file 22 | * @brief Common header file for generic macros and definitions 23 | * 24 | */ 25 | 26 | /* 27 | * GPIO glue macros, this can be used to define a pin number in source/header file and use that macro for pin 28 | * configuration using this expansion. 29 | * example: 30 | * #define RESET_PIN 8 31 | * NRF_GPIO->PINCNF(RESET_PIN) = XXX ; // Expanded NRF_GPIO->PIN_CNF[8] = XXX 32 | */ 33 | #define PINX_GLUE(x, y, z) x##y##_##z /*!< first level glue for pin macros */ 34 | #define PINCNF(p) PINX_GLUE(PIN,p,CNF) /*!< gpio configure pin number 'p' */ 35 | #define PINOUT(p) PINX_GLUE(PIN,p,OUT) /*!< gpio out pin number 'p' */ 36 | 37 | /*lint --flb "Leave library region" */ 38 | #endif 39 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/compiler_abstraction.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is confidential property of Nordic 4 | * Semiconductor ASA.Terms and conditions of usage are described in detail 5 | * in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #ifndef _COMPILER_ABSTRACTION_H 14 | #define _COMPILER_ABSTRACTION_H 15 | 16 | /*lint ++flb "Enter library region" */ 17 | 18 | #if defined ( __CC_ARM ) 19 | #define __ASM __asm /*!< asm keyword for ARM Compiler */ 20 | #define __INLINE __inline /*!< inline keyword for ARM Compiler */ 21 | #define __STATIC_INLINE static __inline 22 | 23 | #elif defined ( __ICCARM__ ) 24 | #define __ASM __asm /*!< asm keyword for IAR Compiler */ 25 | #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ 26 | #define __STATIC_INLINE static inline 27 | #define __current_sp() __get_SP() 28 | 29 | #elif defined ( __GNUC__ ) 30 | #define __ASM __asm /*!< asm keyword for GNU Compiler */ 31 | #define __INLINE inline /*!< inline keyword for GNU Compiler */ 32 | #define __STATIC_INLINE static inline 33 | 34 | static __INLINE unsigned int __current_sp(void) 35 | { 36 | register unsigned sp asm("sp"); 37 | return sp; 38 | } 39 | 40 | #elif defined ( __TASKING__ ) 41 | #define __ASM __asm /*!< asm keyword for TASKING Compiler */ 42 | #define __INLINE inline /*!< inline keyword for TASKING Compiler */ 43 | #define __STATIC_INLINE static inline 44 | 45 | #endif 46 | 47 | /*lint --flb "Leave library region" */ 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ext_sensors/mpu6050.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #ifndef MPU6050_H 14 | #define MPU6050_H 15 | 16 | /*lint ++flb "Enter library region" */ 17 | 18 | #include 19 | #include 20 | 21 | /** @file 22 | * @brief MPU6050 gyro/accelerometer driver. 23 | * 24 | * 25 | * @defgroup nrf_drivers_mpu6050 MPU6050 gyro/accelerometer driver 26 | * @{ 27 | * @ingroup nrf_drivers 28 | * @brief MPU6050 gyro/accelerometer driver. 29 | */ 30 | 31 | /** 32 | * @brief Function for initializing MPU6050 and verifies it's on the bus. 33 | * 34 | * @param device_address Device TWI address in bits [6:0]. 35 | * @return 36 | * @retval true MPU6050 found on the bus and ready for operation. 37 | * @retval false MPU6050 not found on the bus or communication failure. 38 | */ 39 | bool mpu6050_init(uint8_t device_address); 40 | 41 | /** 42 | @brief Function for writing a MPU6050 register contents over TWI. 43 | @param[in] register_address Register address to start writing to 44 | @param[in] value Value to write to register 45 | @retval true Register write succeeded 46 | @retval false Register write failed 47 | */ 48 | bool mpu6050_register_write(uint8_t register_address, const uint8_t value); 49 | 50 | /** 51 | @brief Function for reading MPU6050 register contents over TWI. 52 | Reads one or more consecutive registers. 53 | @param[in] register_address Register address to start reading from 54 | @param[in] number_of_bytes Number of bytes to read 55 | @param[out] destination Pointer to a data buffer where read data will be stored 56 | @retval true Register read succeeded 57 | @retval false Register read failed 58 | */ 59 | bool mpu6050_register_read(uint8_t register_address, uint8_t *destination, uint8_t number_of_bytes); 60 | 61 | /** 62 | @brief Function for reading and verifying MPU6050 product ID. 63 | @retval true Product ID is what was expected 64 | @retval false Product ID was not what was expected 65 | */ 66 | bool mpu6050_verify_product_id(void); 67 | 68 | /** 69 | *@} 70 | **/ 71 | 72 | /*lint --flb "Leave library region" */ 73 | 74 | #endif /* MPU6050_H */ 75 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/ext_sensors/sdio.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #ifndef SDIO_H 14 | #define SDIO_H 15 | 16 | /*lint ++flb "Enter library region" */ 17 | 18 | #include 19 | #include 20 | 21 | /** @file 22 | * @brief 2-wire serial interface driver (compatible with ADNS2080 mouse sensor driver) 23 | * 24 | * 25 | * @defgroup nrf_drivers_sdio SDIO driver 26 | * @{ 27 | * @ingroup nrf_drivers 28 | * @brief 2-wire serial interface driver. 29 | */ 30 | 31 | /** 32 | * @brief Function for initializing 2-wire serial interface and trying to handle stuck slaves. 33 | * 34 | */ 35 | void sdio_init(void); 36 | 37 | /** 38 | * @brief Function for reading a byte over 2-wire serial interface. 39 | * 40 | * Developer needs to implement this function in a way that suits the hardware. 41 | * @param address Register address to read from 42 | * @return Byte read 43 | */ 44 | uint8_t sdio_read_byte(uint8_t address); 45 | 46 | /** 47 | * @brief Function for reading several bytes over 2-wire serial interface using burst mode. 48 | * 49 | * Developer needs to implement this function in a way that suits the hardware. 50 | * @param target_buffer Buffer location to store read bytes to 51 | * @param target_buffer_size Bytes allocated for target_buffer 52 | */ 53 | void sdio_read_burst(uint8_t *target_buffer, uint8_t target_buffer_size); 54 | 55 | /** 56 | * @brief Function for writing a byte over 2-wire serial interface. 57 | * 58 | * Developer needs to implement this function in a way that suits the hardware. 59 | * @param address Register address to write to 60 | * @param data_byte Data byte to write 61 | */ 62 | void sdio_write_byte(uint8_t address, uint8_t data_byte); 63 | 64 | /** 65 | *@} 66 | **/ 67 | 68 | /*lint --flb "Leave library region" */ 69 | #endif 70 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/nrf.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | 14 | #ifndef NRF_H 15 | #define NRF_H 16 | 17 | #ifndef _WIN32 18 | 19 | #include "compiler_abstraction.h" 20 | 21 | /* Family selection for main includes. NRF51 must be selected. */ 22 | #ifdef NRF51 23 | #include "nrf51.h" 24 | #include "nrf51_bitfields.h" 25 | #include "nrf51_deprecated.h" 26 | #else 27 | #error "Device family must be defined. See nrf.h." 28 | #endif /* NRF51 */ 29 | 30 | #endif /* _WIN32 */ 31 | 32 | #endif /* NRF_H */ 33 | 34 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/nrf_assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006 Nordic Semiconductor. All Rights Reserved. 3 | * 4 | * The information contained herein is confidential property of Nordic Semiconductor. The use, 5 | * copying, transfer or disclosure of such information is prohibited except by express written 6 | * agreement with Nordic Semiconductor. 7 | * 8 | */ 9 | 10 | /** @file 11 | * @brief Utilities for verifying program logic 12 | */ 13 | 14 | #ifndef NRF_ASSERT_H_ 15 | #define NRF_ASSERT_H_ 16 | 17 | #include 18 | 19 | #if defined(DEBUG_NRF) || defined(DEBUG_NRF_USER) 20 | 21 | /** @brief Function for handling assertions. 22 | * 23 | * 24 | * @note 25 | * This function is called when an assertion has triggered. 26 | * 27 | * 28 | * @post 29 | * All hardware is put into an idle non-emitting state (in particular the radio is highly 30 | * important to switch off since the radio might be in a state that makes it send 31 | * packets continiously while a typical final infinit ASSERT loop is executing). 32 | * 33 | * 34 | * @param line_num The line number where the assertion is called 35 | * @param file_name Pointer to the file name 36 | */ 37 | void assert_nrf_callback(uint16_t line_num, const uint8_t *file_name); 38 | 39 | /*lint -emacro(506, ASSERT) */ /* Suppress "Constant value Boolean */ 40 | /*lint -emacro(774, ASSERT) */ /* Suppress "Boolean within 'if' always evaluates to True" */ \ 41 | 42 | /** @brief Function for checking intended for production code. 43 | * 44 | * Check passes if "expr" evaluates to true. */ 45 | #define ASSERT(expr) \ 46 | if (expr) \ 47 | { \ 48 | } \ 49 | else \ 50 | { \ 51 | assert_nrf_callback((uint16_t)__LINE__, (uint8_t *)__FILE__); \ 52 | } 53 | #else 54 | #define ASSERT(expr) //!< Assert empty when disabled 55 | void assert_nrf_callback(uint16_t line_num, const uint8_t *file_name); 56 | #endif /* defined(DEBUG_NRF) || defined(DEBUG_NRF_USER) */ 57 | 58 | #endif /* NRF_ASSERT_H_ */ 59 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/nrf_delay.h: -------------------------------------------------------------------------------- 1 | #ifndef _NRF_DELAY_H 2 | #define _NRF_DELAY_H 3 | 4 | #include "nrf.h" 5 | 6 | /*lint --e{438, 522} "Variable not used" "Function lacks side-effects" */ 7 | #if defined ( __CC_ARM ) 8 | static __ASM void __INLINE nrf_delay_us(uint32_t volatile number_of_us) 9 | { 10 | loop 11 | SUBS R0, R0, #1 12 | NOP 13 | NOP 14 | NOP 15 | NOP 16 | NOP 17 | NOP 18 | NOP 19 | NOP 20 | NOP 21 | NOP 22 | NOP 23 | NOP 24 | BNE loop 25 | BX LR 26 | } 27 | #elif defined ( __ICCARM__ ) 28 | static void __INLINE nrf_delay_us(uint32_t volatile number_of_us) 29 | { 30 | __ASM ( 31 | "loop:\n\t" 32 | " SUBS R0, R0, #1\n\t" 33 | " NOP\n\t" 34 | " NOP\n\t" 35 | " NOP\n\t" 36 | " NOP\n\t" 37 | " NOP\n\t" 38 | " NOP\n\t" 39 | " NOP\n\t" 40 | " NOP\n\t" 41 | " NOP\n\t" 42 | " NOP\n\t" 43 | " NOP\n\t" 44 | " NOP\n\t" 45 | " BNE loop\n\t"); 46 | } 47 | #elif defined ( __GNUC__ ) 48 | static void __INLINE nrf_delay_us(uint32_t volatile number_of_us) 49 | { 50 | do 51 | { 52 | __ASM volatile ( 53 | "NOP\n\t" 54 | "NOP\n\t" 55 | "NOP\n\t" 56 | "NOP\n\t" 57 | "NOP\n\t" 58 | "NOP\n\t" 59 | "NOP\n\t" 60 | "NOP\n\t" 61 | "NOP\n\t" 62 | "NOP\n\t" 63 | "NOP\n\t" 64 | "NOP\n\t" 65 | "NOP\n\t" 66 | "NOP\n\t" 67 | ); 68 | } while (--number_of_us); 69 | } 70 | #endif 71 | 72 | void nrf_delay_ms(uint32_t volatile number_of_ms); 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/nrf_ecb.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is confidential property of Nordic 4 | * Semiconductor ASA.Terms and conditions of usage are described in detail 5 | * in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | * $LastChangedRevision: 13999 $ 12 | */ 13 | 14 | /** 15 | * @file 16 | * @brief ECB driver API. 17 | */ 18 | 19 | #ifndef NRF_ECB_H__ 20 | #define NRF_ECB_H__ 21 | 22 | /** 23 | * @defgroup nrf_ecb AES ECB encryption 24 | * @{ 25 | * @ingroup nrf_drivers 26 | * @brief Driver for the nRF51 AES Electronic Code Book (ECB) peripheral. 27 | * 28 | * In order to encrypt and decrypt data the peripheral must be powered on 29 | * using nrf_ecb_init() and then the key set using nrf_ecb_set_key. 30 | */ 31 | 32 | #include 33 | 34 | /** 35 | * Initialize and power on the ECB peripheral. 36 | * 37 | * Allocates memory for the ECBDATAPTR. 38 | * @retval true Initialization was successful. 39 | * @retval false Powering up failed. 40 | */ 41 | bool nrf_ecb_init(void); 42 | 43 | /** 44 | * Encrypt/decrypt 16-byte data using current key. 45 | * 46 | * The function avoids unnecessary copying of data if the point to the 47 | * correct locations in the ECB data structure. 48 | * 49 | * @param dst Result of encryption/decryption. 16 bytes will be written. 50 | * @param src Source with 16-byte data to be encrypted/decrypted. 51 | * 52 | * @retval true If the encryption operation completed. 53 | * @retval false If the encryption operation did not complete. 54 | */ 55 | bool nrf_ecb_crypt(uint8_t * dst, const uint8_t * src); 56 | 57 | /** 58 | * Set the key to be used for encryption/decryption. 59 | * 60 | * @param key Pointer to key. 16 bytes will be read. 61 | */ 62 | void nrf_ecb_set_key(const uint8_t * key); 63 | 64 | #endif // NRF_ECB_H__ 65 | 66 | /** @} */ 67 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/nrf_nvmc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is confidential property of Nordic 4 | * Semiconductor ASA.Terms and conditions of usage are described in detail 5 | * in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | * $LastChangedRevision: 17685 $ 12 | */ 13 | 14 | /** 15 | * @file 16 | * @brief NMVC driver API. 17 | */ 18 | 19 | #ifndef NRF_NVMC_H__ 20 | #define NRF_NVMC_H__ 21 | 22 | #include 23 | 24 | 25 | /** 26 | * @defgroup nrf_nvmc Non-volatile memory controller 27 | * @{ 28 | * @ingroup nrf_drivers 29 | * @brief Driver for the nRF51 NVMC peripheral. 30 | * 31 | * This driver allows writing to the non-volatile memory (NVM) regions 32 | * of the nRF51. In order to write to NVM the controller must be powered 33 | * on and the relevant page must be erased. 34 | * 35 | */ 36 | 37 | 38 | /** 39 | * @brief Erase a page in flash. This is required before writing to any 40 | * address in the page. 41 | * 42 | * @param address Start address of the page. 43 | */ 44 | void nrf_nvmc_page_erase(uint32_t address); 45 | 46 | 47 | /** 48 | * @brief Write a single byte to flash. 49 | * 50 | * The function reads the word containing the byte, and then 51 | * rewrites the entire word. 52 | * 53 | * @param address Address to write to. 54 | * @param value Value to write. 55 | */ 56 | void nrf_nvmc_write_byte(uint32_t address , uint8_t value); 57 | 58 | 59 | /** 60 | * @brief Write a 32-bit word to flash. 61 | * @param address Address to write to. 62 | * @param value Value to write. 63 | */ 64 | void nrf_nvmc_write_word(uint32_t address, uint32_t value); 65 | 66 | 67 | /** 68 | * @brief Write consecutive bytes to flash. 69 | * 70 | * @param address Address to write to. 71 | * @param src Pointer to data to copy from. 72 | * @param num_bytes Number of bytes in src to write. 73 | */ 74 | void nrf_nvmc_write_bytes(uint32_t address, const uint8_t * src, uint32_t num_bytes); 75 | 76 | 77 | /** 78 | @ @brief Write consecutive words to flash. 79 | * 80 | * @param address Address to write to. 81 | * @param src Pointer to data to copy from. 82 | * @param num_words Number of bytes in src to write. 83 | */ 84 | void nrf_nvmc_write_words(uint32_t address, const uint32_t * src, uint32_t num_words); 85 | 86 | 87 | #endif // NRF_NVMC_H__ 88 | /** @} */ 89 | 90 | 91 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/nrf_temp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #ifndef NRF_TEMP_H__ 14 | #define NRF_TEMP_H__ 15 | 16 | #include "nrf51.h" 17 | 18 | /** 19 | * @defgroup nrf_temperature TEMP (temperature) abstraction 20 | * @{ 21 | * @ingroup nrf_drivers temperature_example 22 | * @brief Temperature module init and read functions. 23 | * 24 | */ 25 | 26 | 27 | 28 | /** 29 | * @brief Function for preparing the temp module for temperature measurement. 30 | * 31 | * This function initializes the TEMP module and writes to the hidden configuration register. 32 | * 33 | * @param none 34 | */ 35 | static __INLINE void nrf_temp_init(void) 36 | { 37 | /**@note Workaround for PAN_028 rev2.0A anomaly 31 - TEMP: Temperature offset value has to be manually loaded to the TEMP module */ 38 | *(uint32_t *) 0x4000C504 = 0; 39 | } 40 | 41 | 42 | 43 | #define MASK_SIGN (0x00000200UL) 44 | #define MASK_SIGN_EXTENSION (0xFFFFFC00UL) 45 | 46 | /** 47 | * @brief Function for reading temperature measurement. 48 | * 49 | * The function reads the 10 bit 2's complement value and transforms it to a 32 bit 2's complement value. 50 | * 51 | * @param none 52 | */ 53 | static __INLINE int32_t nrf_temp_read(void) 54 | { 55 | /**@note Workaround for PAN_028 rev2.0A anomaly 28 - TEMP: Negative measured values are not represented correctly */ 56 | return ((NRF_TEMP->TEMP & MASK_SIGN) != 0) ? (NRF_TEMP->TEMP | MASK_SIGN_EXTENSION) : (NRF_TEMP->TEMP); 57 | } 58 | 59 | /** @} */ 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Include/system_nrf51.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | 14 | #ifndef SYSTEM_NRF51_H 15 | #define SYSTEM_NRF51_H 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include 22 | 23 | 24 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 25 | 26 | /** 27 | * Initialize the system 28 | * 29 | * @param none 30 | * @return none 31 | * 32 | * @brief Setup the microcontroller system. 33 | * Initialize the System and update the SystemCoreClock variable. 34 | */ 35 | extern void SystemInit (void); 36 | 37 | /** 38 | * Update SystemCoreClock variable 39 | * 40 | * @param none 41 | * @return none 42 | * 43 | * @brief Updates the SystemCoreClock with current core Clock 44 | * retrieved from cpu registers. 45 | */ 46 | extern void SystemCoreClockUpdate (void); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* SYSTEM_NRF51_H */ 53 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Source/app_common/app_fifo.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #include "app_fifo.h" 14 | #include "app_util.h" 15 | 16 | 17 | #define FIFO_LENGTH (p_fifo->write_pos - p_fifo->read_pos) /**< Macro for calculating the FIFO length. */ 18 | 19 | 20 | uint32_t app_fifo_init(app_fifo_t * p_fifo, uint8_t * p_buf, uint16_t buf_size) 21 | { 22 | // Check buffer for null pointer 23 | if (p_buf == NULL) 24 | { 25 | return NRF_ERROR_NULL; 26 | } 27 | 28 | // Check that the buffer size is a power of two 29 | if (!IS_POWER_OF_TWO(buf_size)) 30 | { 31 | return NRF_ERROR_INVALID_LENGTH; 32 | } 33 | 34 | p_fifo->p_buf = p_buf; 35 | p_fifo->buf_size_mask = buf_size - 1; 36 | p_fifo->read_pos = 0; 37 | p_fifo->write_pos = 0; 38 | 39 | return NRF_SUCCESS; 40 | } 41 | 42 | 43 | uint32_t app_fifo_put(app_fifo_t * p_fifo, uint8_t byte) 44 | { 45 | if (FIFO_LENGTH <= p_fifo->buf_size_mask) 46 | { 47 | p_fifo->p_buf[p_fifo->write_pos & p_fifo->buf_size_mask] = byte; 48 | p_fifo->write_pos++; 49 | return NRF_SUCCESS; 50 | } 51 | 52 | return NRF_ERROR_NO_MEM; 53 | } 54 | 55 | 56 | uint32_t app_fifo_get(app_fifo_t * p_fifo, uint8_t * p_byte) 57 | { 58 | if (FIFO_LENGTH != 0) 59 | { 60 | *p_byte = p_fifo->p_buf[p_fifo->read_pos & p_fifo->buf_size_mask]; 61 | p_fifo->read_pos++; 62 | return NRF_SUCCESS; 63 | } 64 | 65 | return NRF_ERROR_NOT_FOUND; 66 | 67 | } 68 | 69 | uint32_t app_fifo_flush(app_fifo_t * p_fifo) 70 | { 71 | p_fifo->read_pos = p_fifo->write_pos; 72 | return NRF_SUCCESS; 73 | } 74 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Source/app_common/crc16.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #include "crc16.h" 14 | #include 15 | 16 | uint16_t crc16_compute(const uint8_t * p_data, uint32_t size, const uint16_t * p_crc) 17 | { 18 | uint32_t i; 19 | uint16_t crc = (p_crc == NULL) ? 0xffff : *p_crc; 20 | 21 | for (i = 0; i < size; i++) 22 | { 23 | crc = (unsigned char)(crc >> 8) | (crc << 8); 24 | crc ^= p_data[i]; 25 | crc ^= (unsigned char)(crc & 0xff) >> 4; 26 | crc ^= (crc << 8) << 4; 27 | crc ^= ((crc & 0xff) << 4) << 1; 28 | } 29 | 30 | return crc; 31 | } 32 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Source/ble/ble_debug_assert_handler.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #include "ble_debug_assert_handler.h" 14 | #include 15 | #include "nrf51.h" 16 | #include "ble_error_log.h" 17 | #include "nordic_common.h" 18 | 19 | #define MAX_LENGTH_FILENAME 128 /**< Max length of filename to copy for the debug error handlier. */ 20 | 21 | 22 | // WARNING - DO NOT USE THIS FUNCTION IN END PRODUCT. - WARNING 23 | // WARNING - FOR DEBUG PURPOSES ONLY. - WARNING 24 | void ble_debug_assert_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name) 25 | { 26 | // Copying parameters to static variables because parameters may not be accessible in debugger. 27 | static volatile uint8_t s_file_name[MAX_LENGTH_FILENAME]; 28 | static volatile uint16_t s_line_num; 29 | static volatile uint32_t s_error_code; 30 | 31 | strncpy((char *)s_file_name, (const char *)p_file_name, MAX_LENGTH_FILENAME - 1); 32 | s_file_name[MAX_LENGTH_FILENAME - 1] = '\0'; 33 | s_line_num = line_num; 34 | s_error_code = error_code; 35 | UNUSED_VARIABLE(s_file_name); 36 | UNUSED_VARIABLE(s_line_num); 37 | UNUSED_VARIABLE(s_error_code); 38 | 39 | // WARNING: The PRIMASK register is set to disable ALL interrups during writing the error log. 40 | // 41 | // Do not use __disable_irq() in normal operation. 42 | __disable_irq(); 43 | 44 | // This function will write error code, filename, and line number to the flash. 45 | // In addition, the Cortex-M0 stack memory will also be written to the flash. 46 | (void) ble_error_log_write(error_code, p_file_name, line_num); 47 | 48 | // For debug purposes, this function never returns. 49 | // Attach a debugger for tracing the error cause. 50 | for (;;) 51 | { 52 | // Do nothing. 53 | } 54 | } 55 | 56 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Source/ble/ble_racp.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | */ 11 | 12 | #include "ble_racp.h" 13 | #include 14 | 15 | 16 | void ble_racp_decode(uint8_t data_len, uint8_t * p_data, ble_racp_value_t * p_racp_val) 17 | { 18 | p_racp_val->opcode = 0xFF; 19 | p_racp_val->operator = 0xFF; 20 | p_racp_val->operand_len = 0; 21 | p_racp_val->p_operand = NULL; 22 | 23 | if (data_len > 0) 24 | { 25 | p_racp_val->opcode = p_data[0]; 26 | } 27 | if (data_len > 1) 28 | { 29 | p_racp_val->operator = p_data[1]; //lint !e415 30 | } 31 | if (data_len > 2) 32 | { 33 | p_racp_val->operand_len = data_len - 2; 34 | p_racp_val->p_operand = &p_data[2]; //lint !e416 35 | } 36 | } 37 | 38 | 39 | uint8_t ble_racp_encode(const ble_racp_value_t * p_racp_val, uint8_t * p_data) 40 | { 41 | uint8_t len = 0; 42 | int i; 43 | 44 | if (p_data != NULL) 45 | { 46 | p_data[len++] = p_racp_val->opcode; 47 | p_data[len++] = p_racp_val->operator; 48 | 49 | for (i = 0; i < p_racp_val->operand_len; i++) 50 | { 51 | p_data[len++] = p_racp_val->p_operand[i]; 52 | } 53 | } 54 | 55 | return len; 56 | } 57 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Source/ble/ble_radio_notification.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | */ 11 | 12 | #include "ble_radio_notification.h" 13 | #include 14 | 15 | 16 | static bool m_radio_active = false; /**< Current radio state. */ 17 | static ble_radio_notification_evt_handler_t m_evt_handler = NULL; /**< Application event handler for handling Radio Notification events. */ 18 | 19 | 20 | void SWI1_IRQHandler(void) 21 | { 22 | m_radio_active = !m_radio_active; 23 | if (m_evt_handler != NULL) 24 | { 25 | m_evt_handler(m_radio_active); 26 | } 27 | } 28 | 29 | 30 | uint32_t ble_radio_notification_init(nrf_app_irq_priority_t irq_priority, 31 | nrf_radio_notification_distance_t distance, 32 | ble_radio_notification_evt_handler_t evt_handler) 33 | { 34 | uint32_t err_code; 35 | 36 | m_evt_handler = evt_handler; 37 | 38 | // Initialize Radio Notification software interrupt 39 | err_code = sd_nvic_ClearPendingIRQ(SWI1_IRQn); 40 | if (err_code != NRF_SUCCESS) 41 | { 42 | return err_code; 43 | } 44 | 45 | err_code = sd_nvic_SetPriority(SWI1_IRQn, irq_priority); 46 | if (err_code != NRF_SUCCESS) 47 | { 48 | return err_code; 49 | } 50 | 51 | err_code = sd_nvic_EnableIRQ(SWI1_IRQn); 52 | if (err_code != NRF_SUCCESS) 53 | { 54 | return err_code; 55 | } 56 | 57 | // Configure the event 58 | return sd_radio_notification_cfg_set(NRF_RADIO_NOTIFICATION_TYPE_INT_ON_BOTH, distance); 59 | } 60 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Source/ble/ble_sensorsim.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #include "ble_sensorsim.h" 14 | 15 | 16 | void ble_sensorsim_init(ble_sensorsim_state_t * p_state, 17 | const ble_sensorsim_cfg_t * p_cfg) 18 | { 19 | if (p_cfg->start_at_max) 20 | { 21 | p_state->current_val = p_cfg->max; 22 | p_state->is_increasing = false; 23 | } 24 | else 25 | { 26 | p_state->current_val = p_cfg->min; 27 | p_state->is_increasing = true; 28 | } 29 | } 30 | 31 | 32 | uint32_t ble_sensorsim_measure(ble_sensorsim_state_t * p_state, 33 | const ble_sensorsim_cfg_t * p_cfg) 34 | { 35 | if (p_state->is_increasing) 36 | { 37 | if (p_cfg->max - p_state->current_val > p_cfg->incr) 38 | { 39 | p_state->current_val += p_cfg->incr; 40 | } 41 | else 42 | { 43 | p_state->current_val = p_cfg->max; 44 | p_state->is_increasing = false; 45 | } 46 | } 47 | else 48 | { 49 | if (p_state->current_val - p_cfg->min > p_cfg->incr) 50 | { 51 | p_state->current_val -= p_cfg->incr; 52 | } 53 | else 54 | { 55 | p_state->current_val = p_cfg->min; 56 | p_state->is_increasing = true; 57 | } 58 | } 59 | return p_state->current_val; 60 | } 61 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Source/ble/ble_services/ble_srv_common.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #include "ble_srv_common.h" 14 | #include 15 | #include "nordic_common.h" 16 | #include "app_error.h" 17 | 18 | 19 | uint8_t ble_srv_report_ref_encode(uint8_t * p_encoded_buffer, 20 | const ble_srv_report_ref_t * p_report_ref) 21 | { 22 | uint8_t len = 0; 23 | 24 | p_encoded_buffer[len++] = p_report_ref->report_id; 25 | p_encoded_buffer[len++] = p_report_ref->report_type; 26 | 27 | APP_ERROR_CHECK_BOOL(len == BLE_SRV_ENCODED_REPORT_REF_LEN); 28 | return len; 29 | } 30 | 31 | 32 | void ble_srv_ascii_to_utf8(ble_srv_utf8_str_t * p_utf8, char * p_ascii) 33 | { 34 | p_utf8->length = (uint16_t)strlen(p_ascii); 35 | p_utf8->p_str = (uint8_t *)p_ascii; 36 | } 37 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Source/ble/rpc/ble_rpc_event_encoder.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | 14 | #include "ble_rpc_event_encoder.h" 15 | #include "ble_rpc_event_encoder_gap.h" 16 | #include "ble_rpc_event_encoder_gatts.h" 17 | #include 18 | #include 19 | #include "app_util.h" 20 | #include "ble_gap.h" 21 | #include "nrf_error.h" 22 | #include "hci_transport.h" 23 | 24 | 25 | void ble_rpc_event_handle(ble_evt_t * p_ble_evt) 26 | { 27 | uint32_t err_code; 28 | uint8_t * p_buffer = NULL; 29 | uint8_t evt_packet_size = 0; 30 | 31 | // Allocate a memory buffer from HCI transport layer for transmitting the Command Response. 32 | // Loop until a buffer is available. 33 | do 34 | { 35 | err_code = hci_transport_tx_alloc(&p_buffer); 36 | } 37 | while (err_code == NRF_ERROR_NO_MEM); 38 | 39 | APP_ERROR_CHECK(err_code); 40 | 41 | uint16_t event_id = p_ble_evt->header.evt_id; 42 | 43 | if ((BLE_GAP_EVT_BASE <= event_id) && (event_id < BLE_GAP_EVT_LAST)) 44 | { 45 | evt_packet_size = ble_rpc_evt_gap_encode(p_ble_evt, p_buffer); 46 | } 47 | else if ((BLE_GATTS_EVT_BASE <= event_id) && (event_id < BLE_GATTS_EVT_LAST)) 48 | { 49 | evt_packet_size = ble_rpc_evt_gatts_encode(p_ble_evt, p_buffer); 50 | } 51 | else 52 | { 53 | // Do nothing. 54 | } 55 | 56 | if (evt_packet_size != 0) 57 | { 58 | err_code = hci_transport_pkt_write(p_buffer, evt_packet_size); 59 | APP_ERROR_CHECK(err_code); 60 | // @note: TX buffer must be freed upon TX done event from HCI Transport layer. The BLE 61 | // connectivity example project handles this in main.c. 62 | } 63 | else 64 | { 65 | // No event was encoded, therefore the buffer is freed immediately. 66 | err_code = hci_transport_tx_free(); 67 | APP_ERROR_CHECK(err_code); 68 | } 69 | } 70 | 71 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Source/gzp/nrf_gzp_host_nrf51.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is confidential property of Nordic 4 | * Semiconductor ASA.Terms and conditions of usage are described in detail 5 | * in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRENTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | * $LastChangedRevision: 133 $ 12 | */ 13 | 14 | 15 | #include "nrf_gzp.h" 16 | #include "nrf_nvmc.h" 17 | 18 | /** 19 | * @file 20 | * @brief Implementation of Gazell Pairing Library (gzp), nRF51 specific Host functions. 21 | * @defgroup gzp_source_host_nrf51 Gazell Pairing Host nRF51 specific implementation 22 | * @{ 23 | * @ingroup gzp_04_source 24 | */ 25 | 26 | 27 | void gzp_host_chip_id_read(uint8_t *dst, uint8_t n) 28 | { 29 | uint8_t i; 30 | uint8_t random_number; 31 | 32 | if( *((uint8_t*)(GZP_PARAMS_STORAGE_ADR + GZP_HOST_ID_LENGTH + 1)) == 0xff) 33 | { 34 | nrf_nvmc_write_byte((GZP_PARAMS_STORAGE_ADR + GZP_HOST_ID_LENGTH + 1) , 0x00); 35 | 36 | for(i = 0; i < n; i++) 37 | { 38 | gzp_random_numbers_generate(&random_number, 1); 39 | nrf_nvmc_write_byte((GZP_PARAMS_STORAGE_ADR + GZP_HOST_ID_LENGTH + 2 + i) , random_number); 40 | } 41 | } 42 | 43 | for(i = 0; i < n; i++) 44 | { 45 | *(dst++) = *((uint8_t*)(GZP_PARAMS_STORAGE_ADR + GZP_HOST_ID_LENGTH + 2 + i)); 46 | } 47 | } 48 | 49 | /** @} */ 50 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Source/nrf_assert/nrf_assert.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2006 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | #include "nrf_assert.h" 13 | 14 | #if defined(DEBUG_NRF) 15 | void assert_nrf_callback(uint16_t line_num, const uint8_t *file_name) 16 | { 17 | (void) file_name; /* Unused parameter */ 18 | (void) line_num; /* Unused parameter */ 19 | 20 | while (1) ; 21 | } 22 | #endif /* DEBUG_NRF */ 23 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Source/nrf_delay/nrf_delay.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #include 14 | #include "compiler_abstraction.h" 15 | #include "nrf.h" 16 | #include "nrf_delay.h" 17 | 18 | /*lint --e{438} "Variable not used" */ 19 | void nrf_delay_ms(uint32_t volatile number_of_ms) 20 | { 21 | while(number_of_ms != 0) 22 | { 23 | number_of_ms--; 24 | nrf_delay_us(999); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Source/nrf_ecb/nrf_ecb.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | * $LastChangedRevision: 25419 $ 12 | */ 13 | 14 | /** 15 | * @file 16 | * @brief Implementation of AES ECB driver 17 | */ 18 | 19 | 20 | //lint -e438 21 | 22 | #include 23 | #include 24 | #include 25 | #include "nrf.h" 26 | #include "nrf_ecb.h" 27 | 28 | static uint8_t ecb_data[48]; ///< ECB data structure for RNG peripheral to access. 29 | static uint8_t* ecb_key; ///< Key: Starts at ecb_data 30 | static uint8_t* ecb_cleartext; ///< Cleartext: Starts at ecb_data + 16 bytes. 31 | static uint8_t* ecb_ciphertext; ///< Ciphertext: Starts at ecb_data + 32 bytes. 32 | 33 | bool nrf_ecb_init(void) 34 | { 35 | ecb_key = ecb_data; 36 | ecb_cleartext = ecb_data + 16; 37 | ecb_ciphertext = ecb_data + 32; 38 | 39 | NRF_ECB->ECBDATAPTR = (uint32_t)ecb_data; 40 | return true; 41 | } 42 | 43 | 44 | bool nrf_ecb_crypt(uint8_t * dest_buf, const uint8_t * src_buf) 45 | { 46 | uint32_t counter = 0x1000000; 47 | if(src_buf != ecb_cleartext) 48 | { 49 | memcpy(ecb_cleartext,src_buf,16); 50 | } 51 | NRF_ECB->EVENTS_ENDECB = 0; 52 | NRF_ECB->TASKS_STARTECB = 1; 53 | while(NRF_ECB->EVENTS_ENDECB == 0) 54 | { 55 | counter--; 56 | if(counter == 0) 57 | { 58 | return false; 59 | } 60 | } 61 | NRF_ECB->EVENTS_ENDECB = 0; 62 | if(dest_buf != ecb_ciphertext) 63 | { 64 | memcpy(dest_buf,ecb_ciphertext,16); 65 | } 66 | return true; 67 | } 68 | 69 | void nrf_ecb_set_key(const uint8_t * key) 70 | { 71 | memcpy(ecb_key,key,16); 72 | } 73 | 74 | 75 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Source/templates/gcc/Makefile.windows: -------------------------------------------------------------------------------- 1 | ifeq ($(findstring 86, $(ProgramFiles)), ) 2 | PROGFILES := C:/Program Files 3 | else 4 | PROGFILES := C:/Program Files (x86) 5 | endif 6 | 7 | GNU_INSTALL_ROOT := $(PROGFILES)/GNU Tools ARM Embedded/4.7 2013q1 8 | GNU_VERSION := 4.7.3 9 | GNU_PREFIX := arm-none-eabi 10 | 11 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Source/templates/gcc/gcc_nrf51_blank_xxaa.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | SEARCH_DIR(.) 3 | GROUP(-lgcc -lc -lnosys) 4 | 5 | MEMORY 6 | { 7 | FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K 8 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 16K 9 | } 10 | 11 | INCLUDE "gcc_nrf51_common.ld" 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Source/templates/gcc/gcc_nrf51_blank_xxab.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | SEARCH_DIR(.) 3 | GROUP(-lgcc -lc -lnosys) 4 | 5 | MEMORY 6 | { 7 | FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 128K 8 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 16K 9 | } 10 | 11 | INCLUDE "gcc_nrf51_common.ld" 12 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Source/templates/gcc/gcc_nrf51_s110_xxaa.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | SEARCH_DIR(.) 3 | GROUP(-lgcc -lc -lnosys) 4 | 5 | MEMORY 6 | { 7 | FLASH (rx) : ORIGIN = 0x14000, LENGTH = 0x2C000 /* 80 kB is taken by S110, 176 kB available for application. */ 8 | RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x2000 /* 8 kB, 8 kB is taken by S110. */ 9 | } 10 | INCLUDE "gcc_nrf51_common.ld" 11 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Source/templates/gcc/gcc_nrf51_s110_xxab.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | SEARCH_DIR(.) 3 | GROUP(-lgcc -lc -lnosys) 4 | 5 | MEMORY 6 | { 7 | FLASH (rx) : ORIGIN = 0x14000, LENGTH = 0xC000 /* 80 kB is taken by S110, 48 kB available for application. */ 8 | RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x2000 /* 8 kB, 8 kB is taken by S110. */ 9 | } 10 | INCLUDE "gcc_nrf51_common.ld" 11 | -------------------------------------------------------------------------------- /bootloader/nrf51822/Source/templates/gcc/gcc_nrf51_s210_xxaa.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | SEARCH_DIR(.) 3 | GROUP(-lgcc -lc -lnosys) 4 | 5 | MEMORY 6 | { 7 | FLASH (rx) : ORIGIN = 0x0000A000, LENGTH = 216K 8 | RAM (rwx) : ORIGIN = 0x20000800, LENGTH = 14K 9 | } 10 | INCLUDE "gcc_nrf51_common.ld" 11 | -------------------------------------------------------------------------------- /bootloader/project/JLinkSettings.ini: -------------------------------------------------------------------------------- 1 | [BREAKPOINTS] 2 | ShowInfoWin = 1 3 | EnableFlashBP = 2 4 | BPDuringExecution = 0 5 | [CFI] 6 | CFISize = 0x00 7 | CFIAddr = 0x00 8 | [CPU] 9 | OverrideMemMap = 0 10 | AllowSimulation = 0 11 | ScriptFile="" 12 | [FLASH] 13 | CacheExcludeSize = 0x00 14 | CacheExcludeAddr = 0x00 15 | MinNumBytesFlashDL = 0 16 | SkipProgOnCRCMatch = 1 17 | VerifyDownload = 1 18 | AllowCaching = 0 19 | EnableFlashDL = 2 20 | Override = 0 21 | Device="UNSPECIFIED" 22 | [GENERAL] 23 | WorkRAMSize = 0x00 24 | WorkRAMAddr = 0x00 25 | RAMUsageLimit = 0x00 26 | [SWO] 27 | SWOLogFile="" 28 | [MEM] 29 | RdOverrideOrMask = 0x00 30 | RdOverrideAndMask = 0xFFFFFFFF 31 | RdOverrideAddr = 0xFFFFFFFF 32 | WrOverrideOrMask = 0x00 33 | WrOverrideAndMask = 0xFFFFFFFF 34 | WrOverrideAddr = 0xFFFFFFFF 35 | -------------------------------------------------------------------------------- /doc/nRF51822_Developer_Kit_User_Guide v1.2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/doc/nRF51822_Developer_Kit_User_Guide v1.2.pdf -------------------------------------------------------------------------------- /doc/手环硬件资料/手环硬件资料/SCH_PCB.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/doc/手环硬件资料/手环硬件资料/SCH_PCB.pdf -------------------------------------------------------------------------------- /doc/手环硬件资料/手环硬件资料/参考设计BOM.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/doc/手环硬件资料/手环硬件资料/参考设计BOM.xls -------------------------------------------------------------------------------- /doc/手环硬件资料/手环硬件资料/手环版图源文件V6.DDB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/doc/手环硬件资料/手环硬件资料/手环版图源文件V6.DDB -------------------------------------------------------------------------------- /doc/手环硬件资料/手环硬件资料/芯片手册/AS1130_Datasheet_EN_v5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/doc/手环硬件资料/手环硬件资料/芯片手册/AS1130_Datasheet_EN_v5.pdf -------------------------------------------------------------------------------- /doc/手环硬件资料/手环硬件资料/芯片手册/BAL-NR_datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/doc/手环硬件资料/手环硬件资料/芯片手册/BAL-NR_datasheet.pdf -------------------------------------------------------------------------------- /doc/手环硬件资料/手环硬件资料/芯片手册/LIS3DH.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/doc/手环硬件资料/手环硬件资料/芯片手册/LIS3DH.pdf -------------------------------------------------------------------------------- /doc/手环硬件资料/手环硬件资料/芯片手册/S8211C_C.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/doc/手环硬件资料/手环硬件资料/芯片手册/S8211C_C.pdf -------------------------------------------------------------------------------- /doc/手环硬件资料/手环硬件资料/芯片手册/bq24040.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/doc/手环硬件资料/手环硬件资料/芯片手册/bq24040.pdf -------------------------------------------------------------------------------- /doc/手环硬件资料/手环硬件资料/芯片手册/drv2605.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/doc/手环硬件资料/手环硬件资料/芯片手册/drv2605.pdf -------------------------------------------------------------------------------- /doc/手环硬件资料/手环硬件资料/芯片手册/nRF51 Series Reference manual v2.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/doc/手环硬件资料/手环硬件资料/芯片手册/nRF51 Series Reference manual v2.0.pdf -------------------------------------------------------------------------------- /doc/手环硬件资料/手环硬件资料/芯片手册/nRF51822 PS v1 3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/doc/手环硬件资料/手环硬件资料/芯片手册/nRF51822 PS v1 3.pdf -------------------------------------------------------------------------------- /doc/手环硬件资料/手环硬件资料/芯片手册/tps3898.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/doc/手环硬件资料/手环硬件资料/芯片手册/tps3898.pdf -------------------------------------------------------------------------------- /doc/手环硬件资料/手环硬件资料/芯片手册/tps62260.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/doc/手环硬件资料/手环硬件资料/芯片手册/tps62260.pdf -------------------------------------------------------------------------------- /wrist-rom-open/Source/algorithm_inc/click-algorithm.h: -------------------------------------------------------------------------------- 1 | #ifndef _HEALTH_ALGORITHM_INNER_H_ 2 | #define _HEALTH_ALGORITHM_INNER_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | typedef struct click_event { 9 | long long click_time; 10 | #ifdef CLICK_TEST_MODE 11 | char is_valid; 12 | #endif // CLICK_TEST_MODE 13 | } click_event_t; 14 | 15 | 16 | typedef void(*click_algorithm_cb)(click_event_t *event, void* user_data); 17 | 18 | int init_click_algorithm(int sample_rate); 19 | int click_algorithm_finalize(void); 20 | int register_click_algorithm_callback(click_algorithm_cb cb, void *user_data); 21 | int click_algorithm_accelerate_data_in(short int x, short int y, short int z, int compose, long long timestamp); 22 | const char * click_algorithm_error_desc(void); 23 | int generate_click_event(click_event_t *event); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/bd_bluetooth_log.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #ifndef _BD_BLUETOOTH_LOG_H_ 26 | #define _BD_BLUETOOTH_LOG_H_ 27 | #include "bd_communicate_protocol.h" 28 | 29 | void bluetooth_log(const char * func, uint32_t line, const char * restrict format, ...); 30 | 31 | #define BLUETOOTH_LOG(format, ...) bluetooth_log(__func__, __LINE__, format, ##__VA_ARGS__); 32 | 33 | void resolve_log_command_id(log_command_key_t key); 34 | void set_bluetooth_log_state(bool state); 35 | bool get_bluetooth_log_state(void); 36 | 37 | #endif //_BD_BLUETOOTH_LOG_H_ 38 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/bd_buzzer.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | 26 | #ifndef BUZZER_H__ 27 | #define BUZZER_H__ 28 | 29 | 30 | /**@brief Function to start flashing the LED. 31 | * @details This will start the TIMER1 and enable the GPIOTE task that toggles the LED. 32 | * The PPI and GPIOTE configurations done by this app will make this action result in the 33 | * flashing of the LED. 34 | * @pre Can only be called after the SoftDevice is enabled - uses nrf_soc API 35 | */ 36 | void buzzer_start(void); 37 | 38 | /**@brief Function to stop flashing the LED. 39 | * @details This will stop the TIMER1 and disable the GPIOTE task that toggles the LED. 40 | * The PPI and GPIOTE configurations done by this app will 41 | * make this action result in the turning off the LED. 42 | */ 43 | void buzzer_stop(void); 44 | 45 | #endif // buzzer_H__ 46 | 47 | /** @} */ 48 | /** @endcond */ 49 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/bd_charging.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #include 26 | #include "board_config_pins.h" 27 | /************************************************************************** 28 | * Charging state defination 29 | ***************************************************************************/ 30 | typedef enum { 31 | InCharging = 0, /* Device connect to the plugs*/ 32 | ChargingComplete, /* Show charging complete & still connect to plugs*/ 33 | NoCharge /* Show not connect to plugs*/ 34 | }Charging_State; 35 | 36 | void charger_init(void); 37 | void charger_framework_init(void); 38 | Charging_State charger_status(void); 39 | uint8_t charger_connected(void); 40 | 41 | void update_charging_status(uint8_t refresh); 42 | uint8_t get_battery_voltage_adjustment(void); 43 | void function_charger_event_handler(uint8_t pin_no); 44 | void function_chargingcomplete_event_handler(uint8_t pin_no); 45 | 46 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/bd_communicate_protocol.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/wrist-rom-open/Source/inc/bd_communicate_protocol.h -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/bd_crc16.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #ifndef __CRC16_H 26 | #define __CRC16_H 27 | #include 28 | 29 | 30 | extern uint16_t const crc16_table[256]; 31 | 32 | extern uint16_t bd_crc16(uint16_t crc, const uint8_t *buffer, uint16_t len); 33 | 34 | #endif /* __CRC16_H */ 35 | 36 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/bd_factory_test.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #ifndef BD_FACTORY_TEST__ 26 | #define BD_FACTORY_TEST__ 27 | 28 | #include "board_config_pins.h" 29 | #include 30 | 31 | #define LED_SENSOR_TEST_RESULT BAIDU_LED_3 32 | 33 | #define GRAVITY_VALUE (8192) 34 | #define MIN_SENSOR_VALUE ((GRAVITY_VALUE - 819)*(GRAVITY_VALUE - 819)) 35 | #define MAX_SENSOR_VALUE ((GRAVITY_VALUE + 819)*(GRAVITY_VALUE + 819)) 36 | 37 | 38 | #define FACTORY_TEST_FLAG_OFF (8) 39 | #define SERIAL_NUMBER_LENGTH (32) 40 | 41 | 42 | void bootup_check(void); 43 | void do_test(uint8_t *data, uint16_t length); 44 | uint8_t is_factory_test_done(void); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/bd_input_event_source.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #ifndef _INPUT_EVENT_SOURCE_H_ 26 | #define _INPUT_EVENT_SOURCE_H_ 27 | 28 | #include 29 | #include "config.h" 30 | 31 | #define THREE_SECOND_INTERVAL APP_TIMER_TICKS(2000, APP_TIMER_PRESCALER) /**< long press timer delay . */ 32 | #define SHORT_PRESS_DELAY APP_TIMER_TICKS(500, APP_TIMER_PRESCALER) 33 | 34 | /* enum defination */ 35 | typedef enum { 36 | NO_PRESS = 0, 37 | SHORT_PRESS, 38 | LONG_PRESS 39 | }PressType; 40 | 41 | /***************************************************************** 42 | * control input action 43 | ******************************************************************/ 44 | typedef enum { 45 | INPUT_ACCEPT_BOND = 1, 46 | INPUT_CANCEL_PHONE_CALL = 2, 47 | INPUT_CANCEL_ALARM = 3, 48 | INPUT_SHOW_STEP_COUNT = 4, 49 | INPUT_SWAP_SLEEP_MODE = 5, 50 | INPUT_DEFAULT_MODE = 0xFF, //default mode for input action flags 51 | }InputAction; 52 | 53 | #ifdef HAS_BUTTON 54 | /* button identifier timer hanler*/ 55 | void btn_timeout_handler(void * p_context); 56 | #endif 57 | /* button event handler*/ 58 | void function_button_event_handler(uint8_t pin_no); 59 | 60 | void input_event_handle_schedule(void * p_event_data, uint16_t event_size); 61 | 62 | //input task register 63 | //extern InputAction global_short_press_action ; 64 | //extern InputAction global_long_press_action ; 65 | 66 | //void reset_short_press_action_SM(InputAction currentAction); 67 | #endif //_INPUT_EVENT_SOURCE_H_ 68 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/bd_interaction.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #ifndef _INTERACTION_ 26 | #define _INTERACTION_ 27 | 28 | #include "stdint.h" 29 | #include "config.h" 30 | 31 | #define NOTIFICATION_DEBUG 0 32 | #define NOTIFICATION_BONDING 1 33 | #define NOTIFICATION_BONDED 2 34 | #define NOTIFICATION_TEST 3 35 | #define NOTIFICATION_CHARGING 4 36 | #define NOTIFICATION_CALLING 5 37 | #define NOTIFICATION_ALARM 6 38 | #define NOTIFICATION_LOSE 7 39 | #define NOTIFICATION_SWITCH 8 40 | #define NOTIFICATION_TARGET 9 41 | #define NOTIFICATION_STATE 10 42 | 43 | #define NOTIFICATION_ANIMATE 11 44 | 45 | 46 | 47 | // typedef enum { 48 | // Bonding = 0, 49 | // Charging, 50 | // Calling, 51 | // Alarm, 52 | // Counter, 53 | // Sleep, 54 | // Unknown 55 | // }Notification_Status; 56 | 57 | void notification_start( uint8_t type, uint16_t value ); 58 | void notification_stop( void ); 59 | 60 | #endif //_INTERACTION_ 61 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/bd_interrupt_notify.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/wrist-rom-open/Source/inc/bd_interrupt_notify.h -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/bd_led_flash.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/wrist-rom-open/Source/inc/bd_led_flash.h -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/bd_level_drive_motor.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #ifndef _BD_LEVEL_DRIVE_MOTOR_H_ 26 | #define _BD_LEVEL_DRIVE_MOTOR_H_ 27 | 28 | #include 29 | 30 | typedef enum { 31 | VIBRATE_NONE = 0, 32 | FAST_VIBRATE = 1, 33 | SLOW_VIBRATE = 2 34 | }MOTOR_ACTION; 35 | 36 | 37 | typedef enum { 38 | VIBRATE = 0, 39 | SLIENT = 1 40 | }MOTOR_OP; 41 | 42 | void motor_init(void); 43 | 44 | uint32_t motor_control_framework_init(void); 45 | 46 | void motor_action_control_start(MOTOR_ACTION action, uint16_t virbrate_times); 47 | 48 | void motor_action_control_stop(void ); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/bd_low_power_mode.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #ifndef _LOW_POWER_MODE_H_ 26 | #define _LOW_POWER_MODE_H_ 27 | 28 | void power_wfi(void); 29 | void power_system_off(void); 30 | void sd_system_off(void); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/bd_private_bond.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #ifndef _PRIVATE_BOND_H_ 26 | #define _PRIVATE_BOND_H_ 27 | #include 28 | #include "config.h" 29 | 30 | #define USER_ID_LENGTH (32) 31 | 32 | #define FLASH_PAGE_USER_ID FLASH_PAGE_PRIVATE_BOND 33 | 34 | 35 | uint32_t bond_read_user_id(void); 36 | uint32_t bond_store_user_id(void); 37 | 38 | void bond_press_handle(void ); 39 | void bond_success_event_dispatch(void); 40 | void bond_fail_event_dispatch(void); 41 | uint32_t check_user_id_bonded(const uint8_t* user_id, uint8_t length); 42 | 43 | void login_success_event_dispatch(void); 44 | void login_fail_event_dispatch(void); 45 | bool check_has_bonded(void); 46 | void set_device_has_bonded(bool value); 47 | 48 | #endif //_PRIVATE_BOND_H_ 49 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/bd_square_root.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #ifndef _BD_SQUARE_ROOT_H_ 26 | #define _BD_SQUARE_ROOT_H_ 27 | 28 | #include "stdint.h" 29 | 30 | uint32_t SquareRoot(uint32_t a_nInput); 31 | 32 | #endif //_BD_SQUARE_ROOT_H_ 33 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/bd_stack_dump_repoter.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #include 26 | 27 | void get_stack_dump_command_resolve(uint8_t key); 28 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/bd_switch_sleep.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #ifndef _BD_SWITCH_SLEEP_H_ 26 | #define _BD_SWITCH_SLEEP_H_ 27 | #include 28 | #include 29 | #include "step_counter.h" 30 | #define SETTING_SLEEP_MODE 0 31 | #define SETTING_STEP_MODE 1 32 | /** 33 | * handle 2 Double-click event, switch between normal mode and sleeping mode 34 | * 35 | * 36 | * @note 37 | * 38 | * @param spi_base_address register base address of the selected SPI master module 39 | * @param transfer_size number of bytes to transmit/receive over SPI master 40 | * @param tx_data pointer to the data that needs to be transmitted 41 | * @param rx_data pointer to the data that needs to be received 42 | * @return 43 | * @retval true if transmit/reveive of transfer_size were completed. 44 | * @retval false if transmit/reveive of transfer_size were not complete and tx_data/rx_data points to invalid data. 45 | */ 46 | void reset_sleep_setting(void); 47 | 48 | SleepData_U * get_last_sleep_setting_event(void); 49 | SleepHead_t * get_last_sleep_setting_event_head(void); 50 | void send_last_time_sleep_mode(void); 51 | 52 | void two_Double_tap_handle(void); 53 | void update_sleep_status(void); 54 | 55 | void restore_SleepSettingsFromFlash(void); 56 | bool save_sleep_settings_to_flash(void); 57 | void update_sleep_setting_head(void); 58 | void reset_sleep_setting_head(void); 59 | void set_curr_sleep_flag(bool sleeping); 60 | bool get_curr_sleep_flag(void); 61 | uint16_t sleep_setting_count(void); 62 | bool save_sleep_settings_to_flash(void); 63 | bool send_sleep_setting_data(void); 64 | void send_sleep_setting_data_cb(void); 65 | #endif 66 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/bd_wdt.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #ifndef BD_WDT_H 26 | #define DB_WDT_H 27 | 28 | void wdt_start(void); 29 | void wdt_stop(void); 30 | void wdt_feed(void); 31 | void wdt_init(void); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/bd_work_state.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #ifndef WORK_STATE_H__ 26 | #define WORK_STATE_H__ 27 | 28 | /************************************************************************** 29 | * Defines the main status 30 | ***************************************************************************/ 31 | typedef enum { 32 | LOW_POWER = 0, 33 | ADVERTISING, 34 | BINDING, 35 | NORMAL, 36 | CHARGING, 37 | NOTIFYING, 38 | CAMERA 39 | } WORK_STATE; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/ble_bondmngr_cfg.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | 26 | #ifndef BLE_BONDMNGR_CFG_H__ 27 | #define BLE_BONDMNGR_CFG_H__ 28 | 29 | /**@brief Number of CCCDs used in the current application. */ 30 | #define BLE_BONDMNGR_CCCD_COUNT 1 /* */ 31 | 32 | /**@brief Maximum number of bonded masters. */ 33 | #define BLE_BONDMNGR_MAX_BONDED_MASTERS 3 34 | 35 | #endif // BLE_BONDMNGR_CFG_H__ 36 | 37 | /** @} */ 38 | /** @endcond */ 39 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/board_config_pins.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #ifndef BOARD_CONFIG_PINS_H__ 26 | #define BOARD_CONFIG_PINS_H__ 27 | 28 | #include "config.h" 29 | 30 | #ifdef USE_DVK_6310 31 | 32 | #include "dvk6310_board_config_pins.h" 33 | 34 | #elif defined (WX1000) 35 | 36 | #include "wx1000_board_config_pins.h" 37 | 38 | #endif //USE_DVK_6310 39 | 40 | #define TWI_SDA_STANDARD0_DISCONNECT() do { \ 41 | NRF_GPIO->PIN_CNF[TWI_MASTER_CONFIG_DATA_PIN_NUMBER] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \ 42 | |(GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) \ 43 | |(GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) \ 44 | |(GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos) \ 45 | |(GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos); \ 46 | } while (0) /*!< Configures SDA pin to Standard-0, No-drive 1 */ 47 | 48 | 49 | #define TWI_SCL_STANDARD0_DISCONNECT() do { \ 50 | NRF_GPIO->PIN_CNF[TWI_MASTER_CONFIG_CLOCK_PIN_NUMBER] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \ 51 | |(GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) \ 52 | |(GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) \ 53 | |(GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos) \ 54 | |(GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos); \ 55 | } while (0) /*!< Configures SCL pin to Standard-0, No-drive 1 */ 56 | 57 | #endif // BOARD_CONFIG_PINS_H__ 58 | 59 | /** @} */ 60 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/hal_acc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #ifndef HAL_ACC_H 26 | #define HAL_ACC_H 27 | 28 | #include "bd_lis3dh_driver.h" 29 | #define LIS3DH_ODR_FREQ LIS3DH_ODR_100Hz 30 | #define ACC_UNIT 0.031 31 | #define TAP_TIME_UNIT 32 | #define TAP_TIME_LIMIT 3 33 | #define TAP_LATENCY 14 34 | #define TAP_WINDOW 30 35 | #define TAP_THRESHOLD 1.5/ACC_UNIT 36 | 37 | void hal_acc_init(void); 38 | void hal_acc_PowerDown(void); 39 | void hal_acc_enable(void); 40 | bool hal_acc_ConfigClick(LIS3DH_ODR_t Freq, LIS3DH_Fullscale_t FullScale); 41 | void hal_acc_GetFifoData(uint8_t * val); 42 | void hal_acc_config_wake_int(bool enable); 43 | void hal_acc_config_Dtap(bool enable); 44 | void hal_acc_reset(void); 45 | /*lint --flb "Leave library region" */ 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/inc/hal_vibrate.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #ifndef _HAL_VIBRATE_H__ 26 | #define _HAL_VIBRATE_H__ 27 | void hal_vibrate_init(void); 28 | void hal_vibrate_once(int idx,int wait); 29 | #endif //_HAL_VIBRATE_H__ 30 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/libs/AlgorithmLibFornrf51.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/wrist-rom-open/Source/libs/AlgorithmLibFornrf51.lib -------------------------------------------------------------------------------- /wrist-rom-open/Source/src/bd_charging.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/wrist-rom-open/Source/src/bd_charging.c -------------------------------------------------------------------------------- /wrist-rom-open/Source/src/bd_communicate_protocol.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/wrist-rom-open/Source/src/bd_communicate_protocol.c -------------------------------------------------------------------------------- /wrist-rom-open/Source/src/bd_hal_vibrate.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #include "board_config_pins.h" 26 | 27 | #ifdef FEATURE_MOTOR_LRA 28 | #include "drv2605.h" 29 | void hal_vibrate_init() 30 | { 31 | drv260x_init(); 32 | } 33 | void hal_vibrate_once(int idx,int wait) 34 | { 35 | drv260x_vib(idx,wait); 36 | } 37 | #endif //FEATURE_MOTOR_LRA 38 | 39 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/src/bd_interaction.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/wrist-rom-open/Source/src/bd_interaction.c -------------------------------------------------------------------------------- /wrist-rom-open/Source/src/bd_led_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/wrist-rom-open/Source/src/bd_led_flash.c -------------------------------------------------------------------------------- /wrist-rom-open/Source/src/bd_nrf_delay.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | 26 | #include "compiler_abstraction.h" 27 | #include "nrf.h" 28 | #include "nrf_delay.h" 29 | 30 | /*lint --e{438} "Variable not used" */ 31 | void nrf_delay_ms(uint32_t volatile number_of_ms) 32 | { 33 | while(number_of_ms != 0) { 34 | number_of_ms--; 35 | nrf_delay_us(999); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/src/bd_square_root.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #include "bd_square_root.h" 26 | 27 | uint32_t SquareRoot(uint32_t a_nInput) 28 | { 29 | uint32_t op = a_nInput; 30 | uint32_t res = 0; 31 | uint32_t one = 1uL << 30; // The second-to-top bit is set: use 1u << 14 for uint16_t type; use 1uL<<30 for uint32_t type 32 | 33 | 34 | // "one" starts at the highest power of four <= than the argument. 35 | while (one > op) { 36 | one >>= 2; 37 | } 38 | 39 | while (one != 0) { 40 | if (op >= res + one) { 41 | op = op - (res + one); 42 | res = res + 2 * one; 43 | } 44 | res >>= 1; 45 | one >>= 2; 46 | } 47 | return res; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /wrist-rom-open/Source/src/bd_wdt.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) [2014 Baidu]. All Rights Reserved. 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | * 14 | * File Name : 15 | * Author : 16 | * Version : $Revision:$ 17 | * Date : $Date:$ 18 | * Description : 19 | * 20 | * HISTORY: 21 | * Date | Modification | Author 22 | * 28/03/2014 | Initial Revision | 23 | 24 | */ 25 | #include "nrf51.h" 26 | #include "nrf51_bitfields.h" 27 | 28 | #define RELOAD_COUNT (32768*60*3-1) //3 minutes 29 | 30 | void wdt_init(void) 31 | { 32 | NRF_WDT->TASKS_START = 0; 33 | NRF_WDT->CRV = RELOAD_COUNT; 34 | NRF_WDT->CONFIG = 35 | WDT_CONFIG_HALT_Pause << WDT_CONFIG_HALT_Pos | 36 | WDT_CONFIG_SLEEP_Pause << WDT_CONFIG_SLEEP_Pos; 37 | NRF_WDT->RREN = WDT_RREN_RR0_Enabled << WDT_RREN_RR0_Pos; 38 | } 39 | 40 | void wdt_start(void) 41 | { 42 | NRF_WDT->TASKS_START = 1; 43 | } 44 | 45 | void wdt_feed(void) 46 | { 47 | if(NRF_WDT->RUNSTATUS & WDT_RUNSTATUS_RUNSTATUS_Msk) 48 | NRF_WDT->RR[0] = WDT_RR_RR_Reload; 49 | } 50 | 51 | void wdt_stop(void) 52 | { 53 | NRF_WDT->TASKS_START = 0; 54 | } 55 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/app_common/crc16.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup crc_compute CRC compute 16 | * @{ 17 | * @ingroup hci_transport 18 | * 19 | * @brief This module implements the CRC-16 calculation in the blocks. 20 | */ 21 | 22 | #ifndef CRC16_H__ 23 | #define CRC16_H__ 24 | 25 | #include 26 | 27 | /**@brief Function for calculating CRC-16 in blocks. 28 | * 29 | * Feed each consecutive data block into this function, along with the current value of p_crc as 30 | * returned by the previous call of this function. The first call of this function should pass NULL 31 | * as the initial value of the crc in p_crc. 32 | * 33 | * @param[in] p_data The input data block for computation. 34 | * @param[in] size The size of the input data block in bytes. 35 | * @param[in] p_crc The previous calculated CRC-16 value or NULL if first call. 36 | * 37 | * @return The updated CRC-16 value, based on the input supplied. 38 | */ 39 | uint16_t crc16_compute(const uint8_t * p_data, uint32_t size, const uint16_t * p_crc); 40 | 41 | #endif // CRC16_H__ 42 | 43 | /** @} */ 44 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/app_common/hci_mem_pool_internal.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup memory_pool_internal Memory Pool Internal 16 | * @{ 17 | * @ingroup memory_pool 18 | * 19 | * @brief Memory pool internal definitions 20 | */ 21 | 22 | #ifndef MEM_POOL_INTERNAL_H__ 23 | #define MEM_POOL_INTERNAL_H__ 24 | 25 | #define TX_BUF_SIZE 600u /**< TX buffer size in bytes. */ 26 | #define RX_BUF_SIZE TX_BUF_SIZE /**< RX buffer size in bytes. */ 27 | 28 | #endif // MEM_POOL_INTERNAL_H__ 29 | 30 | /** @} */ 31 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/ble_date_time.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/wrist-rom-open/nrf51822/Include/ble/ble_date_time.h -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/ble_eval_board_pins.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_sdk_lib_eval_board_pins Evaluation Board LEDs and Buttons Pin Assignments 16 | * @{ 17 | * @ingroup ble_sdk_lib 18 | * @brief Pin assignments for LEDs and Buttons on the evaluation board 19 | * 20 | * @details Pin assignments for LEDs and Buttons in evaluation board applications. 21 | */ 22 | 23 | #ifndef BLE_EVAL_BOARD_PINS_H__ 24 | #define BLE_EVAL_BOARD_PINS_H__ 25 | 26 | #define EVAL_BOARD_LED_0 18 /**< Pin connected to LED 0 in the pca10001 evaluation board.*/ 27 | #define EVAL_BOARD_LED_1 19 /**< Pin connected to LED 1 in the pca10001 evaluation board.*/ 28 | 29 | #define EVAL_BOARD_BUTTON_0 16 /**< Pin connected to BUTTON 0 in the pca10001 evaluation board.*/ 30 | #define EVAL_BOARD_BUTTON_1 17 /**< Pin connected to BUTTON 1 in the pca10001 evaluation board.*/ 31 | 32 | #define ADVERTISING_LED_PIN_NO EVAL_BOARD_LED_0 /**< Pin that can be used by applications to indicate advertising state.*/ 33 | #define CONNECTED_LED_PIN_NO EVAL_BOARD_LED_1 /**< Pin that can be used by applications to indicate connected state.*/ 34 | 35 | #endif // BLE_EVAL_BOARD_PINS_H__ 36 | 37 | /** @} */ 38 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/ble_sensorsim.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_sdk_lib_sensorsim Sensor Data Simulator 16 | * @{ 17 | * @ingroup ble_sdk_lib 18 | * @brief Functions for simulating sensor data. 19 | * 20 | * @details Currently only a triangular waveform simulator is implemented. 21 | */ 22 | 23 | #ifndef BLE_SENSORSIM_H__ 24 | #define BLE_SENSORSIM_H__ 25 | 26 | #include 27 | #include 28 | 29 | /**@brief Triangular waveform sensor simulator configuration. */ 30 | typedef struct 31 | { 32 | uint32_t min; /**< Minimum simulated value. */ 33 | uint32_t max; /**< Maximum simulated value. */ 34 | uint32_t incr; /**< Increment between each measurement. */ 35 | bool start_at_max; /**< TRUE is measurement is to start at the maximum value, FALSE if it is to start at the minimum. */ 36 | } ble_sensorsim_cfg_t; 37 | 38 | /**@brief Triangular waveform sensor simulator state. */ 39 | typedef struct 40 | { 41 | uint32_t current_val; /**< Current sensor value. */ 42 | bool is_increasing; /**< TRUE if the simulator is in increasing state, FALSE otherwise. */ 43 | } ble_sensorsim_state_t; 44 | 45 | /**@brief Function for initializing a triangular waveform sensor simulator. 46 | * 47 | * @param[out] p_state Current state of simulator. 48 | * @param[in] p_cfg Simulator configuration. 49 | */ 50 | void ble_sensorsim_init(ble_sensorsim_state_t * p_state, 51 | const ble_sensorsim_cfg_t * p_cfg); 52 | 53 | /**@brief Function for generating a simulated sensor measurement using a triangular waveform generator. 54 | * 55 | * @param[in,out] p_state Current state of simulator. 56 | * @param[in] p_cfg Simulator configuration. 57 | * 58 | * @return Simulator output. 59 | */ 60 | uint32_t ble_sensorsim_measure(ble_sensorsim_state_t * p_state, 61 | const ble_sensorsim_cfg_t * p_cfg); 62 | 63 | #endif // BLE_SENSORSIM_H__ 64 | 65 | /** @} */ 66 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/ble_services/ble_sc_ctrlpt.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/wrist-rom-open/nrf51822/Include/ble/ble_services/ble_sc_ctrlpt.h -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/ble_services/ble_sensor_location.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/wrist-rom-open/nrf51822/Include/ble/ble_services/ble_sensor_location.h -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/rpc/ble_rpc_cmd_decoder_gap.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_rpc_cmd_decoder_gap GAP Command Decoder 16 | * @{ 17 | * @ingroup ble_sdk_lib_serialization 18 | * 19 | * @brief Decoder for serialized GAP commands from Application Chip. 20 | * 21 | * @details This file contains the declaration of the function that decodes the serialized GAP 22 | * commands from Application Chip and calls the appropriate BLE stack API. 23 | */ 24 | 25 | #ifndef BLE_RPC_CMD_DECODER_GAP_H__ 26 | #define BLE_RPC_CMD_DECODER_GAP_H__ 27 | 28 | #include 29 | 30 | /**@brief Function for processing the encoded GAP command from Application Chip. 31 | * 32 | * @details This function will decode the encoded command and call the appropriate BLE Stack 33 | * API. It will then create a Command Response packet with the return value from the 34 | * stack API encoded in it and will send it to the transport layer for transmission to 35 | * the application controller chip. 36 | 37 | * @param[in] p_command The encoded command. 38 | * @param[in] op_code Operation code of the command. 39 | * @param[in] command_len Length of the encoded command. 40 | * 41 | * @retval NRF_SUCCESS If the decoding of the command was successful, the soft device API 42 | * was called, and the command response was sent to peer, otherwise an 43 | * error code. 44 | * If the transport layer returns an error code while sending 45 | * the Command Response, the same error code will be returned by this 46 | * function (see @ref hci_transport_pkt_write for the list of 47 | * error codes). 48 | */ 49 | uint32_t ble_rpc_cmd_gap_decode(uint8_t * p_command, uint8_t op_code, uint32_t command_len); 50 | 51 | #endif // BLE_RPC_CMD_DECODER_GAP_H__ 52 | 53 | /** @} */ 54 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/rpc/ble_rpc_cmd_decoder_gatts.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_rpc_cmd_decoder_gatts GATTS Command Decoder 16 | * @{ 17 | * @ingroup ble_sdk_lib_serialization 18 | * 19 | * @brief Decoder for serialized GATTS commands from Application Chip. 20 | * 21 | * @details This file contains the declaration of the function that decodes the serialized GATTS 22 | * commands from Application Chip and calls the appropriate BLE stack API. 23 | */ 24 | 25 | #ifndef BLE_RPC_CMD_DECODER_GATTS_H__ 26 | #define BLE_RPC_CMD_DECODER_GATTS_H__ 27 | 28 | #include 29 | 30 | /**@brief Function for processing the encoded GATTS command from application chip. 31 | * 32 | * @details This function will decode the encoded command and call the appropriate BLE Stack 33 | * API. It will then create a Command Response packet with the return value from the 34 | * stack API encoded in it and will send it to the transport layer for transmission to 35 | * the application controller chip. 36 | 37 | * @param[in] p_command The encoded command. 38 | * @param[in] op_code Operation code of the command. 39 | * @param[in] command_len Length of the encoded command. 40 | * 41 | * @retval NRF_SUCCESS If the decoding of the command was successful, the soft device API 42 | * was called, and the command response was sent to peer, otherwise an 43 | * error code. 44 | * If the transport layer returns an error code while sending 45 | * the Command Response, the same error code will be returned by this 46 | * function (see @ref hci_transport_pkt_write for the list of 47 | * error codes). 48 | */ 49 | uint32_t ble_rpc_cmd_gatts_decode(uint8_t * p_command, uint8_t op_code, uint32_t command_len); 50 | 51 | #endif // BLE_RPC_CMD_DECODER_GATTS_H__ 52 | 53 | /** @} */ 54 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/rpc/ble_rpc_event_decoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_rpc_evt_decoder Event Decoder 16 | * @{ 17 | * @ingroup ble_sdk_lib_serialization 18 | * 19 | * @brief Decoder for serialized events from nRF51822. 20 | * 21 | * @details This file contains the declaration of the function that initializes the event decoder 22 | * module and processes received events. 23 | */ 24 | 25 | #ifndef BLE_RPC_EVT_DECODER_H__ 26 | #define BLE_RPC_EVT_DECODER_H__ 27 | 28 | #include 29 | 30 | #ifndef SVCALL_AS_NORMAL_FUNCTION 31 | #error "The compiler define SVCALL_AS_NORMAL_FUNCTION is not defined." 32 | #endif 33 | 34 | 35 | /**@brief Function for pushing an encoded packet in the event decoder. 36 | * 37 | * @warning This function is not reentrant safe and should always be called from same interrupt 38 | * context. 39 | * 40 | * @param[in] p_event_packet Pointer to the encoded event received. 41 | * @param[in] event_packet_length Length of received packet. 42 | * 43 | * @retval NRF_SUCCESS Upon success. 44 | * @retval NRF_ERROR_NO_MEM Upon receive queue full. 45 | */ 46 | uint32_t ble_rpc_event_pkt_received(uint8_t * p_event_packet, uint16_t event_packet_length); 47 | 48 | #endif // BLE_RPC_EVT_DECODER_H__ 49 | 50 | /** @} **/ 51 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/rpc/ble_rpc_event_decoder_gap.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_rpc_evt_decoder_gap GAP Event Decoder 16 | * @{ 17 | * @ingroup ble_sdk_lib_serialization 18 | * 19 | * @brief Decoder for serialized GAP events from nRF51822. 20 | * 21 | * @details This file contains declarations of functions used for decoding GAP event packets 22 | * received from the Connectivity Chip. 23 | * 24 | */ 25 | 26 | #ifndef BLE_RPC_EVENT_DECODER_GAP_H__ 27 | #define BLE_RPC_EVENT_DECODER_GAP_H__ 28 | 29 | #include 30 | #include "ble.h" 31 | 32 | /** @brief Function for decoding the length of a BLE GAP event. 33 | * 34 | * @param[in] event_id Event Id for the event to length decode. 35 | * @param[out] p_event_length The pointer for storing the decoded event length. 36 | */ 37 | void ble_rpc_gap_evt_length_decode(uint8_t event_id, uint16_t * p_event_length); 38 | 39 | /** @brief Function for decoding a BLE GAP event. 40 | * 41 | * @param[out] p_ble_evt The pointer for storing the decoded event. 42 | * @param[in] p_packet The pointer to the encoded event. 43 | */ 44 | void ble_rpc_gap_evt_packet_decode(ble_evt_t * p_ble_evt, 45 | uint8_t const * const p_packet); 46 | 47 | #endif // BLE_RPC_EVENT_DECODER_GAP_H__ 48 | 49 | /** @} **/ 50 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/rpc/ble_rpc_event_decoder_gatts.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_rpc_evt_decoder_gatts GATTS Event Decoder 16 | * @{ 17 | * @ingroup ble_sdk_lib_serialization 18 | * 19 | * @brief Decoder for serialized GATT Server events from nRF51822. 20 | * 21 | * @details This file contains declarations of functions used for decoding GATTS event packets 22 | * received from the Connectivity Chip. 23 | * 24 | */ 25 | 26 | #ifndef BLE_RPC_EVENT_DECODER_GATTS_H__ 27 | #define BLE_RPC_EVENT_DECODER_GATTS_H__ 28 | 29 | #include 30 | #include "ble.h" 31 | #include "ble_gatts.h" 32 | 33 | /** @brief Function for decoding the length of a BLE GATTS event. The decoded BLE GATTS event 34 | * length will be returned in p_event_length. 35 | * 36 | * @param[in] event_id Event Id of the event, whose length is to be decoded. 37 | * @param[out] p_event_length The pointer for storing the decoded event length. 38 | * @param[in] p_packet The pointer to the encoded event. 39 | */ 40 | void ble_rpc_gatts_evt_length_decode(uint8_t event_id, 41 | uint16_t * p_event_length, 42 | uint8_t const * const p_packet); 43 | 44 | /** @brief Function for decoding a BLE GATTS event. The decoded BLE GATTS event will be returned in 45 | * the memory pointed to by p_ble_evt. 46 | * 47 | * @param[out] p_ble_evt The pointer for storing the decoded event. 48 | * @param[in] p_packet The pointer to the encoded event. 49 | */ 50 | void ble_rpc_gatts_evt_packet_decode(ble_evt_t * p_ble_evt, 51 | uint8_t const * const p_packet); 52 | 53 | #endif // BLE_RPC_EVENT_DECODER_GATTS_H__ 54 | 55 | /** @} **/ 56 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/rpc/ble_rpc_event_encoder.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_rpc_event_encoder Events Encoder 16 | * @{ 17 | * @ingroup ble_sdk_lib_serialization 18 | * 19 | * @brief Event encoder for S110 SoftDevice serialization. 20 | * 21 | * @details This module provides a function for serializing S110 SoftDevice events. 22 | * 23 | */ 24 | #ifndef BLE_RPC_EVENT_ENCODER_H__ 25 | #define BLE_RPC_EVENT_ENCODER_H__ 26 | 27 | #include "ble.h" 28 | 29 | /**@brief Function for encoding a @ref ble_evt_t. The function will pass the serialized byte stream to the 30 | * transport layer after encoding. 31 | * 32 | * @param[in] p_ble_evt S110 SoftDevice event to serialize. 33 | */ 34 | void ble_rpc_event_handle(ble_evt_t * p_ble_evt); 35 | 36 | #endif // BLE_RPC_EVENT_ENCODER_H__ 37 | 38 | /** @} */ 39 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/rpc/ble_rpc_event_encoder_gap.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_rpc_event_encoder_gap GAP Event Encoder 16 | * @{ 17 | * @ingroup ble_sdk_lib_serialization 18 | * 19 | * @brief Event encoder for S110 SoftDevice serialization. 20 | * 21 | * @details This module provides functions for serializing S110 SoftDevice events. 22 | * 23 | */ 24 | #ifndef BLE_RPC_EVENT_ENCODER_GAP_H__ 25 | #define BLE_RPC_EVENT_ENCODER_GAP_H__ 26 | 27 | #include 28 | #include 29 | 30 | /**@brief Function for encoding a @ref ble_evt_t GAP event. 31 | * 32 | * @param[in] p_ble_evt S110 SoftDevice event to serialize. 33 | * @param[out] p_buffer Pointer to a buffer for the encoded event. 34 | * 35 | * @return Number of bytes encoded. 36 | */ 37 | uint32_t ble_rpc_evt_gap_encode(ble_evt_t * p_ble_evt, uint8_t * p_buffer); 38 | 39 | #endif // BLE_RPC_EVENT_ENCODER_GAP_H__ 40 | 41 | /** @} */ 42 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/rpc/ble_rpc_event_encoder_gatts.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup ble_rpc_event_encoder_gatts GATTS Events Encoder 16 | * @{ 17 | * @ingroup ble_sdk_lib_serialization 18 | * 19 | * @brief Event encoder for S110 SoftDevice serialization. 20 | * 21 | * @details This module provides functions for serializing S110 SoftDevice events. 22 | * 23 | */ 24 | #ifndef BLE_RPC_EVENT_ENCODER_GATTS_H__ 25 | #define BLE_RPC_EVENT_ENCODER_GATTS_H__ 26 | 27 | #include 28 | #include 29 | 30 | /**@brief Function for encoding a @ref ble_evt_t GATTS event. 31 | * 32 | * @param[in] p_ble_evt S110 SoftDevice event to serialize. 33 | * @param[out] p_buffer Pointer to a buffer for the encoded event. 34 | * 35 | * @return Number of bytes encoded. 36 | */ 37 | uint32_t ble_rpc_evt_gatts_encode(ble_evt_t * p_ble_evt, uint8_t * p_buffer); 38 | 39 | #endif // BLE_RPC_EVENT_ENCODER_GATTS_H__ 40 | 41 | /** @} */ 42 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/rpc/ble_rpc_pkt_receiver.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * 15 | * @defgroup rpc_pkt_receiver Packet Receiver 16 | * @{ 17 | * @ingroup ble_sdk_lib_serialization 18 | * 19 | * @brief This module is used for processing the Command Response packets and Event packets. 20 | */ 21 | 22 | #ifndef BLE_RPC_PKT_RECEIVER_H__ 23 | #define BLE_RPC_PKT_RECEIVER_H__ 24 | 25 | #include 26 | 27 | /**@brief Function for initializing the BLE S110 RPC Packet Receiver module. 28 | * 29 | * @return NRF_SUCCESS upon success, any other upon failure. 30 | */ 31 | uint32_t ble_rpc_pkt_receiver_init(void); 32 | 33 | #endif 34 | 35 | /** @} **/ 36 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/softdevice/ble_err.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 3 | * 4 | * The information contained herein is confidential property of Nordic Semiconductor. The use, 5 | * copying, transfer or disclosure of such information is prohibited except by express written 6 | * agreement with Nordic Semiconductor. 7 | * 8 | */ 9 | /** 10 | @addtogroup BLE_COMMON 11 | @{ 12 | @addtogroup nrf_error 13 | @{ 14 | @ingroup BLE_COMMON 15 | @} 16 | 17 | @defgroup ble_err General error codes 18 | @{ 19 | 20 | @brief General error code definitions for the BLE API. 21 | 22 | @ingroup BLE_COMMON 23 | */ 24 | #ifndef NRF_BLE_ERR_H__ 25 | #define NRF_BLE_ERR_H__ 26 | 27 | #include "nrf_error.h" 28 | 29 | /* @defgroup BLE_ERRORS Error Codes 30 | * @{ */ 31 | #define BLE_ERROR_INVALID_CONN_HANDLE (NRF_ERROR_STK_BASE_NUM+0x001) /**< Invalid connection handle. */ 32 | #define BLE_ERROR_INVALID_ATTR_HANDLE (NRF_ERROR_STK_BASE_NUM+0x002) /**< Invalid attribute handle. */ 33 | #define BLE_ERROR_NO_TX_BUFFERS (NRF_ERROR_STK_BASE_NUM+0x003) /**< Buffer capacity exceeded. */ 34 | /** @} */ 35 | 36 | 37 | /** @defgroup BLE_ERROR_SUBRANGES Module specific error code subranges 38 | * @brief Assignment of subranges for module specific error codes. 39 | * @note For specific error codes, see ble_.h or ble_error_.h. 40 | * @{ */ 41 | #define NRF_L2CAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x100) /**< L2CAP specific errors. */ 42 | #define NRF_GAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x200) /**< GAP specific errors. */ 43 | #define NRF_GATTC_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x300) /**< GATT client specific errors. */ 44 | #define NRF_GATTS_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x400) /**< GATT server specific errors. */ 45 | /** @} */ 46 | 47 | #endif 48 | 49 | 50 | /** 51 | @} 52 | @} 53 | */ 54 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/softdevice/ble_ranges.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 3 | 4 | The information contained herein is confidential property of Nordic Semiconductor. The use, 5 | copying, transfer or disclosure of such information is prohibited except by express written 6 | agreement with Nordic Semiconductor. 7 | */ 8 | /** 9 | @addtogroup BLE_COMMON 10 | @{ 11 | @defgroup ble_ranges Module specific SVC and event number subranges 12 | @{ 13 | 14 | @brief Definition of SVC and event number subranges for each API module. 15 | 16 | @note 17 | SVCs and event numbers are split into subranges for each API module. 18 | Each module receives its entire allocated range of SVC calls, whether implemented or not, 19 | but return BLE_ERROR_NOT_SUPPORTED for unimplemented or undefined calls in its range. 20 | 21 | Note that the symbols BLE__SVC_LAST is the end of the allocated SVC range, 22 | rather than the last SVC function call actually defined and implemented. 23 | 24 | Specific SVC and event values are defined in each module's ble_.h file, 25 | which defines names of each individual SVC code based on the range start value. 26 | */ 27 | 28 | #ifndef BLE_RANGES_H__ 29 | #define BLE_RANGES_H__ 30 | 31 | #define BLE_SVC_BASE 0x50 32 | #define BLE_SVC_LAST 0x5B /* Total: 12. */ 33 | 34 | #define BLE_RESERVED_SVC_BASE 0x5C 35 | #define BLE_RESERVED_SVC_LAST 0x5F /* Total: 4. */ 36 | 37 | #define BLE_GAP_SVC_BASE 0x60 38 | #define BLE_GAP_SVC_LAST 0x7F /* Total: 32. */ 39 | 40 | #define BLE_GATTC_SVC_BASE 0x80 41 | #define BLE_GATTC_SVC_LAST 0x9F /* Total: 32. */ 42 | 43 | #define BLE_GATTS_SVC_BASE 0xA0 44 | #define BLE_GATTS_SVC_LAST 0xAF /* Total: 16. */ 45 | 46 | #define BLE_L2CAP_SVC_BASE 0xB0 47 | #define BLE_L2CAP_SVC_LAST 0xBF /* Total: 16. */ 48 | 49 | 50 | #define BLE_EVT_INVALID 0x00 51 | 52 | #define BLE_EVT_BASE 0x01 53 | #define BLE_EVT_LAST 0x0F /* Total: 15. */ 54 | 55 | #define BLE_GAP_EVT_BASE 0x10 56 | #define BLE_GAP_EVT_LAST 0x2F /* Total: 32. */ 57 | 58 | #define BLE_GATTC_EVT_BASE 0x30 59 | #define BLE_GATTC_EVT_LAST 0x4F /* Total: 32. */ 60 | 61 | #define BLE_GATTS_EVT_BASE 0x50 62 | #define BLE_GATTS_EVT_LAST 0x6F /* Total: 32. */ 63 | 64 | #define BLE_L2CAP_EVT_BASE 0x70 65 | #define BLE_L2CAP_EVT_LAST 0x8F /* Total: 32. */ 66 | 67 | #endif /* BLE_RANGES_H__ */ 68 | 69 | /** 70 | @} 71 | @} 72 | */ 73 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/softdevice/nrf_error_sdm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 3 | * 4 | * The information contained herein is confidential property of Nordic Semiconductor. The use, 5 | * copying, transfer or disclosure of such information is prohibited except by express written 6 | * agreement with Nordic Semiconductor. 7 | * 8 | */ 9 | /** 10 | @addtogroup nrf_sdm_api 11 | @{ 12 | @defgroup nrf_sdm_error SoftDevice Manager Error Codes 13 | @{ 14 | 15 | @brief Error definitions for the SDM API 16 | */ 17 | 18 | /* Header guard */ 19 | #ifndef NRF_ERROR_SDM_H__ 20 | #define NRF_ERROR_SDM_H__ 21 | 22 | #include "nrf_error.h" 23 | 24 | #define NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN (NRF_ERROR_SDM_BASE_NUM + 0) ///< Unknown lfclk source 25 | #define NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION (NRF_ERROR_SDM_BASE_NUM + 1) ///< Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts) 26 | #define NRF_ERROR_SDM_INCORRECT_CLENR0 (NRF_ERROR_SDM_BASE_NUM + 2) ///< Incorrect CLENR0 (can be caused by erronous SoftDevice flashing) 27 | 28 | #endif // NRF_ERROR_SDM_H__ 29 | 30 | /** 31 | @} 32 | @} 33 | */ 34 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/softdevice/nrf_error_soc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 3 | * 4 | * The information contained herein is confidential property of Nordic Semiconductor. The use, 5 | * copying, transfer or disclosure of such information is prohibited except by express written 6 | * agreement with Nordic Semiconductor. 7 | * 8 | */ 9 | /** 10 | @addtogroup nrf_soc_api 11 | @{ 12 | @defgroup nrf_soc_error SoC Library Error Codes 13 | @{ 14 | 15 | @brief Error definitions for the SoC library 16 | 17 | */ 18 | 19 | /* Header guard */ 20 | #ifndef NRF_ERROR_SOC_H__ 21 | #define NRF_ERROR_SOC_H__ 22 | 23 | #include "nrf_error.h" 24 | 25 | /* Mutex Errors */ 26 | #define NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN (NRF_ERROR_SOC_BASE_NUM + 0) ///< Mutex already taken 27 | 28 | /* NVIC errors */ 29 | #define NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE (NRF_ERROR_SOC_BASE_NUM + 1) ///< NVIC interrupt not available 30 | #define NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED (NRF_ERROR_SOC_BASE_NUM + 2) ///< NVIC interrupt priority not allowed 31 | #define NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 3) ///< NVIC should not return 32 | 33 | /* Power errors */ 34 | #define NRF_ERROR_SOC_POWER_MODE_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 4) ///< Power mode unknown 35 | #define NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 5) ///< Power POF threshold unknown 36 | #define NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 6) ///< Power off should not return 37 | 38 | /* Rand errors */ 39 | #define NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES (NRF_ERROR_SOC_BASE_NUM + 7) ///< RAND not enough values 40 | 41 | /* PPI errors */ 42 | #define NRF_ERROR_SOC_PPI_INVALID_CHANNEL (NRF_ERROR_SOC_BASE_NUM + 8) ///< Invalid PPI Channel 43 | #define NRF_ERROR_SOC_PPI_INVALID_GROUP (NRF_ERROR_SOC_BASE_NUM + 9) ///< Invalid PPI Group 44 | 45 | #endif // NRF_ERROR_SOC_H__ 46 | /** 47 | @} 48 | @} 49 | */ 50 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/softdevice/nrf_svc.h: -------------------------------------------------------------------------------- 1 | #ifndef NRF_SVC__ 2 | #define NRF_SVC__ 3 | 4 | #ifdef SVCALL_AS_NORMAL_FUNCTION 5 | #define SVCALL(number, return_type, signature) return_type signature 6 | #else 7 | 8 | #ifndef SVCALL 9 | #if defined (__CC_ARM) 10 | #define SVCALL(number, return_type, signature) return_type __svc(number) signature 11 | #elif defined (__GNUC__) 12 | #define SVCALL(number, return_type, signature) \ 13 | _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \ 14 | _Pragma("GCC diagnostic ignored \"-Wunused-function\"") \ 15 | __attribute__((naked)) static return_type signature \ 16 | { \ 17 | __asm( \ 18 | "svc %0\n" \ 19 | "bx r14" : : "I" (number) : "r0" \ 20 | ); \ 21 | } 22 | #elif defined (__ICCARM__) 23 | #define PRAGMA(x) _Pragma(#x) 24 | #define SVCALL(number, return_type, signature) \ 25 | PRAGMA(swi_number = number) \ 26 | __swi return_type signature; 27 | #else 28 | #define SVCALL(number, return_type, signature) return_type signature 29 | #endif 30 | #endif // SVCALL 31 | 32 | #endif // SVCALL_AS_NORMAL_FUNCTION 33 | #endif // NRF_SVC__ 34 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ble/softdevice/softdevice_assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 3 | * 4 | * The information contained herein is confidential property of Nordic Semiconductor. The use, 5 | * copying, transfer or disclosure of such information is prohibited except by express written 6 | * agreement with Nordic Semiconductor. 7 | * 8 | */ 9 | 10 | /** @brief Utilities for verifying program logic 11 | */ 12 | 13 | #ifndef SOFTDEVICE_ASSERT_H_ 14 | #define SOFTDEVICE_ASSERT_H_ 15 | 16 | #include 17 | 18 | /** @brief This function handles assertions. 19 | * 20 | * 21 | * @note 22 | * This function is called when an assertion has triggered. 23 | * 24 | * 25 | * @param line_num The line number where the assertion is called 26 | * @param file_name Pointer to the file name 27 | */ 28 | void assert_softdevice_callback(uint16_t line_num, const uint8_t *file_name); 29 | 30 | 31 | /*lint -emacro(506, ASSERT) */ /* Suppress "Constant value Boolean */ 32 | /*lint -emacro(774, ASSERT) */ /* Suppress "Boolean within 'if' always evaluates to True" */ \ 33 | /** @brief Check intended for production code 34 | * 35 | * Check passes if "expr" evaluates to true. */ 36 | #define ASSERT(expr) \ 37 | if (expr) \ 38 | { \ 39 | } \ 40 | else \ 41 | { \ 42 | assert_softdevice_callback((uint16_t)__LINE__, (uint8_t *)__FILE__); \ 43 | /*lint -unreachable */ \ 44 | } 45 | 46 | #endif /* SOFTDEVICE_ASSERT_H_ */ 47 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/boards.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | #ifndef BOARDS_H 13 | #define BOARDS_H 14 | 15 | #if defined(BOARD_NRF6310) 16 | #include "boards/nrf6310.h" 17 | #elif defined(BOARD_PCA10000) 18 | #include "boards/pca10000.h" 19 | #elif defined(BOARD_PCA10001) 20 | #include "boards/pca10001.h" 21 | #elif defined(BOARD_PCA10003) 22 | #include "boards/pca10003.h" 23 | #else 24 | #error "Board is not defined" 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/common.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #ifndef COMMON_H 14 | #define COMMON_H 15 | 16 | /*lint ++flb "Enter library region" */ 17 | 18 | #include 19 | #include 20 | 21 | /* @file 22 | * @brief Common header file for generic macros and definitions 23 | * 24 | */ 25 | 26 | /* 27 | * GPIO glue macros, this can be used to define a pin number in source/header file and use that macro for pin 28 | * configuration using this expansion. 29 | * example: 30 | * #define RESET_PIN 8 31 | * NRF_GPIO->PINCNF(RESET_PIN) = XXX ; // Expanded NRF_GPIO->PIN_CNF[8] = XXX 32 | */ 33 | #define PINX_GLUE(x, y, z) x##y##_##z /*!< first level glue for pin macros */ 34 | #define PINCNF(p) PINX_GLUE(PIN,p,CNF) /*!< gpio configure pin number 'p' */ 35 | #define PINOUT(p) PINX_GLUE(PIN,p,OUT) /*!< gpio out pin number 'p' */ 36 | 37 | /*lint --flb "Leave library region" */ 38 | #endif 39 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/compiler_abstraction.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is confidential property of Nordic 4 | * Semiconductor ASA.Terms and conditions of usage are described in detail 5 | * in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #ifndef _COMPILER_ABSTRACTION_H 14 | #define _COMPILER_ABSTRACTION_H 15 | 16 | /*lint ++flb "Enter library region" */ 17 | 18 | #if defined ( __CC_ARM ) 19 | #define __ASM __asm /*!< asm keyword for ARM Compiler */ 20 | #define __INLINE __inline /*!< inline keyword for ARM Compiler */ 21 | #define __STATIC_INLINE static __inline 22 | 23 | #elif defined ( __ICCARM__ ) 24 | #define __ASM __asm /*!< asm keyword for IAR Compiler */ 25 | #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ 26 | #define __STATIC_INLINE static inline 27 | #define __current_sp() __get_SP() 28 | 29 | #elif defined ( __GNUC__ ) 30 | #define __ASM __asm /*!< asm keyword for GNU Compiler */ 31 | #define __INLINE inline /*!< inline keyword for GNU Compiler */ 32 | #define __STATIC_INLINE static inline 33 | 34 | static __INLINE unsigned int __current_sp(void) 35 | { 36 | register unsigned sp asm("sp"); 37 | return sp; 38 | } 39 | 40 | #elif defined ( __TASKING__ ) 41 | #define __ASM __asm /*!< asm keyword for TASKING Compiler */ 42 | #define __INLINE inline /*!< inline keyword for TASKING Compiler */ 43 | #define __STATIC_INLINE static inline 44 | 45 | #endif 46 | 47 | /*lint --flb "Leave library region" */ 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ext_sensors/mpu6050.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #ifndef MPU6050_H 14 | #define MPU6050_H 15 | 16 | /*lint ++flb "Enter library region" */ 17 | 18 | #include 19 | #include 20 | 21 | /** @file 22 | * @brief MPU6050 gyro/accelerometer driver. 23 | * 24 | * 25 | * @defgroup nrf_drivers_mpu6050 MPU6050 gyro/accelerometer driver 26 | * @{ 27 | * @ingroup nrf_drivers 28 | * @brief MPU6050 gyro/accelerometer driver. 29 | */ 30 | 31 | /** 32 | * @brief Function for initializing MPU6050 and verifies it's on the bus. 33 | * 34 | * @param device_address Device TWI address in bits [6:0]. 35 | * @return 36 | * @retval true MPU6050 found on the bus and ready for operation. 37 | * @retval false MPU6050 not found on the bus or communication failure. 38 | */ 39 | bool mpu6050_init(uint8_t device_address); 40 | 41 | /** 42 | @brief Function for writing a MPU6050 register contents over TWI. 43 | @param[in] register_address Register address to start writing to 44 | @param[in] value Value to write to register 45 | @retval true Register write succeeded 46 | @retval false Register write failed 47 | */ 48 | bool mpu6050_register_write(uint8_t register_address, const uint8_t value); 49 | 50 | /** 51 | @brief Function for reading MPU6050 register contents over TWI. 52 | Reads one or more consecutive registers. 53 | @param[in] register_address Register address to start reading from 54 | @param[in] number_of_bytes Number of bytes to read 55 | @param[out] destination Pointer to a data buffer where read data will be stored 56 | @retval true Register read succeeded 57 | @retval false Register read failed 58 | */ 59 | bool mpu6050_register_read(uint8_t register_address, uint8_t *destination, uint8_t number_of_bytes); 60 | 61 | /** 62 | @brief Function for reading and verifying MPU6050 product ID. 63 | @retval true Product ID is what was expected 64 | @retval false Product ID was not what was expected 65 | */ 66 | bool mpu6050_verify_product_id(void); 67 | 68 | /** 69 | *@} 70 | **/ 71 | 72 | /*lint --flb "Leave library region" */ 73 | 74 | #endif /* MPU6050_H */ 75 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/ext_sensors/sdio.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #ifndef SDIO_H 14 | #define SDIO_H 15 | 16 | /*lint ++flb "Enter library region" */ 17 | 18 | #include 19 | #include 20 | 21 | /** @file 22 | * @brief 2-wire serial interface driver (compatible with ADNS2080 mouse sensor driver) 23 | * 24 | * 25 | * @defgroup nrf_drivers_sdio SDIO driver 26 | * @{ 27 | * @ingroup nrf_drivers 28 | * @brief 2-wire serial interface driver. 29 | */ 30 | 31 | /** 32 | * @brief Function for initializing 2-wire serial interface and trying to handle stuck slaves. 33 | * 34 | */ 35 | void sdio_init(void); 36 | 37 | /** 38 | * @brief Function for reading a byte over 2-wire serial interface. 39 | * 40 | * Developer needs to implement this function in a way that suits the hardware. 41 | * @param address Register address to read from 42 | * @return Byte read 43 | */ 44 | uint8_t sdio_read_byte(uint8_t address); 45 | 46 | /** 47 | * @brief Function for reading several bytes over 2-wire serial interface using burst mode. 48 | * 49 | * Developer needs to implement this function in a way that suits the hardware. 50 | * @param target_buffer Buffer location to store read bytes to 51 | * @param target_buffer_size Bytes allocated for target_buffer 52 | */ 53 | void sdio_read_burst(uint8_t *target_buffer, uint8_t target_buffer_size); 54 | 55 | /** 56 | * @brief Function for writing a byte over 2-wire serial interface. 57 | * 58 | * Developer needs to implement this function in a way that suits the hardware. 59 | * @param address Register address to write to 60 | * @param data_byte Data byte to write 61 | */ 62 | void sdio_write_byte(uint8_t address, uint8_t data_byte); 63 | 64 | /** 65 | *@} 66 | **/ 67 | 68 | /*lint --flb "Leave library region" */ 69 | #endif 70 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/nrf.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | 14 | #ifndef NRF_H 15 | #define NRF_H 16 | 17 | #ifndef _WIN32 18 | 19 | #include "compiler_abstraction.h" 20 | 21 | /* Family selection for main includes. NRF51 must be selected. */ 22 | #ifdef NRF51 23 | #include "nrf51.h" 24 | #include "nrf51_bitfields.h" 25 | #include "nrf51_deprecated.h" 26 | #else 27 | #error "Device family must be defined. See nrf.h." 28 | #endif /* NRF51 */ 29 | 30 | #endif /* _WIN32 */ 31 | 32 | #endif /* NRF_H */ 33 | 34 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/nrf_assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006 Nordic Semiconductor. All Rights Reserved. 3 | * 4 | * The information contained herein is confidential property of Nordic Semiconductor. The use, 5 | * copying, transfer or disclosure of such information is prohibited except by express written 6 | * agreement with Nordic Semiconductor. 7 | * 8 | */ 9 | 10 | /** @file 11 | * @brief Utilities for verifying program logic 12 | */ 13 | 14 | #ifndef NRF_ASSERT_H_ 15 | #define NRF_ASSERT_H_ 16 | 17 | #include 18 | 19 | #if defined(DEBUG_NRF) || defined(DEBUG_NRF_USER) 20 | 21 | /** @brief Function for handling assertions. 22 | * 23 | * 24 | * @note 25 | * This function is called when an assertion has triggered. 26 | * 27 | * 28 | * @post 29 | * All hardware is put into an idle non-emitting state (in particular the radio is highly 30 | * important to switch off since the radio might be in a state that makes it send 31 | * packets continiously while a typical final infinit ASSERT loop is executing). 32 | * 33 | * 34 | * @param line_num The line number where the assertion is called 35 | * @param file_name Pointer to the file name 36 | */ 37 | void assert_nrf_callback(uint16_t line_num, const uint8_t *file_name); 38 | 39 | /*lint -emacro(506, ASSERT) */ /* Suppress "Constant value Boolean */ 40 | /*lint -emacro(774, ASSERT) */ /* Suppress "Boolean within 'if' always evaluates to True" */ \ 41 | 42 | /** @brief Function for checking intended for production code. 43 | * 44 | * Check passes if "expr" evaluates to true. */ 45 | #define ASSERT(expr) \ 46 | if (expr) \ 47 | { \ 48 | } \ 49 | else \ 50 | { \ 51 | assert_nrf_callback((uint16_t)__LINE__, (uint8_t *)__FILE__); \ 52 | } 53 | #else 54 | #define ASSERT(expr) //!< Assert empty when disabled 55 | void assert_nrf_callback(uint16_t line_num, const uint8_t *file_name); 56 | #endif /* defined(DEBUG_NRF) || defined(DEBUG_NRF_USER) */ 57 | 58 | #endif /* NRF_ASSERT_H_ */ 59 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/nrf_delay.h: -------------------------------------------------------------------------------- 1 | #ifndef _NRF_DELAY_H 2 | #define _NRF_DELAY_H 3 | 4 | #include "nrf.h" 5 | 6 | /*lint --e{438, 522} "Variable not used" "Function lacks side-effects" */ 7 | #if defined ( __CC_ARM ) 8 | static __ASM void __INLINE nrf_delay_us(uint32_t volatile number_of_us) 9 | { 10 | loop 11 | SUBS R0, R0, #1 12 | NOP 13 | NOP 14 | NOP 15 | NOP 16 | NOP 17 | NOP 18 | NOP 19 | NOP 20 | NOP 21 | NOP 22 | NOP 23 | NOP 24 | BNE loop 25 | BX LR 26 | } 27 | #elif defined ( __ICCARM__ ) 28 | static void __INLINE nrf_delay_us(uint32_t volatile number_of_us) 29 | { 30 | __ASM ( 31 | "loop:\n\t" 32 | " SUBS R0, R0, #1\n\t" 33 | " NOP\n\t" 34 | " NOP\n\t" 35 | " NOP\n\t" 36 | " NOP\n\t" 37 | " NOP\n\t" 38 | " NOP\n\t" 39 | " NOP\n\t" 40 | " NOP\n\t" 41 | " NOP\n\t" 42 | " NOP\n\t" 43 | " NOP\n\t" 44 | " NOP\n\t" 45 | " BNE loop\n\t"); 46 | } 47 | #elif defined ( __GNUC__ ) 48 | static void __INLINE nrf_delay_us(uint32_t volatile number_of_us) 49 | { 50 | do 51 | { 52 | __ASM volatile ( 53 | "NOP\n\t" 54 | "NOP\n\t" 55 | "NOP\n\t" 56 | "NOP\n\t" 57 | "NOP\n\t" 58 | "NOP\n\t" 59 | "NOP\n\t" 60 | "NOP\n\t" 61 | "NOP\n\t" 62 | "NOP\n\t" 63 | "NOP\n\t" 64 | "NOP\n\t" 65 | "NOP\n\t" 66 | "NOP\n\t" 67 | ); 68 | } while (--number_of_us); 69 | } 70 | #endif 71 | 72 | void nrf_delay_ms(uint32_t volatile number_of_ms); 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/nrf_ecb.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is confidential property of Nordic 4 | * Semiconductor ASA.Terms and conditions of usage are described in detail 5 | * in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | * $LastChangedRevision: 13999 $ 12 | */ 13 | 14 | /** 15 | * @file 16 | * @brief ECB driver API. 17 | */ 18 | 19 | #ifndef NRF_ECB_H__ 20 | #define NRF_ECB_H__ 21 | 22 | /** 23 | * @defgroup nrf_ecb AES ECB encryption 24 | * @{ 25 | * @ingroup nrf_drivers 26 | * @brief Driver for the nRF51 AES Electronic Code Book (ECB) peripheral. 27 | * 28 | * In order to encrypt and decrypt data the peripheral must be powered on 29 | * using nrf_ecb_init() and then the key set using nrf_ecb_set_key. 30 | */ 31 | 32 | #include 33 | 34 | /** 35 | * Initialize and power on the ECB peripheral. 36 | * 37 | * Allocates memory for the ECBDATAPTR. 38 | * @retval true Initialization was successful. 39 | * @retval false Powering up failed. 40 | */ 41 | bool nrf_ecb_init(void); 42 | 43 | /** 44 | * Encrypt/decrypt 16-byte data using current key. 45 | * 46 | * The function avoids unnecessary copying of data if the point to the 47 | * correct locations in the ECB data structure. 48 | * 49 | * @param dst Result of encryption/decryption. 16 bytes will be written. 50 | * @param src Source with 16-byte data to be encrypted/decrypted. 51 | * 52 | * @retval true If the encryption operation completed. 53 | * @retval false If the encryption operation did not complete. 54 | */ 55 | bool nrf_ecb_crypt(uint8_t * dst, const uint8_t * src); 56 | 57 | /** 58 | * Set the key to be used for encryption/decryption. 59 | * 60 | * @param key Pointer to key. 16 bytes will be read. 61 | */ 62 | void nrf_ecb_set_key(const uint8_t * key); 63 | 64 | #endif // NRF_ECB_H__ 65 | 66 | /** @} */ 67 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/nrf_temp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #ifndef NRF_TEMP_H__ 14 | #define NRF_TEMP_H__ 15 | 16 | #include "nrf51.h" 17 | 18 | /** 19 | * @defgroup nrf_temperature TEMP (temperature) abstraction 20 | * @{ 21 | * @ingroup nrf_drivers temperature_example 22 | * @brief Temperature module init and read functions. 23 | * 24 | */ 25 | 26 | 27 | 28 | /** 29 | * @brief Function for preparing the temp module for temperature measurement. 30 | * 31 | * This function initializes the TEMP module and writes to the hidden configuration register. 32 | * 33 | * @param none 34 | */ 35 | static __INLINE void nrf_temp_init(void) 36 | { 37 | /**@note Workaround for PAN_028 rev2.0A anomaly 31 - TEMP: Temperature offset value has to be manually loaded to the TEMP module */ 38 | *(uint32_t *) 0x4000C504 = 0; 39 | } 40 | 41 | 42 | 43 | #define MASK_SIGN (0x00000200UL) 44 | #define MASK_SIGN_EXTENSION (0xFFFFFC00UL) 45 | 46 | /** 47 | * @brief Function for reading temperature measurement. 48 | * 49 | * The function reads the 10 bit 2's complement value and transforms it to a 32 bit 2's complement value. 50 | * 51 | * @param none 52 | */ 53 | static __INLINE int32_t nrf_temp_read(void) 54 | { 55 | /**@note Workaround for PAN_028 rev2.0A anomaly 28 - TEMP: Negative measured values are not represented correctly */ 56 | return ((NRF_TEMP->TEMP & MASK_SIGN) != 0) ? (NRF_TEMP->TEMP | MASK_SIGN_EXTENSION) : (NRF_TEMP->TEMP); 57 | } 58 | 59 | /** @} */ 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Include/system_nrf51.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | 14 | #ifndef SYSTEM_NRF51_H 15 | #define SYSTEM_NRF51_H 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include 22 | 23 | 24 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 25 | 26 | /** 27 | * Initialize the system 28 | * 29 | * @param none 30 | * @return none 31 | * 32 | * @brief Setup the microcontroller system. 33 | * Initialize the System and update the SystemCoreClock variable. 34 | */ 35 | extern void SystemInit (void); 36 | 37 | /** 38 | * Update SystemCoreClock variable 39 | * 40 | * @param none 41 | * @return none 42 | * 43 | * @brief Updates the SystemCoreClock with current core Clock 44 | * retrieved from cpu registers. 45 | */ 46 | extern void SystemCoreClockUpdate (void); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* SYSTEM_NRF51_H */ 53 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Lib/esb/arm/esb_arm.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/wrist-rom-open/nrf51822/Lib/esb/arm/esb_arm.lib -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Lib/gzll/arm/gzll_arm.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baiduwearable/duband/c2f0e8481cdf667399c0ff8a54e96fe97116b873/wrist-rom-open/nrf51822/Lib/gzll/arm/gzll_arm.lib -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Source/app_common/app_fifo.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #include "app_fifo.h" 14 | #include "app_util.h" 15 | 16 | 17 | #define FIFO_LENGTH (p_fifo->write_pos - p_fifo->read_pos) /**< Macro for calculating the FIFO length. */ 18 | 19 | 20 | uint32_t app_fifo_init(app_fifo_t * p_fifo, uint8_t * p_buf, uint16_t buf_size) 21 | { 22 | // Check buffer for null pointer 23 | if (p_buf == NULL) 24 | { 25 | return NRF_ERROR_NULL; 26 | } 27 | 28 | // Check that the buffer size is a power of two 29 | if (!IS_POWER_OF_TWO(buf_size)) 30 | { 31 | return NRF_ERROR_INVALID_LENGTH; 32 | } 33 | 34 | p_fifo->p_buf = p_buf; 35 | p_fifo->buf_size_mask = buf_size - 1; 36 | p_fifo->read_pos = 0; 37 | p_fifo->write_pos = 0; 38 | 39 | return NRF_SUCCESS; 40 | } 41 | 42 | 43 | uint32_t app_fifo_put(app_fifo_t * p_fifo, uint8_t byte) 44 | { 45 | if (FIFO_LENGTH <= p_fifo->buf_size_mask) 46 | { 47 | p_fifo->p_buf[p_fifo->write_pos & p_fifo->buf_size_mask] = byte; 48 | p_fifo->write_pos++; 49 | return NRF_SUCCESS; 50 | } 51 | 52 | return NRF_ERROR_NO_MEM; 53 | } 54 | 55 | 56 | uint32_t app_fifo_get(app_fifo_t * p_fifo, uint8_t * p_byte) 57 | { 58 | if (FIFO_LENGTH != 0) 59 | { 60 | *p_byte = p_fifo->p_buf[p_fifo->read_pos & p_fifo->buf_size_mask]; 61 | p_fifo->read_pos++; 62 | return NRF_SUCCESS; 63 | } 64 | 65 | return NRF_ERROR_NOT_FOUND; 66 | 67 | } 68 | 69 | uint32_t app_fifo_flush(app_fifo_t * p_fifo) 70 | { 71 | p_fifo->read_pos = p_fifo->write_pos; 72 | return NRF_SUCCESS; 73 | } 74 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Source/app_common/crc16.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #include "crc16.h" 14 | #include 15 | 16 | uint16_t crc16_compute(const uint8_t * p_data, uint32_t size, const uint16_t * p_crc) 17 | { 18 | uint32_t i; 19 | uint16_t crc = (p_crc == NULL) ? 0xffff : *p_crc; 20 | 21 | for (i = 0; i < size; i++) 22 | { 23 | crc = (unsigned char)(crc >> 8) | (crc << 8); 24 | crc ^= p_data[i]; 25 | crc ^= (unsigned char)(crc & 0xff) >> 4; 26 | crc ^= (crc << 8) << 4; 27 | crc ^= ((crc & 0xff) << 4) << 1; 28 | } 29 | 30 | return crc; 31 | } 32 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Source/ble/ble_racp.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | */ 11 | 12 | #include "ble_racp.h" 13 | #include 14 | 15 | 16 | void ble_racp_decode(uint8_t data_len, uint8_t * p_data, ble_racp_value_t * p_racp_val) 17 | { 18 | p_racp_val->opcode = 0xFF; 19 | p_racp_val->operator = 0xFF; 20 | p_racp_val->operand_len = 0; 21 | p_racp_val->p_operand = NULL; 22 | 23 | if (data_len > 0) 24 | { 25 | p_racp_val->opcode = p_data[0]; 26 | } 27 | if (data_len > 1) 28 | { 29 | p_racp_val->operator = p_data[1]; //lint !e415 30 | } 31 | if (data_len > 2) 32 | { 33 | p_racp_val->operand_len = data_len - 2; 34 | p_racp_val->p_operand = &p_data[2]; //lint !e416 35 | } 36 | } 37 | 38 | 39 | uint8_t ble_racp_encode(const ble_racp_value_t * p_racp_val, uint8_t * p_data) 40 | { 41 | uint8_t len = 0; 42 | int i; 43 | 44 | if (p_data != NULL) 45 | { 46 | p_data[len++] = p_racp_val->opcode; 47 | p_data[len++] = p_racp_val->operator; 48 | 49 | for (i = 0; i < p_racp_val->operand_len; i++) 50 | { 51 | p_data[len++] = p_racp_val->p_operand[i]; 52 | } 53 | } 54 | 55 | return len; 56 | } 57 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Source/ble/ble_radio_notification.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | */ 11 | 12 | #include "ble_radio_notification.h" 13 | #include 14 | 15 | 16 | static bool m_radio_active = false; /**< Current radio state. */ 17 | static ble_radio_notification_evt_handler_t m_evt_handler = NULL; /**< Application event handler for handling Radio Notification events. */ 18 | 19 | 20 | void SWI1_IRQHandler(void) 21 | { 22 | m_radio_active = !m_radio_active; 23 | if (m_evt_handler != NULL) 24 | { 25 | m_evt_handler(m_radio_active); 26 | } 27 | } 28 | 29 | 30 | uint32_t ble_radio_notification_init(nrf_app_irq_priority_t irq_priority, 31 | nrf_radio_notification_distance_t distance, 32 | ble_radio_notification_evt_handler_t evt_handler) 33 | { 34 | uint32_t err_code; 35 | 36 | m_evt_handler = evt_handler; 37 | 38 | // Initialize Radio Notification software interrupt 39 | err_code = sd_nvic_ClearPendingIRQ(SWI1_IRQn); 40 | if (err_code != NRF_SUCCESS) 41 | { 42 | return err_code; 43 | } 44 | 45 | err_code = sd_nvic_SetPriority(SWI1_IRQn, irq_priority); 46 | if (err_code != NRF_SUCCESS) 47 | { 48 | return err_code; 49 | } 50 | 51 | err_code = sd_nvic_EnableIRQ(SWI1_IRQn); 52 | if (err_code != NRF_SUCCESS) 53 | { 54 | return err_code; 55 | } 56 | 57 | // Configure the event 58 | return sd_radio_notification_cfg_set(NRF_RADIO_NOTIFICATION_TYPE_INT_ON_BOTH, distance); 59 | } 60 | 61 | /*********************************************************************************** 62 | * erase a page need 21ms 63 | ************************************************************************************/ 64 | 65 | static bluetooth_status_type_t global_bluetooth_status = NotWork; 66 | 67 | void set_global_bluetooth_status(bluetooth_status_type_t state) 68 | { 69 | global_bluetooth_status = state; 70 | } 71 | 72 | bluetooth_status_type_t get_global_bluetooth_status(void) 73 | { 74 | return global_bluetooth_status; 75 | } 76 | 77 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Source/ble/ble_sensorsim.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #include "ble_sensorsim.h" 14 | 15 | 16 | void ble_sensorsim_init(ble_sensorsim_state_t * p_state, 17 | const ble_sensorsim_cfg_t * p_cfg) 18 | { 19 | if (p_cfg->start_at_max) 20 | { 21 | p_state->current_val = p_cfg->max; 22 | p_state->is_increasing = false; 23 | } 24 | else 25 | { 26 | p_state->current_val = p_cfg->min; 27 | p_state->is_increasing = true; 28 | } 29 | } 30 | 31 | 32 | uint32_t ble_sensorsim_measure(ble_sensorsim_state_t * p_state, 33 | const ble_sensorsim_cfg_t * p_cfg) 34 | { 35 | if (p_state->is_increasing) 36 | { 37 | if (p_cfg->max - p_state->current_val > p_cfg->incr) 38 | { 39 | p_state->current_val += p_cfg->incr; 40 | } 41 | else 42 | { 43 | p_state->current_val = p_cfg->max; 44 | p_state->is_increasing = false; 45 | } 46 | } 47 | else 48 | { 49 | if (p_state->current_val - p_cfg->min > p_cfg->incr) 50 | { 51 | p_state->current_val -= p_cfg->incr; 52 | } 53 | else 54 | { 55 | p_state->current_val = p_cfg->min; 56 | p_state->is_increasing = true; 57 | } 58 | } 59 | return p_state->current_val; 60 | } 61 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Source/ble/ble_services/ble_srv_common.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #include "ble_srv_common.h" 14 | #include 15 | #include "nordic_common.h" 16 | #include "app_error.h" 17 | 18 | 19 | uint8_t ble_srv_report_ref_encode(uint8_t * p_encoded_buffer, 20 | const ble_srv_report_ref_t * p_report_ref) 21 | { 22 | uint8_t len = 0; 23 | 24 | p_encoded_buffer[len++] = p_report_ref->report_id; 25 | p_encoded_buffer[len++] = p_report_ref->report_type; 26 | 27 | APP_ERROR_CHECK_BOOL(len == BLE_SRV_ENCODED_REPORT_REF_LEN); 28 | return len; 29 | } 30 | 31 | 32 | void ble_srv_ascii_to_utf8(ble_srv_utf8_str_t * p_utf8, char * p_ascii) 33 | { 34 | p_utf8->length = (uint16_t)strlen(p_ascii); 35 | p_utf8->p_str = (uint8_t *)p_ascii; 36 | } 37 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Source/ble/rpc/ble_rpc_event_encoder.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | 14 | #include "ble_rpc_event_encoder.h" 15 | #include "ble_rpc_event_encoder_gap.h" 16 | #include "ble_rpc_event_encoder_gatts.h" 17 | #include 18 | #include 19 | #include "app_util.h" 20 | #include "ble_gap.h" 21 | #include "nrf_error.h" 22 | #include "hci_transport.h" 23 | 24 | 25 | void ble_rpc_event_handle(ble_evt_t * p_ble_evt) 26 | { 27 | uint32_t err_code; 28 | uint8_t * p_buffer = NULL; 29 | uint8_t evt_packet_size = 0; 30 | 31 | // Allocate a memory buffer from HCI transport layer for transmitting the Command Response. 32 | // Loop until a buffer is available. 33 | do 34 | { 35 | err_code = hci_transport_tx_alloc(&p_buffer); 36 | } 37 | while (err_code == NRF_ERROR_NO_MEM); 38 | 39 | APP_ERROR_CHECK(err_code); 40 | 41 | uint16_t event_id = p_ble_evt->header.evt_id; 42 | 43 | if ((BLE_GAP_EVT_BASE <= event_id) && (event_id < BLE_GAP_EVT_LAST)) 44 | { 45 | evt_packet_size = ble_rpc_evt_gap_encode(p_ble_evt, p_buffer); 46 | } 47 | else if ((BLE_GATTS_EVT_BASE <= event_id) && (event_id < BLE_GATTS_EVT_LAST)) 48 | { 49 | evt_packet_size = ble_rpc_evt_gatts_encode(p_ble_evt, p_buffer); 50 | } 51 | else 52 | { 53 | // Do nothing. 54 | } 55 | 56 | if (evt_packet_size != 0) 57 | { 58 | err_code = hci_transport_pkt_write(p_buffer, evt_packet_size); 59 | APP_ERROR_CHECK(err_code); 60 | // @note: TX buffer must be freed upon TX done event from HCI Transport layer. The BLE 61 | // connectivity example project handles this in main.c. 62 | } 63 | else 64 | { 65 | // No event was encoded, therefore the buffer is freed immediately. 66 | err_code = hci_transport_tx_free(); 67 | APP_ERROR_CHECK(err_code); 68 | } 69 | } 70 | 71 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Source/gzp/nrf_gzp_host_nrf51.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is confidential property of Nordic 4 | * Semiconductor ASA.Terms and conditions of usage are described in detail 5 | * in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRENTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | * $LastChangedRevision: 133 $ 12 | */ 13 | 14 | 15 | #include "nrf_gzp.h" 16 | #include "nrf_nvmc.h" 17 | 18 | /** 19 | * @file 20 | * @brief Implementation of Gazell Pairing Library (gzp), nRF51 specific Host functions. 21 | * @defgroup gzp_source_host_nrf51 Gazell Pairing Host nRF51 specific implementation 22 | * @{ 23 | * @ingroup gzp_04_source 24 | */ 25 | 26 | 27 | void gzp_host_chip_id_read(uint8_t *dst, uint8_t n) 28 | { 29 | uint8_t i; 30 | uint8_t random_number; 31 | 32 | if( *((uint8_t*)(GZP_PARAMS_STORAGE_ADR + GZP_HOST_ID_LENGTH + 1)) == 0xff) 33 | { 34 | nrf_nvmc_write_byte((GZP_PARAMS_STORAGE_ADR + GZP_HOST_ID_LENGTH + 1) , 0x00); 35 | 36 | for(i = 0; i < n; i++) 37 | { 38 | gzp_random_numbers_generate(&random_number, 1); 39 | nrf_nvmc_write_byte((GZP_PARAMS_STORAGE_ADR + GZP_HOST_ID_LENGTH + 2 + i) , random_number); 40 | } 41 | } 42 | 43 | for(i = 0; i < n; i++) 44 | { 45 | *(dst++) = *((uint8_t*)(GZP_PARAMS_STORAGE_ADR + GZP_HOST_ID_LENGTH + 2 + i)); 46 | } 47 | } 48 | 49 | /** @} */ 50 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Source/nrf_assert/nrf_assert.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2006 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | #include "nrf_assert.h" 13 | 14 | #if defined(DEBUG_NRF) 15 | void assert_nrf_callback(uint16_t line_num, const uint8_t *file_name) 16 | { 17 | (void) file_name; /* Unused parameter */ 18 | (void) line_num; /* Unused parameter */ 19 | 20 | while (1) ; 21 | } 22 | #endif /* DEBUG_NRF */ 23 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Source/nrf_delay/nrf_delay.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #include 14 | #include "compiler_abstraction.h" 15 | #include "nrf.h" 16 | #include "nrf_delay.h" 17 | 18 | /*lint --e{438} "Variable not used" */ 19 | void nrf_delay_ms(uint32_t volatile number_of_ms) 20 | { 21 | while(number_of_ms != 0) 22 | { 23 | number_of_ms--; 24 | nrf_delay_us(999); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /wrist-rom-open/nrf51822/Source/nrf_ecb/nrf_ecb.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | * $LastChangedRevision: 25419 $ 12 | */ 13 | 14 | /** 15 | * @file 16 | * @brief Implementation of AES ECB driver 17 | */ 18 | 19 | 20 | //lint -e438 21 | 22 | #include 23 | #include 24 | #include 25 | #include "nrf.h" 26 | #include "nrf_ecb.h" 27 | 28 | static uint8_t ecb_data[48]; ///< ECB data structure for RNG peripheral to access. 29 | static uint8_t* ecb_key; ///< Key: Starts at ecb_data 30 | static uint8_t* ecb_cleartext; ///< Cleartext: Starts at ecb_data + 16 bytes. 31 | static uint8_t* ecb_ciphertext; ///< Ciphertext: Starts at ecb_data + 32 bytes. 32 | 33 | bool nrf_ecb_init(void) 34 | { 35 | ecb_key = ecb_data; 36 | ecb_cleartext = ecb_data + 16; 37 | ecb_ciphertext = ecb_data + 32; 38 | 39 | NRF_ECB->ECBDATAPTR = (uint32_t)ecb_data; 40 | return true; 41 | } 42 | 43 | 44 | bool nrf_ecb_crypt(uint8_t * dest_buf, const uint8_t * src_buf) 45 | { 46 | uint32_t counter = 0x1000000; 47 | if(src_buf != ecb_cleartext) 48 | { 49 | memcpy(ecb_cleartext,src_buf,16); 50 | } 51 | NRF_ECB->EVENTS_ENDECB = 0; 52 | NRF_ECB->TASKS_STARTECB = 1; 53 | while(NRF_ECB->EVENTS_ENDECB == 0) 54 | { 55 | counter--; 56 | if(counter == 0) 57 | { 58 | return false; 59 | } 60 | } 61 | NRF_ECB->EVENTS_ENDECB = 0; 62 | if(dest_buf != ecb_ciphertext) 63 | { 64 | memcpy(dest_buf,ecb_ciphertext,16); 65 | } 66 | return true; 67 | } 68 | 69 | void nrf_ecb_set_key(const uint8_t * key) 70 | { 71 | memcpy(ecb_key,key,16); 72 | } 73 | 74 | 75 | -------------------------------------------------------------------------------- /wrist-rom-open/project/JLinkSettings.ini: -------------------------------------------------------------------------------- 1 | [BREAKPOINTS] 2 | ShowInfoWin = 1 3 | EnableFlashBP = 2 4 | BPDuringExecution = 0 5 | [CFI] 6 | CFISize = 0x00 7 | CFIAddr = 0x00 8 | [CPU] 9 | OverrideMemMap = 0 10 | AllowSimulation = 1 11 | ScriptFile="" 12 | [FLASH] 13 | CacheExcludeSize = 0x00 14 | CacheExcludeAddr = 0x00 15 | MinNumBytesFlashDL = 0 16 | SkipProgOnCRCMatch = 1 17 | VerifyDownload = 1 18 | AllowCaching = 1 19 | EnableFlashDL = 2 20 | Override = 0 21 | Device="UNSPECIFIED" 22 | [GENERAL] 23 | WorkRAMSize = 0x00 24 | WorkRAMAddr = 0x00 25 | RAMUsageLimit = 0x00 26 | [SWO] 27 | SWOLogFile="" 28 | [MEM] 29 | RdOverrideOrMask = 0x00 30 | RdOverrideAndMask = 0xFFFFFFFF 31 | RdOverrideAddr = 0xFFFFFFFF 32 | WrOverrideOrMask = 0x00 33 | WrOverrideAndMask = 0xFFFFFFFF 34 | WrOverrideAddr = 0xFFFFFFFF 35 | --------------------------------------------------------------------------------