]> git.sur5r.net Git - freertos/blobdiff - 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
index d344e095f72f43d046a61b86fb3d0f01c29d1be5..de8cda737f5cdbdc5879ccbbef6cfb11c1d00131 100644 (file)
@@ -4,16 +4,18 @@
 #include <metal/machine.h>
 #include <metal/spi.h>
 
-extern inline void metal_spi_init(struct metal_spi *spi, int baud_rate);
-extern inline int metal_spi_transfer(struct metal_spi *spi, struct metal_spi_config *config, size_t len, char *tx_buf, char *rx_buf);
-extern inline int metal_spi_get_baud_rate(struct metal_spi *spi);
-extern inline int metal_spi_set_baud_rate(struct metal_spi *spi, int baud_rate);
+extern __inline__ void metal_spi_init(struct metal_spi *spi, int baud_rate);
+extern __inline__ int metal_spi_transfer(struct metal_spi *spi, struct metal_spi_config *config, size_t len, char *tx_buf, char *rx_buf);
+extern __inline__ int metal_spi_get_baud_rate(struct metal_spi *spi);
+extern __inline__ int metal_spi_set_baud_rate(struct metal_spi *spi, int baud_rate);
 
-struct metal_spi *metal_spi_get_device(int device_num)
+struct metal_spi *metal_spi_get_device(unsigned int device_num)
 {
-    if(device_num >= __METAL_DT_MAX_SPIS) {
-        return NULL;
+#if __METAL_DT_MAX_SPIS > 0
+    if (device_num < __METAL_DT_MAX_SPIS) {
+        return (struct metal_spi *) __metal_spi_table[device_num];
     }
+#endif
 
-    return (struct metal_spi *) __metal_spi_table[device_num];
+    return NULL;
 }