aboutsummaryrefslogtreecommitdiffstats
path: root/ports/ARM7-LPC214x/lpc214x_ssp.c
diff options
context:
space:
mode:
Diffstat (limited to 'ports/ARM7-LPC214x/lpc214x_ssp.c')
-rw-r--r--ports/ARM7-LPC214x/lpc214x_ssp.c58
1 files changed, 40 insertions, 18 deletions
diff --git a/ports/ARM7-LPC214x/lpc214x_ssp.c b/ports/ARM7-LPC214x/lpc214x_ssp.c
index 145badcf5..ebe29b6e7 100644
--- a/ports/ARM7-LPC214x/lpc214x_ssp.c
+++ b/ports/ARM7-LPC214x/lpc214x_ssp.c
@@ -17,38 +17,55 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * @file ports/ARM7-LPC214x/lpc214x_ssp.c
+ * @brief LPC214x SSP driver code.
+ * @addtogroup LPC214x_SSP
+ * @{
+ */
+
#include <ch.h>
#include "lpc214x.h"
#include "lpc214x_ssp.h"
-#ifdef SSP_USE_MUTEX
+#if LPC214x_SSP_USE_MUTEX
static Semaphore me;
#endif
+/**
+ * @brief Aquires access to the SSP bus.
+ * @note This function also handles the mutual exclusion on the SSP bus if
+ * the @p LPC214x_SSP_USE_MUTEX option is enabled.
+ */
void sspAcquireBus(void) {
-#ifdef SSP_USE_MUTEX
+#if LPC214x_SSP_USE_MUTEX
chSemWait(&me);
#endif
IO0CLR = 1 << 20;
}
+/**
+ * @brief Releases the SSP bus.
+ * @note This function also handles the mutual exclusion on the SSP bus if
+ * the @p LPC214x_SSP_USE_MUTEX option is enabled.
+ */
void sspReleaseBus(void) {
IO0SET = 1 << 20;
-#ifdef SSP_USE_MUTEX
+#if LPC214x_SSP_USE_MUTEX
chSemSignal(&me);
#endif
}
-/*
- * Synchronous SSP transfer.
- * @param in pointer to the incoming data buffer, if this parameter is set to
- * \p NULL then the incoming data is discarded.
- * @param out pointer to the outgoing data buffer, if this parameter is set to
- * \p NULL then 0xFF bytes will be output.
- * @param n the number of bytes to be transferred
+/**
+ * @brief Synchronous SSP transfer.
+ * @param[in] in pointer to the incoming data buffer, if this parameter is set
+ * to @p NULL then the incoming data is discarded
+ * @param[out] out pointer to the outgoing data buffer, if this parameter is
+ * set to @p NULL then 0xFF bytes will be output
+ * @param[in] n the number of bytes to be transferred
* @note The transfer is performed in a software loop and is not interrupt
* driven for performance reasons, this function should be invoked
* by a low priority thread in order to "play nice" with the
@@ -81,10 +98,13 @@ void sspRW(uint8_t *in, uint8_t *out, size_t n) {
}
}
-/*
- * SSP setup.
+/**
+ * @brief SSP setup.
+ * @param[in] cpsr the value for the @p CPSR register
+ * @param[in] cr0 the value for the @p CR0 register
+ * @param[in] cr1 the value for the @p CR1 register
*/
-void SetSSP(int cpsr, int cr0, int cr1) {
+void lpc214x_ssp_setup(int cpsr, int cr0, int cr1) {
SSP *ssp = SSPBase;
ssp->SSP_CR1 = 0;
@@ -93,18 +113,20 @@ void SetSSP(int cpsr, int cr0, int cr1) {
ssp->SSP_CR1 = cr1 | CR1_SSE;
}
-/*
- * SSP subsystem initialization.
+/**
+ * @brief SSP subsystem initialization.
*/
-void InitSSP(void) {
+void lpc214x_ssp_init(void) {
/* Enables the SPI1 clock */
PCONP = (PCONP & PCALL) | PCSPI1;
/* Clock = PCLK / 2 (fastest). */
- SetSSP(2, CR0_DSS8BIT | CR0_FRFSPI | CR0_CLOCKRATE(0), 0);
+ lpc214x_ssp_setup(2, CR0_DSS8BIT | CR0_FRFSPI | CR0_CLOCKRATE(0), 0);
-#ifdef SSP_USE_MUTEX
+#if LPC214x_SSP_USE_MUTEX
chSemInit(&me, 1);
#endif
}
+
+/** @} */