1 /*
2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited
3 */
4
5 #include <stdio.h>
6 #include <aos/errno.h>
7 #ifndef AOS_BOARD_HAAS700
8 #include <vfsdev/spi_dev.h>
9 #endif
10 #include "aos/hal/spi.h"
11 #include "aos_hal_spi.h"
12
aos_hal_spi_init(spi_dev_t * spi)13 int32_t aos_hal_spi_init(spi_dev_t *spi)
14 {
15 #ifndef AOS_BOARD_HAAS700
16 return hal_spi_init(spi);
17 #else
18 return -1;
19 #endif
20 }
21
aos_hal_spi_send(spi_dev_t * spi,const uint8_t * data,uint32_t size,uint32_t timeout)22 int32_t aos_hal_spi_send(spi_dev_t *spi, const uint8_t *data, uint32_t size, uint32_t timeout)
23 {
24 #ifndef AOS_BOARD_HAAS700
25 return hal_spi_send(spi, data, size, timeout);
26 #else
27 return -1;
28 #endif
29 }
30
aos_hal_spi_recv(spi_dev_t * spi,uint8_t * data,uint32_t size,uint32_t timeout)31 int32_t aos_hal_spi_recv(spi_dev_t *spi, uint8_t *data, uint32_t size, uint32_t timeout)
32 {
33 #ifndef AOS_BOARD_HAAS700
34 return hal_spi_recv(spi, data, size, timeout);
35 #else
36 return -1;
37 #endif
38 }
39
aos_hal_spi_send_recv(spi_dev_t * spi,uint8_t * tx_data,uint8_t * rx_data,uint32_t rx_size,uint32_t timeout)40 int32_t aos_hal_spi_send_recv(spi_dev_t *spi, uint8_t *tx_data, uint8_t *rx_data,
41 uint32_t rx_size, uint32_t timeout)
42 {
43 #ifndef AOS_BOARD_HAAS700
44 return hal_spi_send_recv(spi, tx_data, rx_data, rx_size, timeout);
45 #else
46 return -1;
47 #endif
48 }
49
aos_hal_spi_send_and_recv(spi_dev_t * spi,uint8_t * tx_data,uint16_t tx_size,uint8_t * rx_data,uint16_t rx_size,uint32_t timeout)50 int32_t aos_hal_spi_send_and_recv(spi_dev_t *spi, uint8_t *tx_data, uint16_t tx_size, uint8_t *rx_data,
51 uint16_t rx_size, uint32_t timeout)
52 {
53 #ifndef AOS_BOARD_HAAS700
54 return hal_spi_send_and_recv(spi, tx_data, tx_size, rx_data, rx_size, timeout);
55 #else
56 return -1;
57 #endif
58 }
59
aos_hal_spi_finalize(spi_dev_t * spi)60 int32_t aos_hal_spi_finalize(spi_dev_t *spi)
61 {
62 #ifndef AOS_BOARD_HAAS700
63 return hal_spi_finalize(spi);
64 #else
65 return -1;
66 #endif
67 }
68
69
70