LibDriver CH9121X
Loading...
Searching...
No Matches
ch9121x base driver function

ch9121x base driver modules More...

Collaboration diagram for ch9121x base driver function:

Data Structures

struct  ch9121x_handle_s
 ch9121x handle structure definition More...
struct  ch9121x_info_s
 ch9121x information structure definition More...

Macros

#define CH9121X_UART_PRE_DELAY   50
 ch9121x uart pre delay definition

Typedefs

typedef struct ch9121x_handle_s ch9121x_handle_t
 ch9121x handle structure definition
typedef struct ch9121x_info_s ch9121x_info_t
 ch9121x information structure definition

Enumerations

enum  ch9121x_port_t { CH9121X_PORT1 = 0x00 , CH9121X_PORT2 = 0x01 }
 ch9121x port enumeration definition More...
enum  ch9121x_bool_t { CH9121X_BOOL_FALSE = 0x00 , CH9121X_BOOL_TRUE = 0x01 }
 ch9121x bool enumeration definition More...
enum  ch9121x_status_t { CH9121X_STATUS_DISCONNECT = 0x00 , CH9121X_STATUS_CONNECT = 0x01 }
 ch9121x status enumeration definition More...
enum  ch9121x_uart_clock_mode_t { CH9121X_UART_CLOCK_MODE_DEFAULT = 0x00 , CH9121X_UART_CLOCK_MODE_CLASSICAL = 0x01 }
 ch9121x uart clock mode enumeration definition More...
enum  ch9121x_phy_status_t {
  CH9121X_PHY_STATUS_UNKNOWN = 0x00 , CH9121X_PHY_STATUS_DISCONNECTED = 0x01 , CH9121X_PHY_STATUS_10M_FULL_DUPLEX = 0x02 , CH9121X_PHY_STATUS_10M_HALF_DUPLEX = 0x04 ,
  CH9121X_PHY_STATUS_100M_FULL_DUPLEX = 0x08 , CH9121X_PHY_STATUS_100M_HALF_DUPLEX = 0x10
}
 ch9121x phy status enumeration definition More...
enum  ch9121x_mode_t { CH9121X_MODE_TCP_SERVER = 0x00 , CH9121X_MODE_TCP_CLIENT = 0x01 , CH9121X_MODE_UDP_SERVER = 0x02 , CH9121X_MODE_UDP_CLIENT = 0x03 }
 ch9121x mode enumeration definition More...
enum  ch9121x_parity_t {
  CH9121X_PARITY_EVEN = 0x00 , CH9121X_PARITY_ODD = 0x01 , CH9121X_PARITY_MARK = 0x02 , CH9121X_PARITY_SPACE = 0x03 ,
  CH9121X_PARITY_NONE = 0x04
}
 ch9121x parity enumeration definition More...

Functions

uint8_t ch9121x_info (ch9121x_info_t *info)
 get chip's information
uint8_t ch9121x_init (ch9121x_handle_t *handle)
 initialize the chip
uint8_t ch9121x_deinit (ch9121x_handle_t *handle)
 close the chip
uint8_t ch9121x_read (ch9121x_handle_t *handle, uint8_t *buf, uint16_t *len)
 read data
uint8_t ch9121x_write (ch9121x_handle_t *handle, uint8_t *buf, uint16_t len)
 write data
uint8_t ch9121x_get_version (ch9121x_handle_t *handle, uint8_t *version)
 get version
uint8_t ch9121x_reset (ch9121x_handle_t *handle)
 reset the chip
uint8_t ch9121x_save_to_eeprom (ch9121x_handle_t *handle)
 save to eeprom
uint8_t ch9121x_config_and_reset (ch9121x_handle_t *handle)
 config and reset the chip
uint8_t ch9121x_exit (ch9121x_handle_t *handle)
 exit
uint8_t ch9121x_set_dhcp (ch9121x_handle_t *handle, ch9121x_bool_t enable)
 enable or disable dhcp
uint8_t ch9121x_get_dhcp (ch9121x_handle_t *handle, ch9121x_bool_t *enable)
 get dhcp status
uint8_t ch9121x_set_mac (ch9121x_handle_t *handle, uint8_t mac[6])
 set mac address
uint8_t ch9121x_get_mac (ch9121x_handle_t *handle, uint8_t mac[6])
 get chip mac
uint8_t ch9121x_clear_mac (ch9121x_handle_t *handle)
 clear mac address
uint8_t ch9121x_set_ip (ch9121x_handle_t *handle, uint8_t ip[4])
 set ip address
uint8_t ch9121x_get_ip (ch9121x_handle_t *handle, uint8_t ip[4])
 get ip address
