aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTitanMKD2012-06-16 12:51:44 +0200
committerTitanMKD2012-06-16 12:51:44 +0200
commitd80ee80e06ee8791829594f299896fb7f3a276fc (patch)
tree8f46b2f55401224fc52a0cddd43ca4c2154f9660
parentfa315c672fd737d90f24e8f08e2749f0ae1deb39 (diff)
parent9fcea09741183419266b07c3d5003b57fcfc3d47 (diff)
Merge branch 'master' of git://github.com/jboone/libopencm3
-rw-r--r--lib/lpc43xx/ssp.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/lpc43xx/ssp.c b/lib/lpc43xx/ssp.c
index 592b5d8..e9cf5b0 100644
--- a/lib/lpc43xx/ssp.c
+++ b/lib/lpc43xx/ssp.c
@@ -113,6 +113,21 @@ u16 ssp_read(ssp_num_t ssp_num)
return SSP_DR(ssp_port);
}
+void ssp_wait_until_not_busy(ssp_num_t ssp_num)
+{
+ u32 ssp_port;
+
+ if(ssp_num == SSP0_NUM)
+ {
+ ssp_port = SSP0;
+ }else
+ {
+ ssp_port = SSP1;
+ }
+
+ while( (SSP_SR(ssp_port) & SSP_SR_BSY) );
+}
+
/* This Function Wait Data TX Ready, and Write Data to SSP */
void ssp_write(ssp_num_t ssp_num, u16 data)
{
@@ -130,5 +145,16 @@ void ssp_write(ssp_num_t ssp_num, u16 data)
while( (SSP_SR(ssp_port) & SSP_SR_TNF) == 0);
SSP_DR(ssp_port) = data;
+
+ /* Wait for not busy, since we're controlling CS# of
+ * devices manually and need to wait for the data to
+ * be sent. It may also be important to wait here
+ * in case we're configuring devices via SPI and also
+ * with GPIO control -- we need to know when SPI
+ * commands are effective before altering a device's
+ * state with GPIO. I'm thinking the MAX2837, for
+ * example...
+ */
+ ssp_wait_until_not_busy(ssp_num);
}