]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_FreedomStudio/freedom-metal/src/spi.c
Update RISCC-V-RV32-SiFive_HiFive1_FreedomStudio project to latest tools and metal...
[freertos] / FreeRTOS / Demo / RISC-V_RV32_SiFive_HiFive1_FreedomStudio / freedom-metal / src / spi.c
1 /* Copyright 2018 SiFive, Inc */
2 /* SPDX-License-Identifier: Apache-2.0 */
3
4 #include <metal/machine.h>
5 #include <metal/spi.h>
6
7 extern __inline__ void metal_spi_init(struct metal_spi *spi, int baud_rate);
8 extern __inline__ int metal_spi_transfer(struct metal_spi *spi, struct metal_spi_config *config, size_t len, char *tx_buf, char *rx_buf);
9 extern __inline__ int metal_spi_get_baud_rate(struct metal_spi *spi);
10 extern __inline__ int metal_spi_set_baud_rate(struct metal_spi *spi, int baud_rate);
11
12 struct metal_spi *metal_spi_get_device(unsigned int device_num)
13 {
14 #if __METAL_DT_MAX_SPIS > 0
15     if (device_num < __METAL_DT_MAX_SPIS) {
16         return (struct metal_spi *) __metal_spi_table[device_num];
17     }
18 #endif
19
20     return NULL;
21 }