uint8_t ch9121x_set_subnet_mask (ch9121x_handle_t *handle, uint8_t mask[4])
 set subnet mask
uint8_t ch9121x_get_subnet_mask (ch9121x_handle_t *handle, uint8_t mask[4])
 get subnet mask
uint8_t ch9121x_set_gateway (ch9121x_handle_t *handle, uint8_t ip[4])
 set gateway
uint8_t ch9121x_get_gateway (ch9121x_handle_t *handle, uint8_t ip[4])
 get gateway
uint8_t ch9121x_get_status (ch9121x_handle_t *handle, ch9121x_port_t port, ch9121x_status_t *status)
 get status
uint8_t ch9121x_set_mode (ch9121x_handle_t *handle, ch9121x_port_t port, ch9121x_mode_t mode)
 set mode
uint8_t ch9121x_get_mode (ch9121x_handle_t *handle, ch9121x_port_t port, ch9121x_mode_t *mode)
 get mode
uint8_t ch9121x_set_source_port (ch9121x_handle_t *handle, ch9121x_port_t port, uint16_t num)
 set source port
uint8_t ch9121x_get_source_port (ch9121x_handle_t *handle, ch9121x_port_t port, uint16_t *num)
 get source port
uint8_t ch9121x_set_dest_ip (ch9121x_handle_t *handle, ch9121x_port_t port, uint8_t ip[4])
 set dest ip
uint8_t ch9121x_get_dest_ip (ch9121x_handle_t *handle, ch9121x_port_t port, uint8_t ip[4])
 get dest ip
uint8_t ch9121x_set_dest_port (ch9121x_handle_t *handle, ch9121x_port_t port, uint16_t num)
 set dest port
uint8_t ch9121x_get_dest_port (ch9121x_handle_t *handle, ch9121x_port_t port, uint16_t *num)
 get dest port
uint8_t ch9121x_set_uart_baud (ch9121x_handle_t *handle, ch9121x_port_t port, uint32_t baud)
 set uart baud
uint8_t ch9121x_get_uart_baud (ch9121x_handle_t *handle, ch9121x_port_t port, uint32_t *baud)
 get uart baud
uint8_t ch9121x_set_uart_config (ch9121x_handle_t *handle, ch9121x_port_t port, uint8_t data_bit, ch9121x_parity_t parity, uint8_t stop_bit)
 set uart config
uint8_t ch9121x_get_uart_config (ch9121x_handle_t *handle, ch9121x_port_t port, uint8_t *data_bit, ch9121x_parity_t *parity, uint8_t *stop_bit)
 get uart config
uint8_t ch9121x_set_uart_timeout (ch9121x_handle_t *handle, ch9121x_port_t port, uint8_t timeout)
 set uart timeout
uint8_t ch9121x_get_uart_timeout (ch9121x_handle_t *handle, ch9121x_port_t port, uint8_t *timeout)
 get uart timeout
uint8_t ch9121x_uart_timeout_convert_to_register (ch9121x_handle_t *handle, uint16_t ms, uint8_t *reg)
 convert the uart timeout to the register raw data
uint8_t ch9121x_uart_timeout_convert_to_data (ch9121x_handle_t *handle, uint8_t reg, uint16_t *ms)
 convert the register raw data to the offset
uint8_t ch9121x_set_source_port_random (ch9121x_handle_t *handle, ch9121x_port_t port, ch9121x_bool_t enable)
 enable or disable random source port number
uint8_t ch9121x_get_source_port_random (ch9121x_handle_t *handle, ch9121x_port_t port, ch9121x_bool_t *enable)
 get random source port number status
uint8_t ch9121x_set_uart_buffer_length (ch9121x_handle_t *handle, ch9121x_port_t port, uint32_t len)
 set uart buffer length
uint8_t ch9121x_get_uart_buffer_length (ch9121x_handle_t *handle, ch9121x_port_t port, uint32_t *len)
 get uart buffer length
uint8_t ch9121x_set_uart_flush (ch9121x_handle_t *handle, ch9121x_port_t port, ch9121x_bool_t enable)
 enable or disable uart auto flush
uint8_t ch9121x_get_uart_flush (ch9121x_handle_t *handle, ch9121x_port_t port, ch9121x_bool_t *enable)
 get uart auto flush status
uint8_t ch9121x_set_port2 (ch9121x_handle_t *handle, ch9121x_bool_t enable)
 enable or disable uart port2
uint8_t ch9121x_set_disconnect_with_no_rj45 (ch9121x_handle_t *handle, ch9121x_bool_t enable)
 enable or disable disconnect with no rj45
