Patch from David Gustafsson: break out SPI functions and fix bug in capacity
calculation. Removed expensive modulo operations from sd_read and sd_write because the block size is now a variable. (nvt)
This commit is contained in:
parent
9b801b59c7
commit
9b4cd05e1f
4 changed files with 89 additions and 64 deletions
|
@ -38,9 +38,10 @@
|
|||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "msb430-uart1.h"
|
||||
#include "sd-arch.h"
|
||||
|
||||
#include <string.h>
|
||||
#define SPI_IDLE 0xff
|
||||
|
||||
int
|
||||
sd_arch_init(void)
|
||||
|
@ -58,3 +59,32 @@ sd_arch_init(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
sd_arch_spi_write(int c)
|
||||
{
|
||||
UART_TX = c;
|
||||
UART_WAIT_TXDONE();
|
||||
}
|
||||
|
||||
void
|
||||
sd_arch_spi_write_block(uint8_t *bytes, int amount)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < amount; i++) {
|
||||
UART_TX = bytes[i];
|
||||
UART_WAIT_TXDONE();
|
||||
UART_RX;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned
|
||||
sd_arch_spi_read(void)
|
||||
{
|
||||
UART_TX = SPI_IDLE;
|
||||
UART_WAIT_RX();
|
||||
return UART_RX;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue