bluetooth_2 2.0.0.0
Bluetooth 2 Click Driver

API for configuring and manipulating Bluetooth 2 Click driver. More...

Topics

 Bluetooth 2 Registers Settings
 Settings for registers of Bluetooth 2 Click driver.
 
 Bluetooth 2 MikroBUS Map
 MikroBUS pin mapping of Bluetooth 2 Click driver.
 

Functions

void bluetooth2_cfg_setup (bluetooth2_cfg_t *cfg)
 Bluetooth 2 configuration object setup function.
 
err_t bluetooth2_init (bluetooth2_t *ctx, bluetooth2_cfg_t *cfg)
 Bluetooth 2 initialization function.
 
void bluetooth2_default_cfg (bluetooth2_t *ctx)
 Bluetooth 2 default configuration function.
 
err_t bluetooth2_generic_write (bluetooth2_t *ctx, char *data_buf, uint16_t len)
 Bluetooth 2 data writing function.
 
err_t bluetooth2_generic_read (bluetooth2_t *ctx, char *data_buf, uint16_t max_len)
 Bluetooth 2 data reading function.
 
err_t bluetooth2_read_an_pin_value (bluetooth2_t *ctx, uint16_t *data_out)
 Bluetooth 2 read AN pin value function.
 
err_t bluetooth2_read_an_pin_voltage (bluetooth2_t *ctx, float *data_out)
 Bluetooth 2 read AN pin voltage level function.
 
void bluetooth2_set_cts_pin (bluetooth2_t *ctx, uint8_t state)
 Bluetooth 2 set clear to send pin function.
 
void bluetooth2_set_rst_pin (bluetooth2_t *ctx, uint8_t state)
 Bluetooth 2 set reset pin function.
 
void bluetooth2_set_io7_pin (bluetooth2_t *ctx, uint8_t state)
 Bluetooth 2 set PIO7 pin function.
 
uint8_t bluetooth2_get_rts_pin (bluetooth2_t *ctx)
 Bluetooth 2 get request to send pin function.
 
err_t bluetooth2_write_command (bluetooth2_t *ctx, char *data_buf)
 Bluetooth 2 write command function.
 
void bluetooth2_hw_reset (bluetooth2_t *ctx)
 Bluetooth 2 hw reset function.
 
err_t bluetooth2_toggle_mode (bluetooth2_t *ctx)
 Bluetooth 2 toggle mode function.
 
err_t bluetooth2_factory_reset (bluetooth2_t *ctx)
 Bluetooth 2 factory reset function.
 
err_t bluetooth2_sw_reset (bluetooth2_t *ctx)
 Bluetooth 2 sw reset function.
 
err_t bluetooth2_remove_pairings (bluetooth2_t *ctx)
 Bluetooth 2 remove pairings function.
 
err_t bluetooth2_list_pairings (bluetooth2_t *ctx)
 Bluetooth 2 list current pairings function.
 
err_t bluetooth2_set_device_name (bluetooth2_t *ctx, char *dev_name)
 Bluetooth 2 set local device name function.
 
err_t bluetooth2_find_other_devices (bluetooth2_t *ctx, uint8_t timeout)
 Bluetooth 2 find other devices function.
 
err_t bluetooth2_pair (bluetooth2_t *ctx, uint8_t *dev_addr)
 Bluetooth 2 set local device name function.
 
err_t bluetooth2_enable_ok_response (bluetooth2_t *ctx)
 Bluetooth 2 enable OK response function.
 

Detailed Description

API for configuring and manipulating Bluetooth 2 Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ bluetooth2_cfg_setup()

void bluetooth2_cfg_setup ( bluetooth2_cfg_t * cfg)

Bluetooth 2 configuration object setup function.

This function initializes click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See bluetooth2_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ bluetooth2_default_cfg()

void bluetooth2_default_cfg ( bluetooth2_t * ctx)

Bluetooth 2 default configuration function.

This function executes a default configuration of Bluetooth 2 click board.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
Returns
None.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ bluetooth2_enable_ok_response()

err_t bluetooth2_enable_ok_response ( bluetooth2_t * ctx)

Bluetooth 2 enable OK response function.

This function enables OK response. The module will display "OK." after each successful command.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
Returns
  • >=0 - Success,
  • <0 - Error.
See #err_t definition for detailed explanation.
Note
This will set optional_block_1 and config_block of CONTROL CONFIG reg to 0040 1100 (default).

◆ bluetooth2_factory_reset()

err_t bluetooth2_factory_reset ( bluetooth2_t * ctx)

Bluetooth 2 factory reset function.

This function factory resets the device.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
Returns
  • >=0 - Success,
  • <0 - Error.
See #err_t definition for detailed explanation.
Note
Factory reset does not clear the pairings.

◆ bluetooth2_find_other_devices()

err_t bluetooth2_find_other_devices ( bluetooth2_t * ctx,
uint8_t timeout )

Bluetooth 2 find other devices function.

This function is used to find other Bluetooth devices in the area i.e. to make a device discovery.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
[in]timeout: The maximum amount of time (in units of 1.28 seconds) before the inquiry process is halted. Range: 1-48.
Returns
  • >=0 - Success,
  • <0 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bluetooth2_generic_read()

err_t bluetooth2_generic_read ( bluetooth2_t * ctx,
char * data_buf,
uint16_t max_len )