uint8_t ch9121x_get_disconnect_with_no_rj45 (ch9121x_handle_t *handle, ch9121x_bool_t *enable)
 get disconnect with no rj45 status
uint8_t ch9121x_set_domain (ch9121x_handle_t *handle, char *domain)
 set chip domain
uint8_t ch9121x_set_eth_cfg (ch9121x_handle_t *handle, ch9121x_bool_t enable)
 set eth cfg
uint8_t ch9121x_get_eth_cfg (ch9121x_handle_t *handle, ch9121x_bool_t *enable)
 get eth cfg
uint8_t ch9121x_set_uart_clock_mode (ch9121x_handle_t *handle, ch9121x_uart_clock_mode_t mode)
 set uart clock mode
uint8_t ch9121x_get_uart_clock_mode (ch9121x_handle_t *handle, ch9121x_uart_clock_mode_t *mode)
 get uart clock mode
uint8_t ch9121x_get_phy_status (ch9121x_handle_t *handle, ch9121x_phy_status_t *status)
 get phy status
uint8_t ch9121x_set_tcp_retry_mode (ch9121x_handle_t *handle, uint8_t t)
 set tcp retry mode
uint8_t ch9121x_get_tcp_retry_mode (ch9121x_handle_t *handle, uint8_t *t)
 get tcp retry mode
uint8_t ch9121x_set_flow_control (ch9121x_handle_t *handle, ch9121x_bool_t enable)
 enable or disable flow control
uint8_t ch9121x_get_flow_control (ch9121x_handle_t *handle, ch9121x_bool_t *enable)
 get flow control status
uint8_t ch9121x_set_arp_retry (ch9121x_handle_t *handle, uint8_t period, uint8_t times)
 set arp retry
uint8_t ch9121x_tcp_retry_time_convert_to_register (ch9121x_handle_t *handle, uint16_t ms, uint8_t *reg)
 convert the tcp retry time to the register raw data
uint8_t ch9121x_tcp_retry_time_convert_to_data (ch9121x_handle_t *handle, uint8_t reg, uint16_t *ms)
 convert the register raw data to the tcp retry time
uint8_t ch9121x_arp_retry_period_convert_to_register (ch9121x_handle_t *handle, uint16_t ms, uint8_t *reg)
 convert the arp retry period to the register raw data
uint8_t ch9121x_arp_retry_period_convert_to_data (ch9121x_handle_t *handle, uint8_t reg, uint16_t *ms)
 convert the register raw data to the arp retry period

Detailed Description

ch9121x base driver modules

Macro Definition Documentation

◆ CH9121X_UART_PRE_DELAY

#define CH9121X_UART_PRE_DELAY   50

ch9121x uart pre delay definition

50ms

Definition at line 63 of file driver_ch9121x.h.

Typedef Documentation

◆ ch9121x_handle_t

ch9121x handle structure definition

◆ ch9121x_info_t

ch9121x information structure definition

Enumeration Type Documentation

◆ ch9121x_bool_t

ch9121x bool enumeration definition

Enumerator
CH9121X_BOOL_FALSE 

false

CH9121X_BOOL_TRUE 

true

Definition at line 78 of file driver_ch9121x.h.

◆ ch9121x_mode_t

ch9121x mode enumeration definition

Enumerator
CH9121X_MODE_TCP_SERVER 

tcp server

CH9121X_MODE_TCP_CLIENT 

tcp client

CH9121X_MODE_UDP_SERVER 

udp server

CH9121X_MODE_UDP_CLIENT 

udp client

Definition at line 118 of file driver_ch9121x.h.

◆ ch9121x_parity_t

ch9121x parity enumeration definition

Enumerator
CH9121X_PARITY_EVEN 

even parity

CH9121X_PARITY_ODD 

odd parity

CH9121X_PARITY_MARK 

mark

CH9121X_PARITY_SPACE 

space

CH9121X_PARITY_NONE 

none

Definition at line 129 of file driver_ch9121x.h.

◆ ch9121x_phy_status_t

ch9121x phy status enumeration definition

Enumerator
CH9121X_PHY_STATUS_UNKNOWN 

unknown

CH9121X_PHY_STATUS_DISCONNECTED 

disconnected

CH9121X_PHY_STATUS_10M_FULL_DUPLEX 

10 mbps full duplex

CH9121X_PHY_STATUS_10M_HALF_DUPLEX 

10 mbps half duplex

CH9121X_PHY_STATUS_100M_FULL_DUPLEX 

100 mbps full duplex

CH9121X_PHY_STATUS_100M_HALF_DUPLEX 

100 mbps half duplex

Definition at line 105 of file driver_ch9121x.h.

◆ ch9121x_port_t

ch9121x port enumeration definition

