Master Thesis  V1.0
Research and Design of Sensor Node for NMSD Treatment
ble.h
Go to the documentation of this file.
1 /***************************************************************************/
8 /*
9  * ble.h
10  *
11  * Created on: Nov 27, 2019
12  * Author: jonac
13  */
14 
15 #ifndef BLE_BLE_H_
16 #define BLE_BLE_H_
17 
18 #include <stdint.h>
19 #include <stdbool.h>
20 
21 
22 #define DIY 1
23 
25 #define BUFFER_SIZE 80
27 
28 #define BLE_ERROR 99
29 
31 #define BLE_POWER_PIN 11
32 #define BLE_POWER_PORT gpioPortB
33 #define BLE_PIN_TX 0
34 #define BLE_PIN_RX 1
35 #define BLE_PORT gpioPortC
36 #define BLE_USART USART1
37 
38 #if DIY == 0
39 #define BLE_LED2_PIN 10
40 #define BLE_LED2_PORT gpioPortE
41 #endif
42 
43 #if DIY == 1
44 #define BLE_LED2_PIN 10
45 #define BLE_LED2_PORT gpioPortA
46 #endif
47 
48 #define BLE_OUTPUT_POWER_4DB 0x04
49 #define BLE_OUTPUT_POWER_0DB 0x00
50 #define BLE_OUTPUT_POWER_N4DB 0xFC
51 #define BLE_OUTPUT_POWER_N8DB 0xF8
52 #define BLE_OUTPUT_POWER_N12DB 0xF4
53 #define BLE_OUTPUT_POWER_N16DB 0xF0
54 #define BLE_OUTPUT_POWER_N20DB 0xEC
55 #define BLE_OUTPUT_POWER_N40DB 0xD8
56 
57 
59 
61 
62 
63 
64 
65 
67 void BLE_power(bool enable);
68 void BLE_Init();
69 void BLE_rxtx_enable(bool enable);
70 void BLE_connect();
71 void BLE_check_connect();
72 void BLE_disconnect();
73 void BLE_sendData4(uint8_t data_in[]);
74 void BLE_sendData( uint8_t *data, uint8_t *batt, uint8_t length, uint8_t *ble_packet );
75 void BLE_readData( uint8_t *readData, uint8_t length );
76 
77 void BLE_sendIMUData(uint8_t *gyroData, uint8_t *accelData, uint8_t *magnData);
78 
79 void float_to_uint8_t( float *input, uint8_t *out );
80 void float_to_uint8_t_x3( float *input, uint8_t *out );
81 
82 void BLE_set_output_power( uint8_t power );
84 
85 #endif /* BLE_BLE_H_ */
BLE_sendData4
void BLE_sendData4(uint8_t data_in[])
Test function, not used.
Definition: ble.c:212
data
MeasurementData_t data
Definition: main.c:122
float_to_uint8_t_x3
void float_to_uint8_t_x3(float *input, uint8_t *out)
Float to uint8_t conversion x3.
Definition: ble.c:419
BLE_sendIMUData
void BLE_sendIMUData(uint8_t *gyroData, uint8_t *accelData, uint8_t *magnData)
Test function, not used.
Definition: ble.c:334
BLE_Init
void BLE_Init()
BLE chip init.
Definition: ble.c:61
RX_buffer
char RX_buffer[BUFFER_SIZE]
Definition: ble.h:26
BLE_rxtx_enable
void BLE_rxtx_enable(bool enable)
Enable disable RX/TX pins from BLE module.
Definition: ble.c:128
BLE_connect
void BLE_connect()
Connect sequence BLE.
Definition: ble.c:152
BLE_disconnect
void BLE_disconnect()
Disconnect BLE from receiver.
Definition: ble.c:195
BUFFER_SIZE
#define BUFFER_SIZE
Definition: ble.h:25
BLE_set_output_power
void BLE_set_output_power(uint8_t power)
Set BLE output power.
Definition: ble.c:441
float_to_uint8_t
void float_to_uint8_t(float *input, uint8_t *out)
Float to uint8_t conversion.
Definition: ble.c:391
BLE_check_connect
void BLE_check_connect()
Check if LED pin on BLE is high to check if the module is connected to a receiver.
Definition: ble.c:179
BLE_power
void BLE_power(bool enable)
Turn power on/off for BLE module.
Definition: ble.c:84
BLE_readData
void BLE_readData(uint8_t *readData, uint8_t length)
Test function, not used.
Definition: ble.c:308
BLE_sendData
void BLE_sendData(uint8_t *data, uint8_t *batt, uint8_t length, uint8_t *ble_packet)
Send all the data over BLE.
Definition: ble.c:261