nplc 2.1.0.0
N-PLC Click Driver

API for configuring and manipulating N-PLC Click driver. More...

Topics

 N-PLC Device Settings
 Settings for registers of N-PLC Click driver.
 
 N-PLC MikroBUS Map
 MikroBUS pin mapping of N-PLC Click driver.
 

Functions

void nplc_cfg_setup (nplc_cfg_t *cfg)
 N-PLC configuration object setup function.
 
err_t nplc_init (nplc_t *ctx, nplc_cfg_t *cfg)
 N-PLC initialization function.
 
err_t nplc_generic_write (nplc_t *ctx, char *data_in, uint16_t len)
 N-PLC data writing function.
 
err_t nplc_generic_read (nplc_t *ctx, char *data_out, uint16_t len)
 N-PLC data reading function.
 
void nplc_set_rst_pin (nplc_t *ctx, uint8_t state)
 N-PLC set rst pin function.
 
void nplc_set_md1_pin (nplc_t *ctx, uint8_t state)
 N-PLC set md1 pin function.
 
void nplc_set_cts_pin (nplc_t *ctx, uint8_t state)
 N-PLC set cts pin function.
 
uint8_t nplc_get_rts_pin (nplc_t *ctx)
 N-PLC get rts pin function.
 
void nplc_hw_reset (nplc_t *ctx)
 N-PLC hw reset function.
 
void nplc_sw_reset (nplc_t *ctx)
 N-PLC sw reset function.
 
void nplc_factory_reset (nplc_t *ctx)
 N-PLC factory reset function.
 
void nplc_firmware_version (nplc_t *ctx)
 N-PLC firmware version function.
 
void nplc_set_mode (nplc_t *ctx, uint8_t mode)
 N-PLC set mode function.
 
void nplc_send_cmd (nplc_t *ctx, char *cmd)
 N-PLC send command function.
 
void nplc_write_s_register (nplc_t *ctx, char *s_reg, char *param_buf)
 N-PLC write s register function.
 
void nplc_read_s_register (nplc_t *ctx, char *s_reg)
 N-PLC read s register function.
 

Detailed Description

API for configuring and manipulating N-PLC 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

◆ nplc_cfg_setup()

void nplc_cfg_setup ( nplc_cfg_t * cfg)

N-PLC configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ nplc_factory_reset()

void nplc_factory_reset ( nplc_t * ctx)

N-PLC factory reset function.

This function factory resets the device.

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

◆ nplc_firmware_version()

void nplc_firmware_version ( nplc_t * ctx)

N-PLC firmware version function.

This function sends the show firmware version command.

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

◆ nplc_generic_read()

err_t nplc_generic_read ( nplc_t * ctx,
char * data_out,
uint16_t len )

N-PLC data reading function.

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

Parameters
[in]ctx: Click context object. See nplc_t object definition for detailed explanation.
[out]data_out: Output read data.
[in]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.

◆ nplc_generic_write()

err_t nplc_generic_write ( nplc_t * ctx,
char * data_in,
uint16_t len )

N-PLC data writing function.

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

Parameters
[in]ctx: Click context object. See nplc_t object definition for detailed explanation.
[in]data_in: 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.

◆ nplc_get_rts_pin()

uint8_t nplc_get_rts_pin ( nplc_t * ctx)

N-PLC get rts pin function.

This function returns the handshake out (RTS) pin logic state.

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

◆ nplc_hw_reset()

void nplc_hw_reset ( nplc_t * ctx)

N-PLC hw reset function.

This function resets the module by toggling the RST pin.

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

◆ nplc_init()

err_t nplc_init ( nplc_t * ctx,
nplc_cfg_t * cfg )

N-PLC initialization function.

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

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

◆ nplc_read_s_register()

void nplc_read_s_register ( nplc_t * ctx,
char * s_reg )

N-PLC read s register function.

This function sends a desired read S register command with the question mark and CR/LF bytes appended to.

Parameters
[in]ctx: Click context object. See nplc_t object definition for detailed explanation.
[in]s_reg: S register command (without question mark and CR/LF).
Returns
None.
Note
None.

◆ nplc_send_cmd()

void nplc_send_cmd ( nplc_t * ctx,
char * cmd )

N-PLC send command function.

This function sends a desired command with the CR/LF bytes appended to.

Parameters
[in]ctx: Click context object. See nplc_t object definition for detailed explanation.
[in]cmd: Command string.
Returns
None.
Note
None.

◆ nplc_set_cts_pin()

void nplc_set_cts_pin ( nplc_t * ctx,
uint8_t state )

N-PLC set cts pin function.

This function sets the handshake in (CTS) pin to a desired state.

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

◆ nplc_set_md1_pin()

void nplc_set_md1_pin ( nplc_t * ctx,
uint8_t state )

N-PLC set md1 pin function.

This function sets the mode select 1 (MD1) pin to a desired state.

Parameters
[in]ctx: Click context object. See nplc_t object definition for detailed explanation.
[in]state: Mode select 1 pin (1-boot, 0-normal).
Returns
None.
Note
None.

◆ nplc_set_mode()

void nplc_set_mode ( nplc_t * ctx,
uint8_t mode )

N-PLC set mode function.

This function sets operation mode to command or data.

Parameters
[in]ctx: Click context object. See nplc_t object definition for detailed explanation.
[in]mode:
  • 0 - Command mode,
  • 1 - Data mode.
Returns
None.
Note
None.

◆ nplc_set_rst_pin()

void nplc_set_rst_pin ( nplc_t * ctx,
uint8_t state )

N-PLC set rst pin function.

This function sets the reset (RST) pin to a desired state.

Parameters
[in]ctx: Click context object. See nplc_t object definition for detailed explanation.
[in]state: Pin logic state (Active Low).
Returns
None.
Note
None.

◆ nplc_sw_reset()

void nplc_sw_reset ( nplc_t * ctx)

N-PLC sw reset function.

This function software resets the device.

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

◆ nplc_write_s_register()

void nplc_write_s_register ( nplc_t * ctx,
char * s_reg,
char * param_buf )

N-PLC write s register function.

This function sends a desired write S register command with the parameter buffer and CR/LF bytes appended to.

Parameters
[in]ctx: Click context object. See nplc_t object definition for detailed explanation.
[in]s_reg: S register command (without equal sign and CR/LF).
[in]param_buf: Parameters string.
Returns
None.
Note
None.