Enumerator
CH9121X_PORT1 

port1

CH9121X_PORT2 

port2

Definition at line 69 of file driver_ch9121x.h.

◆ ch9121x_status_t

ch9121x status enumeration definition

Enumerator
CH9121X_STATUS_DISCONNECT 

disconnect

CH9121X_STATUS_CONNECT 

connect

Definition at line 87 of file driver_ch9121x.h.

◆ ch9121x_uart_clock_mode_t

ch9121x uart clock mode enumeration definition

Enumerator
CH9121X_UART_CLOCK_MODE_DEFAULT 

default mode

CH9121X_UART_CLOCK_MODE_CLASSICAL 

classical mode

Definition at line 96 of file driver_ch9121x.h.

Function Documentation

◆ ch9121x_arp_retry_period_convert_to_data()

uint8_t ch9121x_arp_retry_period_convert_to_data ( ch9121x_handle_t * handle,
uint8_t reg,
uint16_t * ms )

convert the register raw data to the arp retry period

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]regregister raw data
[out]*mspointer to a ms buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 2496 of file driver_ch9121x.c.

◆ ch9121x_arp_retry_period_convert_to_register()

uint8_t ch9121x_arp_retry_period_convert_to_register ( ch9121x_handle_t * handle,
uint16_t ms,
uint8_t * reg )

convert the arp retry period to the register raw data

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]mstime in ms
[out]*regpointer to a register raw buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 2469 of file driver_ch9121x.c.

◆ ch9121x_clear_mac()

uint8_t ch9121x_clear_mac ( ch9121x_handle_t * handle)

clear mac address

Parameters
[in]*handlepointer to a ch9121x handle structure
Returns
status code
  • 0 success
  • 1 clear mac failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1784 of file driver_ch9121x.c.

◆ ch9121x_config_and_reset()

uint8_t ch9121x_config_and_reset ( ch9121x_handle_t * handle)

config and reset the chip

Parameters
[in]*handlepointer to a ch9121x handle structure
Returns
status code
  • 0 success
  • 1 config and reset failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 425 of file driver_ch9121x.c.

◆ ch9121x_deinit()

uint8_t ch9121x_deinit ( ch9121x_handle_t * handle)

close the chip

Parameters
[in]*handlepointer to a ch9121x handle structure
Returns
status code
  • 0 success
  • 1 uart deinit failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 reset failed
  • 5 reset gpio deinit failed
  • 6 cfg gpio deinit failed
Note
none

Definition at line 2667 of file driver_ch9121x.c.

◆ ch9121x_exit()

uint8_t ch9121x_exit ( ch9121x_handle_t * handle)

exit

Parameters
[in]*handlepointer to a ch9121x handle structure
Returns
status code
  • 0 success
  • 1 exit failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 459 of file driver_ch9121x.c.

◆ ch9121x_get_dest_ip()

uint8_t ch9121x_get_dest_ip ( ch9121x_handle_t * handle,
ch9121x_port_t port,
uint8_t ip[4] )

get dest ip

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[out]*ippointer to an ip buffer
Returns
status code
  • 0 success
  • 1 get dest ip failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1044 of file driver_ch9121x.c.

◆ ch9121x_get_dest_port()

uint8_t ch9121x_get_dest_port ( ch9121x_handle_t * handle,
ch9121x_port_t port,
uint16_t * num )

get dest port

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[out]*numpointer to a dest port buffer
Returns
status code
  • 0 success
  • 1 get dest port failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1130 of file driver_ch9121x.c.

◆ ch9121x_get_dhcp()

uint8_t ch9121x_get_dhcp ( ch9121x_handle_t * handle,
ch9121x_bool_t * enable )

get dhcp status

Parameters
[in]*handlepointer to a ch9121x handle structure
[out]*enablepointer to a bool value buffer
Returns
status code
  • 0 success
  • 1 get dhcp failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 2188 of file driver_ch9121x.c.

◆ ch9121x_get_disconnect_with_no_rj45()

uint8_t ch9121x_get_disconnect_with_no_rj45 ( ch9121x_handle_t * handle,
ch9121x_bool_t * enable )

get disconnect with no rj45 status

Parameters
[in]*handlepointer to a ch9121x handle structure
[out]*enablepointer to a bool value buffer
Returns
status code
  • 0 success
  • 1 get disconnect with no rj45 failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 2063 of file driver_ch9121x.c.

◆ ch9121x_get_eth_cfg()

uint8_t ch9121x_get_eth_cfg ( ch9121x_handle_t * handle,
ch9121x_bool_t * enable )

get eth cfg

