Main project file that contain core program handling and initialization. More...
Functions | |
BLE_NUS_DEF (m_nus, NRF_SDH_BLE_TOTAL_LINK_COUNT) | |
BLE NUS service instance. More... | |
NRF_BLE_GATT_DEF (m_gatt) | |
GATT module instance. More... | |
NRF_BLE_QWR_DEF (m_qwr) | |
Context for the Queued Write module. More... | |
BLE_ADVERTISING_DEF (m_advertising) | |
Advertising module instance. More... | |
void | hallEffectInterrupt_handler (void) |
Hall Effect button Interrupt handler. More... | |
void | limitSwitchBottom_handler (void) |
Bottom limit switch Interrupt handler. More... | |
void | limitSwitchTop_handler (void) |
Upper limit switch Interrupt handler. More... | |
void | TMP_temp_Alert_Interrupt_handler (void) |
TMP117 Temperature Alert Interrupt handler. More... | |
void | motionSensorInterrupt_handler (void) |
ICM20948 Motion Sensor Interrupt handler. More... | |
void | assert_nrf_callback (uint16_t line_num, const uint8_t *p_file_name) |
Callback function for asserts in the SoftDevice. More... | |
void | pm_evt_handler (pm_evt_t const *p_evt) |
Function for handling Peer Manager events. More... | |
void | gatt_evt_handler (nrf_ble_gatt_t *p_gatt, nrf_ble_gatt_evt_t const *p_evt) |
Function for handling events from the GATT library. More... | |
void | menu_handler (ble_evt_t const *p_evt) |
Function for handling data received to the application. More... | |
void | uart_event_handle (app_uart_evt_t *p_event) |
Function for handling app_uart events. More... | |
void | idle_state_handle (void) |
More... | |
void | gatt_init (void) |
Function for initializing the GATT library. More... | |
void | sleep_mode_enter (void) |
Function for putting the chip into sleep mode. More... | |
void | nus_send (uint8_t data[], uint16_t length) |
Send data over BLE Nordic UART Service (NUS) More... | |
void | advertising_start (bool erase_bonds) |
Function for starting advertising. More... | |
void | HFCLKstart () |
Start HFCLK from crystal oscillator, this will give the PWM and SAADC higher accuracy. More... | |
void | BLEdisconnect () |
Disconnect BLE connection. More... | |
void | disableAdvOnDisconnect (void) |
disable restarted advertising upon disconnection. More... | |
void | enableAdvOnDisconnect (void) |
enable restarted advertising upon disconnection. More... | |
bool | BLEconnected () |
Check if connected to client. More... | |
void | stopAdvertising () |
stop advertising More... | |
void | readTMP117 (uint8_t *tempMSB, uint8_t *tempLSB) |
Read TMP117 16 bit temperature register. More... | |
int | main (void) |
Function for application main entry. More... | |
Variables | |
bool | getValue = false |
Menu is waiting for value from BLE application. More... | |
bool | transferDataFlag = false |
Menu is in the process of transfering data to BLE application. More... | |
bool | updateFSM = true |
Init to true in order to access state machine. More... | |
bool | sendNUS = false |
Flag to signal Nordic UART Service to send data. More... | |
bool | motorStopped = false |
Flag to signal if motor is stopped or need to be stopped. More... | |
bool | isAdvertising = false |
Flag to signal if advertising or not. More... | |
mission_t | mission |
Create mission struct instance. More... | |
FSM_t | fsm |
Create Finite State Machine struct instance. More... | |
enum menu | currentMenu |
Create menu enumeration instance to keep track of menu operations. More... | |
Main project file that contain core program handling and initialization.
void advertising_start | ( | bool | erase_bonds | ) |
Function for starting advertising.
Callback function for asserts in the SoftDevice.
This function will be called in case of an assert in the SoftDevice, FAILUREstate is called to float buoyancy vehicle to surface and change LED.
[in] | line_num | Line number of the failing ASSERT call. |
[in] | file_name | File name of the failing ASSERT call. |
< Go to failure state to change LED to PINK and float to surface
< handle error
BLE_ADVERTISING_DEF | ( | m_advertising | ) |
Advertising module instance.
BLE_NUS_DEF | ( | m_nus | , |
NRF_SDH_BLE_TOTAL_LINK_COUNT | |||
) |
BLE NUS service instance.
bool BLEconnected | ( | void | ) |
Check if connected to client.
void BLEdisconnect | ( | void | ) |
Disconnect BLE connection.
void disableAdvOnDisconnect | ( | void | ) |
disable restarted advertising upon disconnection.
void enableAdvOnDisconnect | ( | void | ) |
enable restarted advertising upon disconnection.
void gatt_evt_handler | ( | nrf_ble_gatt_t * | p_gatt, |
nrf_ble_gatt_evt_t const * | p_evt | ||
) |
Function for handling events from the GATT library.
void gatt_init | ( | void | ) |
Function for initializing the GATT library.
This function sets up all the necessary GAP (Generic Access Profile) parameters of the device.
void hallEffectInterrupt_handler | ( | void | ) |
Hall Effect button Interrupt handler.
< Notify FSM that hall effect interrupt has occured
void HFCLKstart | ( | ) |
Start HFCLK from crystal oscillator, this will give the PWM and SAADC higher accuracy.
void idle_state_handle | ( | void | ) |
Function for handling the idle state (main loop).
If there is no pending log operation, then sleep until next the next event occurs.
void limitSwitchBottom_handler | ( | void | ) |
Bottom limit switch Interrupt handler.
void limitSwitchTop_handler | ( | void | ) |
Upper limit switch Interrupt handler.
int main | ( | void | ) |
Function for application main entry.
< Initialize PWM before anything else to avoid the LED on full strength when uninitialized.
< variable to measure motor speed while returning to lower limit switch
< Enable limit switches as soon as the possible to make sure they are enabled when motor is running
< make sure vehicle float to surface on reset.
< Call NUS data transmission by setting flag: sendNUS
void menu_handler | ( | ble_evt_t const * | p_evt | ) |
Function for handling data received to the application.
Function for handling received data to handle the menu system. The user type operate menu by numeric integer values, and set configuration values in integer or float values.
[in] | p_evt | Event received from the ble_event Module. |
< Copy written data from gatts to the application.
< option variable to hold the menu navigation value, when user navigate menu.
< delimiter ':' to separate incomming values, in case a datavalue follows the menu option -! depricated !
< char pointers to hold tokens from separated incoming data.
< tokenize incoming data separated by ':' - depricated, there are no longer a functional case where a second value is used in the menu handling
< GetValue: configuration value for mission (depth and time), PID, and threshold. transferDataFlag: to send file number to transfer_menu()
void motionSensorInterrupt_handler | ( | void | ) |
ICM20948 Motion Sensor Interrupt handler.
NRF_BLE_GATT_DEF | ( | m_gatt | ) |
GATT module instance.
NRF_BLE_QWR_DEF | ( | m_qwr | ) |
Context for the Queued Write module.
Send data over BLE Nordic UART Service (NUS)
[in] | data | string array to be sent over NUS |
[in] | length | Length of string array |
void pm_evt_handler | ( | pm_evt_t const * | p_evt | ) |
Function for handling Peer Manager events.
[in] | p_evt | Peer Manager event. |
Read TMP117 16 bit temperature register.
[out] | tempMSB | 8 most significant bits representing temperature |
[out] | tempLSB | 8 least significant bits representing temperature |
<Temperature register within TMP117
void sleep_mode_enter | ( | void | ) |
Function for putting the chip into sleep mode.
void stopAdvertising | ( | void | ) |
stop advertising
void TMP_temp_Alert_Interrupt_handler | ( | void | ) |
TMP117 Temperature Alert Interrupt handler.
void uart_event_handle | ( | app_uart_evt_t * | p_event | ) |
Function for handling app_uart events.
This function will receive the reply message from motor controller interface, through the app_uart module, and append it to a data buffer array. The data buffer will be summed to verify correct checksum and sent to receiveReply().
[in] | p_event | UART event |
< UART Rx - Receive reply from motor controller.
< Go to FAILUREstate() to change LED to PINK and float to surface
< Go to FAILUREstate() to change LED to PINK and float to surface
enum menu currentMenu |
Create menu enumeration instance to keep track of menu operations.
FSM_t fsm |
Create Finite State Machine struct instance.
bool getValue = false |
Menu is waiting for value from BLE application.
bool isAdvertising = false |
Flag to signal if advertising or not.
mission_t mission |
Create mission struct instance.
bool motorStopped = false |
Flag to signal if motor is stopped or need to be stopped.
bool sendNUS = false |
Flag to signal Nordic UART Service to send data.
bool transferDataFlag = false |
Menu is in the process of transfering data to BLE application.
bool updateFSM = true |
Init to true in order to access state machine.