rn4870  2.0.0.0
Functions
Public function

Functions

void rn4870_cfg_setup (rn4870_cfg_t *cfg)
 Config Object Initialization function. More...
 
RN4870_RETVAL rn4870_init (rn4870_t *ctx, rn4870_cfg_t *cfg)
 Initialization function. More...
 
void rn4870_default_cfg (rn4870_t *ctx)
 Click Default Configuration function. More...
 
void rn4870_reset (rn4870_t *ctx)
 Hardware reset function. More...
 
void rn4870_generic_write (rn4870_t *ctx, char *data_buf, uint16_t len)
 Generic write function. More...
 
int16_t rn4870_generic_read (rn4870_t *ctx, char *data_buf, uint16_t max_len)
 Generic read function. More...
 
void rn4870_uart_write (rn4870_t *ctx, uint8_t *tx_data)
 UART write function. More...
 
void rn4870_initialize (rn4870_t *ctx, char *dev_addr)
 Initialization RN4870 module. More...
 
void rn4870_connect (rn4870_t *ctx, char *dev_addr)
 Connecting to slave device. More...
 
void rn4870_disconnect (rn4870_t *ctx)
 Disconnecting from slave device. More...
 
void rn4870_send (rn4870_t *ctx, uint8_t msg_type, uint16_t data_type, uint8_t dev_id, uint8_t *tx_data)
 Send message function. More...
 
void rn4870_receive (rn4870_t *ctx, char character)
 Receiving character function. More...
 
uint8_t rn4870_read (rn4870_t *ctx, uint8_t *rx_data)
 Read received message function. More...
 
uint8_t rn4870_get_interrupt (rn4870_t *ctx)
 Get interrupt state function. More...
 
void rn4870_set_rst (rn4870_t *ctx)
 Set states of RST pin to high function. More...
 
void rn4870_clear_rst (rn4870_t *ctx)
 Clear states of RST pin function. More...
 
void rn4870_set_rts (rn4870_t *ctx)
 Set states of RTS pin function. More...
 
void rn4870_clear_rts (rn4870_t *ctx)
 Clear states of RTS pin function. More...
 
void rn4870_set_pwm (rn4870_t *ctx)
 Set states of PWM pin function. More...
 
void rn4870_clear_pwm (rn4870_t *ctx)
 Clear states of PWM pin function. More...
 
uint8_t rn4870_int_get (rn4870_t *ctx)
 Get interrupt state function. More...
 
void rn4870_rst_set (rn4870_t *ctx, uint8_t pin_state)
 Set states of RST pin to desired state. More...
 
void rn4870_cs_set (rn4870_t *ctx, uint8_t pin_state)
 Set states of CS pin to desired state. More...
 

Detailed Description

Function Documentation

◆ rn4870_cfg_setup()

void rn4870_cfg_setup ( rn4870_cfg_t cfg)

Config Object Initialization function.

Parameters
cfgClick configuration structure.

@description This function initializes click configuration structure to init state.

Note
All used pins will be set to unconnected state.

◆ rn4870_clear_pwm()

void rn4870_clear_pwm ( rn4870_t ctx)

Clear states of PWM pin function.

Parameters
ctxClick object.

@description The function clear states of PWM pin by sets states of PWM pin to low.

◆ rn4870_clear_rst()

void rn4870_clear_rst ( rn4870_t ctx)

Clear states of RST pin function.

Parameters
ctxClick object.

@description The function clear states of RST pin by sets states of RST pin to low.

◆ rn4870_clear_rts()

void rn4870_clear_rts ( rn4870_t ctx)

Clear states of RTS pin function.

Parameters
ctxClick object.

@description The function clear states of RTS pin by sets states of CS pin to low.

◆ rn4870_connect()

void rn4870_connect ( rn4870_t ctx,
char *  dev_addr 
)

Connecting to slave device.

Parameters
ctxClick object.
dev_addrPointer to the memory location where slave device with be stored

@description The function connects to slave device with desired register address by secures the connection and entering data stream mode.

◆ rn4870_cs_set()

void rn4870_cs_set ( rn4870_t ctx,
uint8_t  pin_state 
)

Set states of CS pin to desired state.

Parameters
ctxClick object.
pin_stateState of pin to be set.

@description The function set states of CS pin desired state.

◆ rn4870_default_cfg()

void rn4870_default_cfg ( rn4870_t ctx)

Click Default Configuration function.

Parameters
ctxClick object.

@description This function executes default configuration for Rn4870 click.

◆ rn4870_disconnect()

void rn4870_disconnect ( rn4870_t ctx)

Disconnecting from slave device.

Parameters
ctxClick object.

@description The function disconnects from slave device by enters CMD mode and kills connection.

◆ rn4870_generic_read()

int32_t rn4870_generic_read ( rn4870_t ctx,
char *  data_buf,
uint16_t  max_len 
)

Generic read function.

Parameters
ctxClick object.
data_bufBuffer to be write.
max_lenLength of data to be read.

@description This function read buffer of maximum length

Parameters
ctxClick object.
data_bufBuffer to be write.
max_lenLength of data to be read.
Returns
number of read bytes

