Skip to content

Commit

Permalink
separate init & configure of uart ops
Browse files Browse the repository at this point in the history
  • Loading branch information
thewon86 authored and mysterywolf committed Feb 21, 2023
1 parent 67bc7e8 commit b4f605d
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 67 deletions.
2 changes: 1 addition & 1 deletion components/drivers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ menuconfig RT_USING_SERIAL
and RT_SERIAL_FIFO_BUFSZ >= 2*RT_SERIAL_DMA_BUFSZ

config RT_SERIAL_HARD_FIFO
bool "Set Hard FIFO buffer size"
bool "Using Hard FIFO"
default n
help
Useful only if the chip supported
Expand Down
15 changes: 12 additions & 3 deletions components/drivers/include/drivers/serialX.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
*
* Change Logs:
* Date Author Notes
* 2022-04-10 THEWON first version
* 2022-04-10 THEWON serialX first version
* 2022-06-08 THEWON add No TX Empty interrupt support
* 2023-02-15 THEWON add init ops
*/

#ifndef __SERIALX_H__
Expand Down Expand Up @@ -124,7 +126,7 @@ struct serial_configure
rt_uint32_t parity :2;
rt_uint32_t bit_order :1;
rt_uint32_t invert :1;
rt_uint32_t bufsz :16;
rt_uint32_t bufsz :16; // unused, move it to struct rt_serial_device
rt_uint32_t flowcontrol :1;
rt_uint32_t reserved :5;
};
Expand All @@ -149,6 +151,7 @@ struct rt_serial_device

const struct rt_uart_ops *ops;
struct serial_configure config;
rt_uint32_t bufsz;

void *serial_rx;
void *serial_tx;
Expand Down Expand Up @@ -176,14 +179,21 @@ typedef struct rt_serial_device rt_serial_t;
*/
struct rt_uart_ops
{
int (*init)(struct rt_serial_device *serial);

rt_err_t (*configure)(struct rt_serial_device *serial, struct serial_configure *cfg);
rt_err_t (*control)(struct rt_serial_device *serial, int cmd, void *arg);

int (*putc)(struct rt_serial_device *serial, char c);
int (*getc)(struct rt_serial_device *serial);
int (*flush)(struct rt_serial_device *serial);

#if defined (RT_SERIAL_NO_TXEIT)
rt_bool_t (*is_int_txing)(struct rt_serial_device *serial);
void (*start_tx)(struct rt_serial_device *serial, rt_uint8_t ch);
#else
void (*start_tx)(struct rt_serial_device *serial);
#endif
void (*stop_tx)(struct rt_serial_device *serial);

#ifdef RT_SERIAL_USING_DMA
Expand All @@ -204,4 +214,3 @@ rt_err_t rt_hw_serial_register(struct rt_serial_device *serial,
void *data);

#endif

Loading

0 comments on commit b4f605d

Please sign in to comment.