12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- /*
- * Bit-Banged SPI routines
- */
-
- #ifndef _ARM_SPI_H
- #define _ARM_SPI_H
-
- #include <stdint.h>
-
- #define DIR_OUTPUT 0
- #define DIR_INPUT 1
-
- void gpioInit(void);
- void gpioDir(uint8_t num, uint8_t dir);
- void gpioSet(uint8_t num, uint8_t val);
- uint8_t gpioGet(uint8_t num);
-
- #define SCK_on gpioSet(22, 1)
- #define SCK_off gpioSet(22, 0)
- #define SCK_dir gpioDir(22, DIR_OUTPUT)
-
- #define MO_on gpioSet(21, 1)
- #define MO_off gpioSet(21, 0)
- #define MO_dir gpioDir(21, DIR_OUTPUT)
-
- #define CS_on gpioSet(24, 1)
- #define CS_off gpioSet(24, 0)
- #define CS_dir gpioDir(24, DIR_OUTPUT)
-
- #define MI_1 gpioGet(23)
- #define MI_0 gpioGet(23)
- #define MI_dir gpioDir(23, DIR_INPUT)
-
- #define GDO_1 gpioGet(25)
- #define GDO_0 gpioGet(25)
- #define GDO_dir gpioDir(25, DIR_INPUT)
-
- #define NOP() __asm__ __volatile__("nop\n\t" \
- "nop\n\t" \
- "nop\n\t" \
- "nop\n\t" \
- "nop\n\t" \
- "nop\n\t")
-
- #endif
|