4 //#include "sys_common.h"
10 #define SPI_MSG_FINISHED 0x040
11 #define SPI_MSG_ABORT 0x020
12 #define SPI_MSG_FAIL 0x010
16 typedef struct spi_msg_head {
17 uint16_t flags; /* message flags */
18 uint16_t addr; /* message destination address -- used as
19 index into the "address translation table"*/
21 //uint16_t size_mode; /* message frame len and mode */
22 uint16_t rq_len; /* requested transfer length */
23 const uint8_t *tx_buf; /* pointer to TX data */
24 uint8_t *rx_buf; /* pointer to RX data */
27 //struct spi_drv *ifc; /* */
28 int (*callback) (struct spi_drv * ifc, int code, struct spi_msg_head * msg); /* Called when whole transfer is finished */
29 long private; /* If set -- msg is processed by HW */
34 #define SPI_CTRL_WAKE_RQ 1
35 typedef int (spi_ctrl_fnc_t) (struct spi_drv * ifc, int ctrl, void *p);
38 typedef struct spi_drv {
39 uint16_t flags; /* Flags */
41 ul_list_head_t rq_queue; /* Queue containing MSG requests to process */
42 spi_msg_head_t *msg_act; /* MSG being actually processed */
43 spi_ctrl_fnc_t *ctrl_fnc; /* Device dependent function responsible for sending data */
47 UL_LIST_CUST_DEC(spi_rq_queue, spi_drv_t, spi_msg_head_t, rq_queue, node)
49 /* ------------------------------------------------------------------------- */
51 typedef unsigned long spi_isr_lock_level_t;
52 #define spi_isr_lock save_and_cli
53 #define spi_isr_unlock restore_flags
55 /* ------------------------------------------------------------------------- */
56 int spi_transfer(spi_drv_t *ifc, int addr, int rq_len, const void *tx_buf, void *rx_buf);
57 spi_drv_t *spi_find_drv(char *name, int number);
58 int spi_msg_rq_ins(spi_drv_t *ifc, spi_msg_head_t *msg);
60 #endif /* _SPI_DRV_H_ */