RP6 ROBOT SYSTEM - 4. RP6 CONTROL M256 WIFI Library
4.1.5. SPI Bus
The SPI functions should NOT be used if a microSD card is inserted. They have just
been ported from the RP6-M32 library and are not really necessary. Basically, you can
connect further SPI peripherals to the ISP connector. You just need to use a chipselect
pin from one of the other connectors and take into consideration that the active level
shifters of the SD card are connected on the bus (via series resistors)! However it is
better to use the UART / SPI ports for other SPI peripherals. The relevant functions to
do that might get included in the library later on. Up to now, you can only refer to the
AVR documentation.
void writeSPI(uint8_t data)
Transfers a data byte via the SPI bus.
writeWordSPI(uint16_t data)
Transfers two data bytes in a 16 bit variable via the SPI bus whereas the high byte is
sent first.
void writeBufferSPI(uint8_t *buffer, uint8_t length)
Transfers up to 255 bytes via the SPI bus from an array of sufficient size. The number
of bytes to be transferred from the array “buffer” are specified by the “length” para-
meter.
uint8_t readSPI(void)
Reads a data byte from the SPI bus.
uint16_t readWordSPI(void)
Reads two bytes from the SPI bus and sends them back as a 16 bit variable. The first
read byte is the high byte.
void readBufferSPI(uint8_t *buffer, uint8_t length)
Reads up to 255 bytes from the SPI bus into an array of sufficient size.
4.1.6. ADCs
All ADC channels can be read via the function:
uint16_t readADC(uint8_t channel)
already known from the RP6Lib. There is not (yet) an automatic variant for the RP6-
M256 that reads all ADC channels in sequence but you can add it yourself if you need
it. Check the normal RP6Library for an example.
The channels are named differently as in the RP6Lib – 16 channels are available:
ADC_15, ADC_14, … ADC_2, ADC_1 and ADC_0
- 32 -