Parameters
[in]*handlepointer to a ch9121x handle structure
[out]*enablepointer to a bool value buffer
Returns
status code
  • 0 success
  • 1 get eth cfg failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1853 of file driver_ch9121x.c.

◆ ch9121x_get_flow_control()

uint8_t ch9121x_get_flow_control ( ch9121x_handle_t * handle,
ch9121x_bool_t * enable )

get flow control status

Parameters
[in]*handlepointer to a ch9121x handle structure
[out]*enablepointer to a bool value buffer
Returns
status code
  • 0 success
  • 1 get flow control failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 2340 of file driver_ch9121x.c.

◆ ch9121x_get_gateway()

uint8_t ch9121x_get_gateway ( ch9121x_handle_t * handle,
uint8_t ip[4] )

get gateway

Parameters
[in]*handlepointer to a ch9121x handle structure
[out]*ippointer to an ip buffer
Returns
status code
  • 0 success
  • 1 get gateway failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 875 of file driver_ch9121x.c.

◆ ch9121x_get_ip()

uint8_t ch9121x_get_ip ( ch9121x_handle_t * handle,
uint8_t ip[4] )

get ip address

Parameters
[in]*handlepointer to a ch9121x handle structure
[out]*ippointer to an ip buffer
Returns
status code
  • 0 success
  • 1 get ip failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 731 of file driver_ch9121x.c.

◆ ch9121x_get_mac()

uint8_t ch9121x_get_mac ( ch9121x_handle_t * handle,
uint8_t mac[6] )

get chip mac

Parameters
[in]*handlepointer to a ch9121x handle structure
[out]*macpointer to a mac buffer
Returns
status code
  • 0 success
  • 1 get mac failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 528 of file driver_ch9121x.c.

◆ ch9121x_get_mode()

uint8_t ch9121x_get_mode ( ch9121x_handle_t * handle,
ch9121x_port_t port,
ch9121x_mode_t * mode )

get mode

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[out]*modepointer to a mode buffer
Returns
status code
  • 0 success
  • 1 get mode failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 650 of file driver_ch9121x.c.

◆ ch9121x_get_phy_status()

uint8_t ch9121x_get_phy_status ( ch9121x_handle_t * handle,
ch9121x_phy_status_t * status )

get phy status

Parameters
[in]*handlepointer to a ch9121x handle structure
[out]*statuspointer to a status buffer
Returns
status code
  • 0 success
  • 1 get phy status failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 2004 of file driver_ch9121x.c.

◆ ch9121x_get_source_port()

uint8_t ch9121x_get_source_port ( ch9121x_handle_t * handle,
ch9121x_port_t port,
uint16_t * num )

get source port

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[out]*numpointer to a source port buffer
Returns
status code
  • 0 success
  • 1 get source port failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 954 of file driver_ch9121x.c.

◆ ch9121x_get_source_port_random()

uint8_t ch9121x_get_source_port_random ( ch9121x_handle_t * handle,
ch9121x_port_t port,
ch9121x_bool_t * enable )

get random source port number status

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[out]*enablepointer to a bool value buffer
Returns
status code
  • 0 success
  • 1 get source port random failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1961 of file driver_ch9121x.c.

◆ ch9121x_get_status()

uint8_t ch9121x_get_status ( ch9121x_handle_t * handle,
ch9121x_port_t port,
ch9121x_status_t * status )

get status

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[out]*statuspointer to a status buffer
Returns
status code
  • 0 success
  • 1 get status failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 563 of file driver_ch9121x.c.

◆ ch9121x_get_subnet_mask()

uint8_t ch9121x_get_subnet_mask ( ch9121x_handle_t * handle,
uint8_t mask[4] )

get subnet mask

Parameters
[in]*handlepointer to a ch9121x handle structure
[out]*maskpointer to a mask buffer
Returns
status code
  • 0 success
  • 1 get subnet mask failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 803 of file driver_ch9121x.c.

◆ ch9121x_get_tcp_retry_mode()

uint8_t ch9121x_get_tcp_retry_mode ( ch9121x_handle_t * handle,
uint8_t * t )

get tcp retry mode

Parameters
[in]*handlepointer to a ch9121x handle structure
[out]*tpointer to a time buffer
Returns
status code
  • 0 success
  • 1 get tcp retry mode failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 2267 of file driver_ch9121x.c.

◆ ch9121x_get_uart_baud()

uint8_t ch9121x_get_uart_baud ( ch9121x_handle_t * handle,
ch9121x_port_t port,
uint32_t * baud )

get uart baud

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[out]*baudpointer to a baud buffer
Returns
status code
  • 0 success
  • 1 get uart baud failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1220 of file driver_ch9121x.c.

