Advertisement
Guest User

spi.h

a guest
Dec 1st, 2015
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1. /* spi.h - initialization of SPI device */
  2. #ifndef SPI_H
  3. #define SPI_H
  4.  
  5. //#include "task.h"
  6.  
  7. #include "sysconfig.h"
  8. #include <avr/io.h>
  9.  
  10. #define FOSC 6400000
  11. #define CS (1<<PB4)
  12. #define MOSI (1<<PB5)
  13. #define MISO (1<<PB6)
  14. #define SCK (1<<PB7)
  15. #define CS_DDR DDRB
  16. #define CS_PORT PORTB                  
  17. #define CS_ENABLE() (CS_PORT &= ~CS)    // set SS high
  18. #define CS_DISABLE() (CS_PORT |= CS)    // set SS low
  19.  
  20. /* function prototypes */
  21. void spi_init_master(void);                 // initialize spi master device (usually MC)
  22. unsigned char spi_write(unsigned char c);   // write to slave device via spi
  23. char spi_command(bool cmd, unsigned long arg, bool crc, uint16_t read);
  24.  
  25. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement