29 #define SPI_HAS_TRANSACTION 
   31 #define SPI_CLOCK_BASE 256000000 
   34 #define SPI_CLOCK_DIV1 BCM2835_SPI_CLOCK_DIVIDER_1 
   35 #define SPI_CLOCK_DIV2 BCM2835_SPI_CLOCK_DIVIDER_2 
   36 #define SPI_CLOCK_DIV4 BCM2835_SPI_CLOCK_DIVIDER_4 
   37 #define SPI_CLOCK_DIV8 BCM2835_SPI_CLOCK_DIVIDER_8 
   38 #define SPI_CLOCK_DIV16 BCM2835_SPI_CLOCK_DIVIDER_16 
   39 #define SPI_CLOCK_DIV32 BCM2835_SPI_CLOCK_DIVIDER_32 
   40 #define SPI_CLOCK_DIV64 BCM2835_SPI_CLOCK_DIVIDER_64 
   41 #define SPI_CLOCK_DIV128 BCM2835_SPI_CLOCK_DIVIDER_128 
   42 #define SPI_CLOCK_DIV256 BCM2835_SPI_CLOCK_DIVIDER_256 
   43 #define SPI_CLOCK_DIV512 BCM2835_SPI_CLOCK_DIVIDER_512 
   44 #define SPI_CLOCK_DIV1024 BCM2835_SPI_CLOCK_DIVIDER_1024 
   45 #define SPI_CLOCK_DIV2048 BCM2835_SPI_CLOCK_DIVIDER_2048 
   46 #define SPI_CLOCK_DIV4096 BCM2835_SPI_CLOCK_DIVIDER_4096 
   47 #define SPI_CLOCK_DIV8192 BCM2835_SPI_CLOCK_DIVIDER_8192 
   48 #define SPI_CLOCK_DIV16384 BCM2835_SPI_CLOCK_DIVIDER_16384 
   49 #define SPI_CLOCK_DIV32768 BCM2835_SPI_CLOCK_DIVIDER_32768 
   50 #define SPI_CLOCK_DIV65536 BCM2835_SPI_CLOCK_DIVIDER_65536 
   53 #define SPI_MODE0 BCM2835_SPI_MODE0 
   54 #define SPI_MODE1 BCM2835_SPI_MODE1 
   55 #define SPI_MODE2 BCM2835_SPI_MODE2 
   56 #define SPI_MODE3 BCM2835_SPI_MODE3 
   58 #define LSBFIRST BCM2835_SPI_BIT_ORDER_LSBFIRST 
   59 #define MSBFIRST BCM2835_SPI_BIT_ORDER_MSBFIRST 
   61 const uint8_t SS   = 24;
 
   62 const uint8_t MOSI = 19;
 
   63 const uint8_t MISO = 21;
 
   64 const uint8_t SCK  = 23;
 
   80         init(SPI_CLOCK_DIV32, MSBFIRST, SPI_MODE0);
 
   93         if (
clock >= SPI_CLOCK_BASE) {
 
   94             divider = SPI_CLOCK_DIV1;
 
   95         } 
else if (
clock >= SPI_CLOCK_BASE / 2) {
 
   96             divider = SPI_CLOCK_DIV2;
 
   97         } 
else if (
clock >= SPI_CLOCK_BASE / 4) {
 
   98             divider = SPI_CLOCK_DIV4;
 
   99         } 
else if (
clock >= SPI_CLOCK_BASE / 8) {
 
  100             divider = SPI_CLOCK_DIV8;
 
  101         } 
else if (
clock >= SPI_CLOCK_BASE / 16) {
 
  102             divider = SPI_CLOCK_DIV16;
 
  103         } 
else if (
clock >= SPI_CLOCK_BASE / 32) {
 
  104             divider = SPI_CLOCK_DIV32;
 
  105         } 
else if (
clock >= SPI_CLOCK_BASE / 64) {
 
  106             divider = SPI_CLOCK_DIV64;
 
  107         } 
else if (
clock >= SPI_CLOCK_BASE / 128) {
 
  108             divider = SPI_CLOCK_DIV128;
 
  109         } 
else if (
clock >= SPI_CLOCK_BASE / 256) {
 
  110             divider = SPI_CLOCK_DIV256;
 
  111         } 
else if (
clock >= SPI_CLOCK_BASE / 512) {
 
  112             divider = SPI_CLOCK_DIV512;
 
  113         } 
else if (
clock >= SPI_CLOCK_BASE / 1024) {
 
  114             divider = SPI_CLOCK_DIV1024;
 
  115         } 
else if (
clock >= SPI_CLOCK_BASE / 2048) {
 
  116             divider = SPI_CLOCK_DIV2048;
 
  117         } 
else if (
clock >= SPI_CLOCK_BASE / 4096) {
 
  118             divider = SPI_CLOCK_DIV4096;
 
  119         } 
else if (
clock >= SPI_CLOCK_BASE / 8192) {
 
  120             divider = SPI_CLOCK_DIV8192;
 
  121         } 
else if (
clock >= SPI_CLOCK_BASE / 16384) {
 
  122             divider = SPI_CLOCK_DIV16384;
 
  123         } 
else if (
clock >= SPI_CLOCK_BASE / 32768) {
 
  124             divider = SPI_CLOCK_DIV32768;
 
  125         } 
else if (
clock >= SPI_CLOCK_BASE / 65536) {
 
  126             divider = SPI_CLOCK_DIV65536;
 
  129             divider = SPI_CLOCK_DIV32;
 
  132         init(divider, bitOrder, dataMode);
 
  147     void init(uint16_t divider, uint8_t bitOrder, uint8_t dataMode)
 
  178     inline static void transfernb(
char* tbuf, 
char* rbuf, uint32_t len);
 
  185     inline static void transfern(
char* buf, uint32_t len);
 
  242     static uint8_t initialized;