◆ ch9121x_get_uart_buffer_length()

uint8_t ch9121x_get_uart_buffer_length ( ch9121x_handle_t * handle,
ch9121x_port_t port,
uint32_t * len )

get uart buffer length

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[out]*lenpointer to a buffer length buffer
Returns
status code
  • 0 success
  • 1 get uart buffer length failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 2100 of file driver_ch9121x.c.

◆ ch9121x_get_uart_clock_mode()

uint8_t ch9121x_get_uart_clock_mode ( ch9121x_handle_t * handle,
ch9121x_uart_clock_mode_t * mode )

get uart clock mode

Parameters
[in]*handlepointer to a ch9121x handle structure
[out]*modepointer to an uart clock mode buffer
Returns
status code
  • 0 success
  • 1 get uart clock mode failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1924 of file driver_ch9121x.c.

◆ ch9121x_get_uart_config()

uint8_t ch9121x_get_uart_config ( ch9121x_handle_t * handle,
ch9121x_port_t port,
uint8_t * data_bit,
ch9121x_parity_t * parity,
uint8_t * stop_bit )

get uart config

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[out]*data_bitpointer to an uart data bit buffer
[out]*paritypointer to an uart parity buffer
[out]*stop_bitpointer to an uart stop bit buffer
Returns
status code
  • 0 success
  • 1 get uart config failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1314 of file driver_ch9121x.c.

◆ ch9121x_get_uart_flush()

uint8_t ch9121x_get_uart_flush ( ch9121x_handle_t * handle,
ch9121x_port_t port,
ch9121x_bool_t * enable )

get uart auto flush status

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[out]*enablepointer to a bool value buffer
Returns
status code
  • 0 success
  • 1 get uart flush failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 2145 of file driver_ch9121x.c.

◆ ch9121x_get_uart_timeout()

uint8_t ch9121x_get_uart_timeout ( ch9121x_handle_t * handle,
ch9121x_port_t port,
uint8_t * timeout )

get uart timeout

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[out]*timeoutpointer to an uart timeout buffer
Returns
status code
  • 0 success
  • 1 get uart timeout failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1406 of file driver_ch9121x.c.

◆ ch9121x_get_version()

uint8_t ch9121x_get_version ( ch9121x_handle_t * handle,
uint8_t * version )

get version

Parameters
[in]*handlepointer to a ch9121x handle structure
[out]*versionpointer to a version buffer
Returns
status code
  • 0 success
  • 1 get version failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 325 of file driver_ch9121x.c.

◆ ch9121x_info()

uint8_t ch9121x_info ( ch9121x_info_t * info)

get chip's information

Parameters
[out]*infopointer to a ch9121x info structure
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 2833 of file driver_ch9121x.c.

◆ ch9121x_init()

uint8_t ch9121x_init ( ch9121x_handle_t * handle)

initialize the chip

Parameters
[in]*handlepointer to a ch9121x handle structure
Returns
status code
  • 0 success
  • 1 uart initialization failed
  • 2 handle is NULL
  • 3 linked functions is NULL
  • 4 reset gpio init failed
  • 5 cfg gpio init failed
  • 6 reset failed
Note
none

Definition at line 2525 of file driver_ch9121x.c.

◆ ch9121x_read()

uint8_t ch9121x_read ( ch9121x_handle_t * handle,
uint8_t * buf,
uint16_t * len )

read data

Parameters
[in]*handlepointer to a ch9121x handle structure
[out]*bufpointer to a data buffer
[in,out]*lenpointer to a length buffer
Returns
status code
  • 0 success
  • 1 read failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 2760 of file driver_ch9121x.c.

◆ ch9121x_reset()

uint8_t ch9121x_reset ( ch9121x_handle_t * handle)

reset the chip

Parameters
[in]*handlepointer to a ch9121x handle structure
Returns
status code
  • 0 success
  • 1 reset failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 358 of file driver_ch9121x.c.

◆ ch9121x_save_to_eeprom()

uint8_t ch9121x_save_to_eeprom ( ch9121x_handle_t * handle)

save to eeprom

Parameters
[in]*handlepointer to a ch9121x handle structure
Returns
status code
  • 0 success
  • 1 save to eeprom failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 392 of file driver_ch9121x.c.

◆ ch9121x_set_arp_retry()

uint8_t ch9121x_set_arp_retry ( ch9121x_handle_t * handle,
uint8_t period,
uint8_t times )

set arp retry

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]periodinput period
[in]timesinput times
Returns
status code
  • 0 success
  • 1 set arp retry failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 2378 of file driver_ch9121x.c.

◆ ch9121x_set_dest_ip()

