aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-12-20 11:38:02 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-12-20 11:38:02 +0000
commit4e37e938e5c861d758168705e8d681d18d9a6243 (patch)
treef5cc7ea4f036a7248cb1f644065e8d56a4d7aef5 /os/hal/platforms
parent1a0f09d780e1e0cfbc1ca29e4453dc4875f9a39d (diff)
downloadChibiOS-4e37e938e5c861d758168705e8d681d18d9a6243.tar.gz
ChibiOS-4e37e938e5c861d758168705e8d681d18d9a6243.tar.bz2
ChibiOS-4e37e938e5c861d758168705e8d681d18d9a6243.zip
FatFS demo for LPC214x added.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1445 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms')
-rw-r--r--os/hal/platforms/LPC214x/spi_lld.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/os/hal/platforms/LPC214x/spi_lld.c b/os/hal/platforms/LPC214x/spi_lld.c
index f3f3e13b7..6e7f7a44b 100644
--- a/os/hal/platforms/LPC214x/spi_lld.c
+++ b/os/hal/platforms/LPC214x/spi_lld.c
@@ -55,20 +55,23 @@ SPIDriver SPID1;
* @param[out] rxbuf the pointer to the receive buffer or @p NULL
*/
void rw8(size_t n, const uint8_t *txbuf, uint8_t *rxbuf) {
+ size_t ntx = n;
while (n > 0) {
- if (SSPBase->SSP_SR & SR_RNE) {
+ uint32_t sr = SSPBase->SSP_SR;
+ if (sr & SR_RNE) {
uint8_t w = SSPBase->SSP_DR;
if (rxbuf != NULL)
*rxbuf++ = w;
n--;
continue; /* Priority over transmission. */
}
- if (SSPBase->SSP_SR & SR_TNF) {
+ if ((ntx > 0) && (sr & SR_TNF)) {
if (txbuf != NULL)
SSPBase->SSP_DR = *txbuf++;
else
- SSPBase->SSP_DR = 0xFF;
+ SSPBase->SSP_DR = 0xFFFFFFFF;
+ ntx--;
}
}
}
@@ -104,6 +107,9 @@ void spi_lld_start(SPIDriver *spip) {
}
/* Configuration.*/
SSPBase->SSP_CR1 = 0;
+ /* Emptying the receive FIFO, it happens to not be empty while debugging.*/
+ while (SSPBase->SSP_SR & SR_RNE)
+ (void) SSPBase->SSP_DR;
SSPBase->SSP_CR0 = spip->spd_config->spc_cr0;
SSPBase->SSP_CPSR = spip->spd_config->spc_cpsr;
SSPBase->SSP_CR1 = spip->spd_config->spc_cr1 | CR1_SSE;