Contiki 2.5
|
Files | |
file | mspi-drv.c |
MSPI driver implementation | |
file | mspi-drv.h |
MSPI driver definitions | |
Macros | |
#define | MSPI_BUS_MANAGER 1 |
#define | MSPI_MODE_0 (0x00) |
#define | MSPI_MODE_1 (0x02) |
#define | MSPI_MODE_2 (0x01) |
#define | MSPI_MODE_3 (0x03) |
#define | MSPI_BAUD_MAX (0x00) |
#define | MSPI_BAUD_2MBPS (0x01) |
#define | MSPI_BAUD_1MBPS (0x03) |
Functions | |
void | mspi_init (uint8_t cs, uint8_t mode, uint16_t baud) |
Initialize the selected USART in the MSPI mode. More... | |
void | mspi_chip_select (uint8_t cs) |
This function enables the chip select by setting the needed I/O pins (BCD-Code) More... | |
void | mspi_chip_release (uint8_t cs) |
This function disables the chip select. More... | |
uint8_t | mspi_transceive (uint8_t data) |
This function can be use either to transmit or receive data via spi. More... | |
void | mspi_deinit (void) |
This function will set all MSPI registers to their default values. | |
void | add_to_spi_mgr (uint8_t cs, uint8_t mode, uint16_t baud) |
This function add a device to the SPI device table and calculates the specific checksum. More... | |
void | change_spi_mode (spi_dev new_config) |
This function changes the SPI configuration. More... | |
Variables | |
volatile uint16_t * | usart_t::UBRRn |
volatile uint8_t * | usart_t::XCKn_DDR |
volatile uint8_t | usart_t::XCKn |
volatile uint8_t * | usart_t::UCSRnA |
volatile uint8_t * | usart_t::UCSRnB |
volatile uint8_t * | usart_t::UCSRnC |
volatile uint8_t * | usart_t::UDRn |
There are a lot of possibilities to realize a Serial Peripheral Interface (SPI) with the ATmega1284p, but the hardware SPI is used by the transceiver chip AT86rf230. In combination with contiki it is not possible to build up an SPI Bus with this hardware SPI. A software SPI would be a solution, but the ATmega1284p provides another opportunity. The MSPI (Maser SPI) is an alternative function of the USART. There are two independent hardware USART, so it is possible to use one for the default debug RS232 interface, while the other one is free to be used as an MSPI. The only difference between an normal SPI and the MSPI is, that MSPI only supports slaves on the bus.
#define MSPI_BAUD_1MBPS (0x03) |
#define MSPI_BAUD_2MBPS (0x01) |
#define MSPI_BAUD_MAX (0x00) |
Maximum MSPI Baud Rate [bps]
Definition at line 150 of file mspi-drv.h.
Referenced by adxl345_init(), at45db_init(), microSD_init(), and mpl115a_init().
#define MSPI_BUS_MANAGER 1 |
#define MSPI_MODE_0 (0x00) |
MSPI Mode 0
Definition at line 116 of file mspi-drv.h.
Referenced by microSD_init(), and mpl115a_init().
#define MSPI_MODE_1 (0x02) |
MSPI Mode 1
Definition at line 124 of file mspi-drv.h.
#define MSPI_MODE_2 (0x01) |
MSPI Mode 2
Definition at line 132 of file mspi-drv.h.
#define MSPI_MODE_3 (0x03) |
MSPI Mode 3
Definition at line 140 of file mspi-drv.h.
Referenced by adxl345_init(), and at45db_init().
void add_to_spi_mgr | ( | uint8_t | cs, |
uint8_t | mode, | ||
uint16_t | baud | ||
) |
This function add a device to the SPI device table and calculates the specific checksum.
cs | Chip Select: Device ID |
mode | Select the (M)SPI mode (MSPI_MODE_0 ... MSPI_MODE_3) |
baud | The MSPI BAUD rate. Sometimes it is necessary to reduce the SCK. Use MSPI_BAUD_MAX in common case. |
Definition at line 106 of file mspi-drv.c.
Referenced by mspi_init().
void change_spi_mode | ( | spi_dev | new_config | ) |
This function changes the SPI configuration.
spi_dev | The specified entry of the SPI Device Table |
Definition at line 112 of file mspi-drv.c.
Referenced by mspi_chip_select().
void mspi_chip_release | ( | uint8_t | cs | ) |
This function disables the chip select.
cs | Chip Select: Device ID |
Definition at line 79 of file mspi-drv.c.
Referenced by adxl345_init(), adxl345_read(), adxl345_write(), at45db_buffer_to_page(), at45db_busy_wait(), at45db_erase_block(), at45db_erase_chip(), at45db_erase_page(), at45db_init(), at45db_page_to_buf(), at45db_read_buffer(), at45db_read_page_bypassed(), at45db_write_buffer(), at45db_write_page(), microSD_init(), microSD_read_block(), microSD_write_block(), microSD_write_cmd(), mpl115a_cmd(), and mpl115a_init().
void mspi_chip_select | ( | uint8_t | cs | ) |
This function enables the chip select by setting the needed I/O pins (BCD-Code)
cs | Chip Select: Device ID |
Definition at line 67 of file mspi-drv.c.
References change_spi_mode().
Referenced by adxl345_read(), adxl345_write(), at45db_busy_wait(), at45db_erase_block(), at45db_erase_chip(), at45db_erase_page(), at45db_init(), at45db_write_cmd(), microSD_init(), microSD_write_cmd(), and mpl115a_cmd().
void mspi_init | ( | uint8_t | cs, |
uint8_t | mode, | ||
uint16_t | baud | ||
) |
Initialize the selected USART in the MSPI mode.
mode | Select the (M)SPI mode (MSPI_MODE_0 ... MSPI_MODE_3) |
baud | The MSPI BAUD rate. Sometimes it is necessary to reduce the SCK. Use MSPI_BAUD_MAX in common case. |
Definition at line 46 of file mspi-drv.c.
References add_to_spi_mgr().
Referenced by adxl345_init(), at45db_init(), microSD_init(), and mpl115a_init().
uint8_t mspi_transceive | ( | uint8_t | data | ) |
This function can be use either to transmit or receive data via spi.
data |
|
Definition at line 85 of file mspi-drv.c.
Referenced by adxl345_read(), adxl345_write(), at45db_busy_wait(), at45db_init(), at45db_read_buffer(), at45db_read_page_bypassed(), at45db_write_buffer(), at45db_write_cmd(), at45db_write_page(), microSD_init(), microSD_read_block(), microSD_write_block(), microSD_write_cmd(), and mpl115a_cmd().
volatile uint16_t* usart_t::UBRRn |
MSPI Baud Rate Register (USART0/USART1)
Definition at line 167 of file mspi-drv.h.
volatile uint8_t* usart_t::UCSRnA |
MSPIM Control and Status Register A (USART0/USART1)
Definition at line 179 of file mspi-drv.h.
volatile uint8_t* usart_t::UCSRnB |
MSPIM Control and Status Register B (USART0/USART1)
Definition at line 183 of file mspi-drv.h.
volatile uint8_t* usart_t::UCSRnC |
MSPIM Control and Status Register C (USART0/USART1)
Definition at line 187 of file mspi-drv.h.
volatile uint8_t* usart_t::UDRn |
MSPI I/O Data Register (USART0/USART1)
Definition at line 191 of file mspi-drv.h.
volatile uint8_t usart_t::XCKn |
MSPI Serial Clock Pin (USART0/USART1)
Definition at line 175 of file mspi-drv.h.
volatile uint8_t* usart_t::XCKn_DDR |
MSPI Serial Clock Pin Data Direction Register (USART0/USART1)
Definition at line 171 of file mspi-drv.h.