uint8_t ch9121x_set_dest_ip ( ch9121x_handle_t * handle,
ch9121x_port_t port,
uint8_t ip[4] )

set dest ip

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[in]*ippointer to an ip buffer
Returns
status code
  • 0 success
  • 1 set dest ip failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 998 of file driver_ch9121x.c.

◆ ch9121x_set_dest_port()

uint8_t ch9121x_set_dest_port ( ch9121x_handle_t * handle,
ch9121x_port_t port,
uint16_t num )

set dest port

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[in]numdest port
Returns
status code
  • 0 success
  • 1 set dest port failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1086 of file driver_ch9121x.c.

◆ ch9121x_set_dhcp()

uint8_t ch9121x_set_dhcp ( ch9121x_handle_t * handle,
ch9121x_bool_t enable )

enable or disable dhcp

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]enablebool value
Returns
status code
  • 0 success
  • 1 set dhcp failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 493 of file driver_ch9121x.c.

◆ ch9121x_set_disconnect_with_no_rj45()

uint8_t ch9121x_set_disconnect_with_no_rj45 ( ch9121x_handle_t * handle,
ch9121x_bool_t enable )

enable or disable disconnect with no rj45

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]enablebool value
Returns
status code
  • 0 success
  • 1 set disconnect with no rj45 failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1668 of file driver_ch9121x.c.

◆ ch9121x_set_domain()

uint8_t ch9121x_set_domain ( ch9121x_handle_t * handle,
char * domain )

set chip domain

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]*domainpointer to a domain buffer
Returns
status code
  • 0 success
  • 1 set domain failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1703 of file driver_ch9121x.c.

◆ ch9121x_set_eth_cfg()

uint8_t ch9121x_set_eth_cfg ( ch9121x_handle_t * handle,
ch9121x_bool_t enable )

set eth cfg

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]enablebool value
Returns
status code
  • 0 success
  • 1 set eth cfg failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1818 of file driver_ch9121x.c.

◆ ch9121x_set_flow_control()

uint8_t ch9121x_set_flow_control ( ch9121x_handle_t * handle,
ch9121x_bool_t enable )

enable or disable flow control

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]enablebool value
Returns
status code
  • 0 success
  • 1 set flow control failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 2304 of file driver_ch9121x.c.

◆ ch9121x_set_gateway()

uint8_t ch9121x_set_gateway ( ch9121x_handle_t * handle,
uint8_t ip[4] )

set gateway

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]*ippointer to an ip buffer
Returns
status code
  • 0 success
  • 1 set gateway failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 837 of file driver_ch9121x.c.

◆ ch9121x_set_ip()

uint8_t ch9121x_set_ip ( ch9121x_handle_t * handle,
uint8_t ip[4] )

set ip address

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]*ippointer to an ip buffer
Returns
status code
  • 0 success
  • 1 set ip failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 693 of file driver_ch9121x.c.

◆ ch9121x_set_mac()

uint8_t ch9121x_set_mac ( ch9121x_handle_t * handle,
uint8_t mac[6] )

set mac address

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]*macpointer to a mac buffer
Returns
status code
  • 0 success
  • 1 set mac failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1745 of file driver_ch9121x.c.

◆ ch9121x_set_mode()

uint8_t ch9121x_set_mode ( ch9121x_handle_t * handle,
ch9121x_port_t port,
ch9121x_mode_t mode )

set mode

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[in]modechip mode
Returns
status code
  • 0 success
  • 1 set mode failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 607 of file driver_ch9121x.c.

◆ ch9121x_set_port2()

uint8_t ch9121x_set_port2 ( ch9121x_handle_t * handle,
ch9121x_bool_t enable )

enable or disable uart port2

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]enablebool value
Returns
status code
  • 0 success
  • 1 set port2 failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1633 of file driver_ch9121x.c.

◆ ch9121x_set_source_port()

uint8_t ch9121x_set_source_port ( ch9121x_handle_t * handle,
ch9121x_port_t port,
uint16_t num )

set source port

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[in]numsource port
Returns
status code
  • 0 success
  • 1 set source port failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 910 of file driver_ch9121x.c.

◆ ch9121x_set_source_port_random()

uint8_t ch9121x_set_source_port_random ( ch9121x_handle_t * handle,
ch9121x_port_t port,
ch9121x_bool_t enable )

enable or disable random source port number

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[in]enablebool value
Returns
status code
  • 0 success
  • 1 set source port random failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1502 of file driver_ch9121x.c.

◆ ch9121x_set_subnet_mask()

uint8_t ch9121x_set_subnet_mask ( ch9121x_handle_t * handle,
uint8_t mask[4] )

