git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2284 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
02caf0b187
commit
d39721a6c2
|
@ -78,6 +78,7 @@
|
|||
#define GPIO1_SW4 4
|
||||
#define GPIO1_LED3R 9
|
||||
#define GPIO1_LED3G 10
|
||||
#define GPIO1_SPI0SEL 11
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -21,14 +21,28 @@
|
|||
#include "hal.h"
|
||||
#include "test.h"
|
||||
|
||||
|
||||
/* Maximum speed SPI configuration (1MHz, CPHA=0, CPOL=0).*/
|
||||
static SPIConfig spicfg = {
|
||||
NULL,
|
||||
GPIO1,
|
||||
GPIO1_SPI0SEL,
|
||||
CR0_DSS8BIT | CR0_FRFSPI | CR0_CLOCKRATE(0),
|
||||
0,
|
||||
48
|
||||
};
|
||||
|
||||
/*
|
||||
* Red LED blinker thread, times are in milliseconds.
|
||||
*/
|
||||
static WORKING_AREA(waThread1, 128);
|
||||
static msg_t Thread1(void *arg) {
|
||||
uint8_t digit = 0;
|
||||
|
||||
(void)arg;
|
||||
while (TRUE) {
|
||||
spiStartSend(&SPID1, 1, &digit);
|
||||
digit++;
|
||||
palClearPad(GPIO0, GPIO0_LED2);
|
||||
chThdSleepMilliseconds(500);
|
||||
palSetPad(GPIO0, GPIO0_LED2);
|
||||
|
@ -78,9 +92,10 @@ int main(int argc, char **argv) {
|
|||
(void)argv;
|
||||
|
||||
/*
|
||||
* Activates the serial driver 1 using the driver default configuration.
|
||||
* Activates the SD1 and SPI1 drivers.
|
||||
*/
|
||||
sdStart(&SD1, NULL);
|
||||
sdStart(&SD1, NULL); /* Default: 38400,8,N,1. */
|
||||
spiStart(&SPID1, &spicfg);
|
||||
|
||||
/*
|
||||
* Creates the blinker threads.
|
||||
|
|
|
@ -199,16 +199,16 @@ void spi_lld_start(SPIDriver *spip) {
|
|||
/* Clock activation.*/
|
||||
#if LPC11xx_SPI_USE_SSP0
|
||||
if (&SPID1 == spip) {
|
||||
LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 11);
|
||||
LPC_SYSCON->SSP0CLKDIV = LPC11xx_SPI_SSP0CLKDIV;
|
||||
LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 11);
|
||||
NVICEnableVector(SSP0_IRQn,
|
||||
CORTEX_PRIORITY_MASK(LPC11xx_SPI_SSP0_IRQ_PRIORITY));
|
||||
}
|
||||
#endif
|
||||
#if LPC11xx_SPI_USE_SSP1
|
||||
if (&SPID2 == spip) {
|
||||
LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 18);
|
||||
LPC_SYSCON->SSP1CLKDIV = LPC11xx_SPI_SSP1CLKDIV;
|
||||
LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 18);
|
||||
NVICEnableVector(SSP1_IRQn,
|
||||
CORTEX_PRIORITY_MASK(LPC11xx_SPI_SSP1_IRQ_PRIORITY));
|
||||
}
|
||||
|
@ -237,16 +237,16 @@ void spi_lld_stop(SPIDriver *spip) {
|
|||
if (spip->spd_state != SPI_STOP) {
|
||||
#if LPC11xx_SPI_USE_SSP0
|
||||
if (&SPID1 == spip) {
|
||||
LPC_SYSCON->SSP0CLKDIV = 0;
|
||||
LPC_SYSCON->SYSAHBCLKCTRL &= ~(1 << 11);
|
||||
LPC_SYSCON->SSP0CLKDIV = 0;
|
||||
NVICDisableVector(SSP0_IRQn);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if LPC11xx_SPI_USE_SSP1
|
||||
if (&SPID2 == spip) {
|
||||
LPC_SYSCON->SSP1CLKDIV = 0;
|
||||
LPC_SYSCON->SYSAHBCLKCTRL &= ~(1 << 18);
|
||||
LPC_SYSCON->SSP1CLKDIV = 0;
|
||||
NVICDisableVector(SSP1_IRQn);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue