upm  0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Data Structures
hal_aci_tl.h File Reference
Include dependency graph for hal_aci_tl.h:

Go to the source code of this file.

Data Structures

struct  _aci_packed_
 Structure for the ACI_CMD_SET_LOCAL_DATA ACI command parameters. More...
 
#define HAL_ACI_MAX_LENGTH   31
 Module for the ACI Transport Layer interface. More...
 
#define UNUSED   255
 
 ACI_ASSERT_SIZE (hal_aci_data_t, HAL_ACI_MAX_LENGTH+2)
 
void hal_aci_tl_init (aci_pins_t *a_pins, bool debug)
 ACI Transport Layer initialization. More...
 
bool hal_aci_tl_send (hal_aci_data_t *aci_buffer)
 Sends an ACI command to the radio. More...
 
hal_aci_data_t * hal_aci_tl_poll_get (void)
 Process pending transactions. More...
 
bool hal_aci_tl_event_get (hal_aci_data_t *p_aci_data)
 Get an ACI event from the event queue. More...
 
bool hal_aci_tl_event_peek (hal_aci_data_t *p_aci_data)
 Peek an ACI event from the event queue. More...
 
void hal_aci_tl_debug_print (bool enable)
 Enable debug printing of all ACI commands sent and ACI events received. More...
 
void hal_aci_tl_pin_reset (void)
 Pin reset the nRF8001. More...
 
bool hal_aci_tl_rx_q_full (void)
 Return full status of transmit queue.
 
bool hal_aci_tl_rx_q_empty (void)
 Return empty status of receive queue.
 
bool hal_aci_tl_tx_q_full (void)
 Return full status of receive queue.
 
bool hal_aci_tl_tx_q_empty (void)
 Return empty status of transmit queue.
 
void hal_aci_tl_q_flush (void)
 Flush the ACI command Queue and the ACI Event Queue. More...
 

Function Documentation

void hal_aci_tl_init ( aci_pins_t *  a_pins,
bool  debug 
)

This function initializes the transport layer, including configuring the SPI, creating message queues for Commands and Events and setting up interrupt if required.

Parameters
a_pinsPins on the MCU used to connect to the nRF8001
boolTrue if debug printing should be enabled on the Serial.

Here is the call graph for this function:

Here is the caller graph for this function:

bool hal_aci_tl_send ( hal_aci_data_t *  aci_buffer)

This function sends an ACI command to the radio. This queue up the message to send and lower the request line. When the device lowers the ready line, m_aci_spi_transfer() will send the data.

Parameters
aci_bufferPointer to the message to send.
Returns
True if the data was successfully queued for sending, false if there is no more space to store messages to send.

Here is the caller graph for this function:

hal_aci_data_t* hal_aci_tl_poll_get ( void  )

The library code takes care of calling this function to check if the nRF8001 RDYN line indicates a pending transaction. It will send a pending message if there is one and return any receive message that was pending.

Returns
Points to data buffer for received data. Length byte in buffer is 0 if no data received.
bool hal_aci_tl_event_get ( hal_aci_data_t *  p_aci_data)

Call this function from the main context to get an event from the ACI event queue This is called by lib_aci_event_get

Here is the caller graph for this function:

bool hal_aci_tl_event_peek ( hal_aci_data_t *  p_aci_data)

Call this function from the main context to peek an event from the ACI event queue. This is called by lib_aci_event_peek

Here is the caller graph for this function:

void hal_aci_tl_debug_print ( bool  enable)

when the enable parameter is true. The debug printing is enabled on the Serial. When the enable parameter is false. The debug printing is disabled on the Serial. By default the debug printing is disabled.

Here is the caller graph for this function:

void hal_aci_tl_pin_reset ( void  )

The reset line of the nF8001 needs to kept low for 200 ns. Redbearlab shield v1.1 and v2012.07 are exceptions as they have a Power ON Reset circuit that works differently. The function handles the exceptions based on the board_name in aci_pins_t

Here is the caller graph for this function:

void hal_aci_tl_q_flush ( void  )

Call this function in the main thread

Here is the caller graph for this function:

Macro Definition Documentation

#define HAL_ACI_MAX_LENGTH   31

This module is responsible for sending and receiving messages over the ACI interface of the nRF8001 chip. The hal_aci_tl_send_cmd() can be called directly to send ACI commands.

The RDYN line is hooked to an interrupt on the MCU when the level is low. The SPI master clocks in the interrupt context. The ACI Command is taken from the head of the command queue is sent over the SPI and the received ACI event is placed in the tail of the event queue.