set subnet mask

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]*maskpointer to a mask buffer
Returns
status code
  • 0 success
  • 1 set subnet mask failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 765 of file driver_ch9121x.c.

◆ ch9121x_set_tcp_retry_mode()

uint8_t ch9121x_set_tcp_retry_mode ( ch9121x_handle_t * handle,
uint8_t t )

set tcp retry mode

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]ttime
Returns
status code
  • 0 success
  • 1 set tcp retry mode failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 t > 7
Note
none

Definition at line 2225 of file driver_ch9121x.c.

◆ ch9121x_set_uart_baud()

uint8_t ch9121x_set_uart_baud ( ch9121x_handle_t * handle,
ch9121x_port_t port,
uint32_t baud )

set uart baud

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[in]baudchip baud
Returns
status code
  • 0 success
  • 1 set uart baud failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1174 of file driver_ch9121x.c.

◆ ch9121x_set_uart_buffer_length()

uint8_t ch9121x_set_uart_buffer_length ( ch9121x_handle_t * handle,
ch9121x_port_t port,
uint32_t len )

set uart buffer length

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[in]lenbuffer length
Returns
status code
  • 0 success
  • 1 set uart buffer length failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1545 of file driver_ch9121x.c.

◆ ch9121x_set_uart_clock_mode()

uint8_t ch9121x_set_uart_clock_mode ( ch9121x_handle_t * handle,
ch9121x_uart_clock_mode_t mode )

set uart clock mode

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]modeuart clock mode
Returns
status code
  • 0 success
  • 1 set uart clock mode failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1889 of file driver_ch9121x.c.

◆ ch9121x_set_uart_config()

uint8_t ch9121x_set_uart_config ( ch9121x_handle_t * handle,
ch9121x_port_t port,
uint8_t data_bit,
ch9121x_parity_t parity,
uint8_t stop_bit )

set uart config

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[in]data_bituart data bit
[in]parityuart parity
[in]stop_bituart stop bit
Returns
status code
  • 0 success
  • 1 set uart config failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1267 of file driver_ch9121x.c.

◆ ch9121x_set_uart_flush()

uint8_t ch9121x_set_uart_flush ( ch9121x_handle_t * handle,
ch9121x_port_t port,
ch9121x_bool_t enable )

enable or disable uart auto flush

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[in]enablebool value
Returns
status code
  • 0 success
  • 1 set uart flush failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1591 of file driver_ch9121x.c.

◆ ch9121x_set_uart_timeout()

uint8_t ch9121x_set_uart_timeout ( ch9121x_handle_t * handle,
ch9121x_port_t port,
uint8_t timeout )

set uart timeout

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]portinput port
[in]timeoutuart timeout
Returns
status code
  • 0 success
  • 1 set uart timeout failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1360 of file driver_ch9121x.c.

◆ ch9121x_tcp_retry_time_convert_to_data()

uint8_t ch9121x_tcp_retry_time_convert_to_data ( ch9121x_handle_t * handle,
uint8_t reg,
uint16_t * ms )

convert the register raw data to the tcp retry time

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]regregister raw data
[out]*mspointer to a ms buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 2442 of file driver_ch9121x.c.

◆ ch9121x_tcp_retry_time_convert_to_register()

uint8_t ch9121x_tcp_retry_time_convert_to_register ( ch9121x_handle_t * handle,
uint16_t ms,
uint8_t * reg )

convert the tcp retry time to the register raw data

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]mstime in ms
[out]*regpointer to a register raw buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 2415 of file driver_ch9121x.c.

◆ ch9121x_uart_timeout_convert_to_data()

uint8_t ch9121x_uart_timeout_convert_to_data ( ch9121x_handle_t * handle,
uint8_t reg,
uint16_t * ms )

convert the register raw data to the offset

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]regregister raw data
[out]*mspointer to a ms buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1474 of file driver_ch9121x.c.

◆ ch9121x_uart_timeout_convert_to_register()

uint8_t ch9121x_uart_timeout_convert_to_register ( ch9121x_handle_t * handle,
uint16_t ms,
uint8_t * reg )

convert the uart timeout to the register raw data

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]mstimeout
[out]*regpointer to a register raw buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1447 of file driver_ch9121x.c.

◆ ch9121x_write()

uint8_t ch9121x_write ( ch9121x_handle_t * handle,
uint8_t * buf,
uint16_t len )

write data

Parameters
[in]*handlepointer to a ch9121x handle structure
[in]*bufpointer to a data buffer
[in]lendata length
Returns
status code
  • 0 success
  • 1 write failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 2721 of file driver_ch9121x.c.