Bluetooth 2 data reading function.

This function reads a desired number of data bytes by using UART serial interface.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
[out]data_buf: Output read data.
[in]max_len: Number of bytes to be read.
Returns
  • >0 - Number of data bytes read,
  • <=0 - Error/Empty Ring buffer.
See #err_t definition for detailed explanation.
Note
None.

◆ bluetooth2_generic_write()

err_t bluetooth2_generic_write ( bluetooth2_t * ctx,
char * data_buf,
uint16_t len )

Bluetooth 2 data writing function.

This function writes a desired number of data bytes by using UART serial interface.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
[in]data_buf: Data buffer for sending.
[in]len: Number of bytes for sending.
Returns
  • >=0 - Success,
  • <0 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bluetooth2_get_rts_pin()

uint8_t bluetooth2_get_rts_pin ( bluetooth2_t * ctx)

Bluetooth 2 get request to send pin function.

This function returns the RTS pin logic state.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
Returns
Pin logic state.
Note
None.

◆ bluetooth2_hw_reset()

void bluetooth2_hw_reset ( bluetooth2_t * ctx)

Bluetooth 2 hw reset function.

This function resets the module by toggling the RST pin.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
Returns
None.
Note
None.

◆ bluetooth2_init()

err_t bluetooth2_init ( bluetooth2_t * ctx,
bluetooth2_cfg_t * cfg )

Bluetooth 2 initialization function.

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

Parameters
[out]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See bluetooth2_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bluetooth2_list_pairings()

err_t bluetooth2_list_pairings ( bluetooth2_t * ctx)

Bluetooth 2 list current pairings function.

This function lists all current pairings.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
Returns
  • >=0 - Success,
  • <0 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bluetooth2_pair()

err_t bluetooth2_pair ( bluetooth2_t * ctx,
uint8_t * dev_addr )

Bluetooth 2 set local device name function.

This function sets the local device name.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
[in]dev_addr: Bluetooth device address of the remote device in format xx:xx:xx:xx:xx:xx where x is a hexadecimal digit.
Returns
  • >=0 - Success,
  • <0 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bluetooth2_read_an_pin_value()

err_t bluetooth2_read_an_pin_value ( bluetooth2_t * ctx,
uint16_t * data_out )

Bluetooth 2 read AN pin value function.

This function reads results of AD conversion of the AN pin.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
[out]data_out: Output ADC result.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bluetooth2_read_an_pin_voltage()

err_t bluetooth2_read_an_pin_voltage ( bluetooth2_t * ctx,
float * data_out )

Bluetooth 2 read AN pin voltage level function.

This function reads results of AD conversion of the AN pin and converts them to proportional voltage level.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
[out]data_out: Output voltage level of the analog pin [V].
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
The conversion to voltage depends on the entered configuration of the ADC (resolution, reference voltage).

◆ bluetooth2_remove_pairings()

err_t bluetooth2_remove_pairings ( bluetooth2_t * ctx)

Bluetooth 2 remove pairings function.

This function removes all the device pairings.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
Returns
  • >=0 - Success,
  • <0 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bluetooth2_set_cts_pin()

void bluetooth2_set_cts_pin ( bluetooth2_t * ctx,
uint8_t state )

Bluetooth 2 set clear to send pin function.

This function sets the CTS pin to a desired state.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
[in]state: Pin logic state.
Returns
None.
Note
None.

◆ bluetooth2_set_device_name()

err_t bluetooth2_set_device_name ( bluetooth2_t * ctx,
char * dev_name )

Bluetooth 2 set local device name function.

This function sets the local device name.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
[in]dev_name: Device name ( up to 140 characters ).
Returns
  • >=0 - Success,
  • <0 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bluetooth2_set_io7_pin()

void bluetooth2_set_io7_pin ( bluetooth2_t * ctx,
uint8_t state )

Bluetooth 2 set PIO7 pin function.

This function sets the PIO7 pin to a desired state.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
[in]state: Pin logic state.
Returns
None.
Note
None.

◆ bluetooth2_set_rst_pin()

void bluetooth2_set_rst_pin ( bluetooth2_t * ctx,
uint8_t state )

Bluetooth 2 set reset pin function.

This function sets the RST pin to a desired state.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
[in]state: Pin logic state.
Returns
None.
Note
None.

◆ bluetooth2_sw_reset()

err_t bluetooth2_sw_reset ( bluetooth2_t * ctx)

Bluetooth 2 sw reset function.

This function sw resets the device.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
Returns
  • >=0 - Success,
  • <0 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bluetooth2_toggle_mode()

err_t bluetooth2_toggle_mode ( bluetooth2_t * ctx)

Bluetooth 2 toggle mode function.

This function is used to toggle between command mode and data mode by issuing the escape sequence.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
Returns
  • >=0 - Success,
  • <0 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ bluetooth2_write_command()

err_t bluetooth2_write_command ( bluetooth2_t * ctx,
char * data_buf )

Bluetooth 2 write command function.

This function sends a desired command with the CR byte appended to.

Parameters
[in]ctx: Click context object. See bluetooth2_t object definition for detailed explanation.
[in]data_buf: Command string.
Returns
  • >=0 - Success,
  • <0 - Error.
See #err_t definition for detailed explanation.
Note
None.