Wallbot_CaaS
Dependencies: MPU6050 mbed PID
Fork of BLE_MPU6050_test6_challenge_sb by
ble_dtm.h
00001 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. 00002 * 00003 * The information contained herein is property of Nordic Semiconductor ASA. 00004 * Terms and conditions of usage are described in detail in NORDIC 00005 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 00006 * 00007 * Licensees are granted free, non-transferable use of the information. NO 00008 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 00009 * the file. 00010 * 00011 */ 00012 00013 /** @file 00014 * 00015 * @defgroup ble_sdk_dtmlib_dtm DTM - Direct Test Mode 00016 * @{ 00017 * @ingroup ble_sdk_lib 00018 * @brief Module for testing RF/PHY using DTM commands. 00019 */ 00020 00021 #ifndef BLE_DTM_H__ 00022 #define BLE_DTM_H__ 00023 00024 #include <stdint.h> 00025 #include <stdbool.h> 00026 00027 00028 /**@brief Configuration parameters. */ 00029 #define DEFAULT_TX_POWER RADIO_TXPOWER_TXPOWER_Pos4dBm /**< Default Transmission power using in the DTM module. */ 00030 #define DEFAULT_TIMER NRF_TIMER0 /**< Default timer used for timing. */ 00031 #define DEFAULT_TIMER_IRQn TIMER0_IRQn /**< IRQ used for timer. NOTE: MUST correspond to DEFAULT_TIMER. */ 00032 00033 /**@brief BLE DTM command codes. */ 00034 typedef uint32_t dtm_cmd_t; /**< DTM command type. */ 00035 00036 #define LE_RESET 0 /**< DTM command: Reset device. */ 00037 #define LE_RECEIVER_TEST 1 /**< DTM command: Start receive test. */ 00038 #define LE_TRANSMITTER_TEST 2 /**< DTM command: Start transmission test. */ 00039 #define LE_TEST_END 3 /**< DTM command: End test and send packet report. */ 00040 00041 // Configuration options used as parameter 2 00042 // when cmd == LE_TRANSMITTER_TEST and payload == DTM_PKT_VENDORSPECIFIC 00043 // Configuration value, if any, is supplied in parameter 3 00044 00045 #define CARRIER_TEST 0 /**< Length=0 indicates a constant, unmodulated carrier until LE_TEST_END or LE_RESET */ 00046 #define CARRIER_TEST_STUDIO 1 /**< nRFgo Studio uses value 1 in length field, to indicate a constant, unmodulated carrier until LE_TEST_END or LE_RESET */ 00047 #define SET_TX_POWER 2 /**< Set transmission power, value -40..+4 dBm in steps of 4 */ 00048 #define SELECT_TIMER 3 /**< Select on of the 16 MHz timers 0, 1 or 2 */ 00049 00050 #define LE_PACKET_REPORTING_EVENT 0x8000 /**< DTM Packet reporting event, returned by the device to the tester. */ 00051 #define LE_TEST_STATUS_EVENT_SUCCESS 0x0000 /**< DTM Status event, indicating success. */ 00052 #define LE_TEST_STATUS_EVENT_ERROR 0x0001 /**< DTM Status event, indicating an error. */ 00053 00054 #define DTM_PKT_PRBS9 0x00 /**< Bit pattern PRBS9. */ 00055 #define DTM_PKT_0X0F 0x01 /**< Bit pattern 11110000 (LSB is the leftmost bit). */ 00056 #define DTM_PKT_0X55 0x02 /**< Bit pattern 10101010 (LSB is the leftmost bit). */ 00057 #define DTM_PKT_VENDORSPECIFIC 0xFFFFFFFF /**< Vendor specific. Nordic: Continuous carrier test, or configuration. */ 00058 00059 /**@brief Return codes from dtm_cmd(). */ 00060 #define DTM_SUCCESS 0x00 /**< Indicate that the DTM function completed with success. */ 00061 #define DTM_ERROR_ILLEGAL_CHANNEL 0x01 /**< Physical channel number must be in the range 0..39. */ 00062 #define DTM_ERROR_INVALID_STATE 0x02 /**< Sequencing error: Command is not valid now. */ 00063 #define DTM_ERROR_ILLEGAL_LENGTH 0x03 /**< Payload size must be in the range 0..37. */ 00064 #define DTM_ERROR_ILLEGAL_CONFIGURATION 0x04 /**< Parameter out of range (legal range is function dependent). */ 00065 #define DTM_ERROR_UNINITIALIZED 0x05 /**< DTM module has not been initialized by the application. */ 00066 00067 // Note: DTM_PKT_VENDORSPECIFIC, is not a packet type 00068 #define PACKET_TYPE_MAX DTM_PKT_0X55 /**< Highest value allowed as DTM Packet type. */ 00069 00070 /** @brief BLE DTM event type. */ 00071 typedef uint32_t dtm_event_t; /**< Type for handling DTM event. */ 00072 00073 /** @brief BLE DTM frequency type. */ 00074 typedef uint32_t dtm_freq_t; /**< Physical channel, valid range: 0..39. */ 00075 00076 /**@brief BLE DTM packet types. */ 00077 typedef uint32_t dtm_pkt_type_t; /**< Type for holding the requested DTM payload type.*/ 00078 00079 00080 /**@brief Function for initializing or re-initializing DTM module 00081 * 00082 * @return DTM_SUCCESS on successful initialization of the DTM module. 00083 */ 00084 uint32_t dtm_init(void); 00085 00086 00087 /**@brief Function for giving control to dtmlib for handling timer and radio events. 00088 * Will return to caller at 625us intervals or whenever another event than radio occurs 00089 * (such as UART input). Function will put MCU to sleep between events. 00090 * 00091 * @return Time counter, incremented every 625 us. 00092 */ 00093 uint32_t dtm_wait(void); 00094 00095 00096 /**@brief Function for calling when a complete command has been prepared by the Tester. 00097 * 00098 * @param[in] cmd One of the DTM_CMD values (bits 14:15 in the 16-bit UART format). 00099 * @param[in] freq Phys. channel no - actual frequency = (2402 + freq * 2) MHz (bits 8:13 in 00100 * the 16-bit UART format). 00101 * @param[in] length Payload length, 0..37 (bits 2:7 in the 16-bit UART format). 00102 * @param[in] payload One of the DTM_PKT values (bits 0:1 in the 16-bit UART format). 00103 * 00104 * @return DTM_SUCCESS or one of the DTM_ERROR_ values 00105 */ 00106 uint32_t dtm_cmd(dtm_cmd_t cmd, dtm_freq_t freq, uint32_t length, dtm_pkt_type_t payload); 00107 00108 00109 /**@brief Function for reading the result of a DTM command 00110 * 00111 * @param[out] p_dtm_event Pointer to buffer for 16 bit event code according to DTM standard. 00112 * 00113 * @return true: new event, false: no event since last call, this event has been read earlier 00114 */ 00115 bool dtm_event_get(dtm_event_t * p_dtm_event); 00116 00117 00118 /**@brief Function for configuring the timer to use. 00119 * 00120 * @note Must be called when no DTM test is running. 00121 * 00122 * @param[in] new_timer Index (0..2) of timer to be used by the DTM library 00123 * 00124 * @return true: success, new timer was selected, false: parameter error 00125 */ 00126 bool dtm_set_timer(uint32_t new_timer); 00127 00128 00129 /**@brief Function for configuring the transmit power. 00130 * 00131 * @note Must be called when no DTM test is running. 00132 * 00133 * @param[in] new_tx_power New output level, +4..-40, in steps of 4. 00134 * 00135 * @return true: tx power setting changed, false: parameter error 00136 */ 00137 bool dtm_set_txpower(uint32_t new_tx_power); 00138 00139 #endif // BLE_DTM_H__ 00140 00141 /** @} */
Generated on Tue Jul 12 2022 18:33:09 by 1.7.2