@description This function read buffer of maximum length

◆ rn4870_generic_write()

void rn4870_generic_write ( rn4870_t ctx,
char *  data_buf,
uint16_t  len 
)

Generic write function.

Parameters
ctxClick object.
data_bufBuffer to be write.
lenLength of data to be write.

@description This function write buffer of specific length

◆ rn4870_get_interrupt()

uint8_t rn4870_get_interrupt ( rn4870_t ctx)

Get interrupt state function.

Parameters
ctxClick object.
Returns
interrupt state ( 0 : not active, 1 : active )

@description The function gets interrupt state by return status of INT pin.

◆ rn4870_init()

RN4870_RETVAL rn4870_init ( rn4870_t ctx,
rn4870_cfg_t cfg 
)

Initialization function.

Parameters
ctxClick object.
cfgClick configuration structure.

@description This function initializes all necessary pins and peripherals used for this click.

◆ rn4870_initialize()

void rn4870_initialize ( rn4870_t ctx,
char *  dev_addr 
)

Initialization RN4870 module.

Parameters
ctxClick object.
dev_addrPointer to the memory location where dev_addr be stored

@description The function initializes RN4870 Bluetooth� 4.2 low energy module by resets the RN4870 module, disable I2C communications pins, reboots the device for change to take effect, enters CMD mode again, and sets the address of the device.

◆ rn4870_int_get()

uint8_t rn4870_int_get ( rn4870_t ctx)

Get interrupt state function.

Parameters
ctxClick object.
Returns
interrupt state ( 0 : not active, 1 : active )

@description The function gets interrupt state by return status of INT pin.

◆ rn4870_read()

uint8_t rn4870_read ( rn4870_t ctx,
uint8_t *  rx_data 
)

Read received message function.

Reading received message.

Parameters
ctxClick object.
rx_datapointer to the memory location where the read text data is stored
Return values
<pre>
  • 0 : if whole and properly formated message was not received and stored
  • 1 : if whole and properly formated message was received and stored

@description The function check message from if data received ( if flag was set ), stores received message to rx_data pointer to the memory location where the read text data is stored and replaces '*' - character with end of string - '0x00'.

Parameters
ctxClick object.
process_bufferBuffer for storing received message
Returns
1 if whole and properly formated message was received and stored; 0 if not

@description This function gets message from 'void rn4870_receive function if flag was set This function replaces '*' (character with end of string) with '0x00' and stores received message to process_buffer

◆ rn4870_receive()

void rn4870_receive ( rn4870_t ctx,
char  character 
)

Receiving character function.

Parameters
ctxClick object.
characterReceived character

@description The function receives character by waits for '#' - character to start parsing message, waits for '*' - character to stop parsing message and sets flag if whole and properly formated message is received.

Parameters
ctxClick object.
tmpReceived character

@description The function receives character by waits for '#' - character to start parsing message, waits for '*' - character to stop parsing message and sets flag if whole and properly formated message is received.

◆ rn4870_reset()

void rn4870_reset ( rn4870_t ctx)

Hardware reset function.

Parameters
ctxClick object.

@description The function Hardware reset - resets the RN4870 Bluetooth� 4.2 low energy module by cleared to '0' RST state pin, wait for 100 ms, set to '1' RST state pin and wait for 200 ms.

Note
Delay is 300 ms.

◆ rn4870_rst_set()

void rn4870_rst_set ( rn4870_t ctx,
uint8_t  pin_state 
)

Set states of RST pin to desired state.

Parameters
ctxClick object.
pin_stateState of pin to be set.

@description The function set states of RST desired state.

◆ rn4870_send()

void rn4870_send ( rn4870_t ctx,
uint8_t  msg_type,
uint16_t  data_type,
uint8_t  dev_id,
uint8_t *  tx_data 
)

Send message function.

Parameters
ctxClick object.
msg_type8-bit message type ( e.g. message - 'M' = 0x4D )
data_type16-bit data type ( e.g. sensor 1 - S1 = 0x5331 )
dev_id8-bit device id ( e.g. slave - 'S' = 0x53 )
tx_dataPointer to the memory location where the text data is stored

@description The function sends message to slave device.

◆ rn4870_set_pwm()

void rn4870_set_pwm ( rn4870_t ctx)

Set states of PWM pin function.

Parameters
ctxClick object.

@description The function set states of PWM pin by sets states of PWM pin to high.

◆ rn4870_set_rst()

void rn4870_set_rst ( rn4870_t ctx)

Set states of RST pin to high function.

Parameters
ctxClick object.

@description The function set states of RST pin to high.

◆ rn4870_set_rts()

void rn4870_set_rts ( rn4870_t ctx)

Set states of RTS pin function.

Parameters
ctxClick object.

@description The function set states of RST pin by sets states of CS pin to high.

◆ rn4870_uart_write()

void rn4870_uart_write ( rn4870_t ctx,
uint8_t *  tx_data 
)

UART write function.

Parameters
ctxClick object.
tx_dataTx buffer

@description This function is for UART writing