Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

spi_bit.h 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef _GPXE_SPI_BIT_H
  2. #define _GPXE_SPI_BIT_H
  3. /** @file
  4. *
  5. * SPI bit-bashing interface
  6. *
  7. */
  8. #include <gpxe/spi.h>
  9. #include <gpxe/bitbash.h>
  10. /** A bit-bashing SPI bus */
  11. struct spi_bit_basher {
  12. /** SPI bus */
  13. struct spi_bus bus;
  14. /** Bit-bashing interface */
  15. struct bit_basher basher;
  16. /** Endianness of data
  17. *
  18. * SPI commands and addresses are always big-endian (i.e. MSB
  19. * transmitted first on the wire), but some cards
  20. * (e.g. natsemi) choose to regard the data stored in the
  21. * EEPROM as little-endian (i.e. LSB transmitted first on the
  22. * wire).
  23. */
  24. int endianness;
  25. };
  26. /** Bit indices used for SPI bit-bashing interface */
  27. enum {
  28. /** Serial clock */
  29. SPI_BIT_SCLK = 0,
  30. /** Master Out Slave In */
  31. SPI_BIT_MOSI,
  32. /** Master In Slave Out */
  33. SPI_BIT_MISO,
  34. /** Slave 0 select */
  35. SPI_BIT_SS0,
  36. };
  37. /**
  38. * Determine bit index for a particular slave
  39. *
  40. * @v slave Slave number
  41. * @ret index Bit index (i.e. SPI_BIT_SSN, where N=slave)
  42. */
  43. #define SPI_BIT_SS( slave ) ( SPI_BIT_SS0 + (slave) )
  44. /** Delay between SCLK transitions */
  45. #define SPI_BIT_UDELAY 1
  46. /** SPI bit basher treats data as big-endian */
  47. #define SPI_BIT_BIG_ENDIAN 0
  48. /** SPI bit basher treats data as little-endian */
  49. #define SPI_BIT_LITTLE_ENDIAN 1
  50. extern void init_spi_bit_basher ( struct spi_bit_basher *spibit );
  51. #endif /* _GPXE_SPI_BIT_H */