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_SW4 4
|
||||||
#define GPIO1_LED3R 9
|
#define GPIO1_LED3R 9
|
||||||
#define GPIO1_LED3G 10
|
#define GPIO1_LED3G 10
|
||||||
|
#define GPIO1_SPI0SEL 11
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -21,14 +21,28 @@
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "test.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.
|
* Red LED blinker thread, times are in milliseconds.
|
||||||
*/
|
*/
|
||||||
static WORKING_AREA(waThread1, 128);
|
static WORKING_AREA(waThread1, 128);
|
||||||
static msg_t Thread1(void *arg) {
|
static msg_t Thread1(void *arg) {
|
||||||
|
uint8_t digit = 0;
|
||||||
|
|
||||||
(void)arg;
|
(void)arg;
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
|
spiStartSend(&SPID1, 1, &digit);
|
||||||
|
digit++;
|
||||||
palClearPad(GPIO0, GPIO0_LED2);
|
palClearPad(GPIO0, GPIO0_LED2);
|
||||||
chThdSleepMilliseconds(500);
|
chThdSleepMilliseconds(500);
|
||||||
palSetPad(GPIO0, GPIO0_LED2);
|
palSetPad(GPIO0, GPIO0_LED2);
|
||||||
|
@ -78,9 +92,10 @@ int main(int argc, char **argv) {
|
||||||
(void)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.
|
* Creates the blinker threads.
|
||||||
|
|
|
@ -199,16 +199,16 @@ void spi_lld_start(SPIDriver *spip) {
|
||||||
/* Clock activation.*/
|
/* Clock activation.*/
|
||||||
#if LPC11xx_SPI_USE_SSP0
|
#if LPC11xx_SPI_USE_SSP0
|
||||||
if (&SPID1 == spip) {
|
if (&SPID1 == spip) {
|
||||||
LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 11);
|
|
||||||
LPC_SYSCON->SSP0CLKDIV = LPC11xx_SPI_SSP0CLKDIV;
|
LPC_SYSCON->SSP0CLKDIV = LPC11xx_SPI_SSP0CLKDIV;
|
||||||
|
LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 11);
|
||||||
NVICEnableVector(SSP0_IRQn,
|
NVICEnableVector(SSP0_IRQn,
|
||||||
CORTEX_PRIORITY_MASK(LPC11xx_SPI_SSP0_IRQ_PRIORITY));
|
CORTEX_PRIORITY_MASK(LPC11xx_SPI_SSP0_IRQ_PRIORITY));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if LPC11xx_SPI_USE_SSP1
|
#if LPC11xx_SPI_USE_SSP1
|
||||||
if (&SPID2 == spip) {
|
if (&SPID2 == spip) {
|
||||||
LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 18);
|
|
||||||
LPC_SYSCON->SSP1CLKDIV = LPC11xx_SPI_SSP1CLKDIV;
|
LPC_SYSCON->SSP1CLKDIV = LPC11xx_SPI_SSP1CLKDIV;
|
||||||
|
LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 18);
|
||||||
NVICEnableVector(SSP1_IRQn,
|
NVICEnableVector(SSP1_IRQn,
|
||||||
CORTEX_PRIORITY_MASK(LPC11xx_SPI_SSP1_IRQ_PRIORITY));
|
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 (spip->spd_state != SPI_STOP) {
|
||||||
#if LPC11xx_SPI_USE_SSP0
|
#if LPC11xx_SPI_USE_SSP0
|
||||||
if (&SPID1 == spip) {
|
if (&SPID1 == spip) {
|
||||||
LPC_SYSCON->SSP0CLKDIV = 0;
|
|
||||||
LPC_SYSCON->SYSAHBCLKCTRL &= ~(1 << 11);
|
LPC_SYSCON->SYSAHBCLKCTRL &= ~(1 << 11);
|
||||||
|
LPC_SYSCON->SSP0CLKDIV = 0;
|
||||||
NVICDisableVector(SSP0_IRQn);
|
NVICDisableVector(SSP0_IRQn);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if LPC11xx_SPI_USE_SSP1
|
#if LPC11xx_SPI_USE_SSP1
|
||||||
if (&SPID2 == spip) {
|
if (&SPID2 == spip) {
|
||||||
LPC_SYSCON->SSP1CLKDIV = 0;
|
|
||||||
LPC_SYSCON->SYSAHBCLKCTRL &= ~(1 << 18);
|
LPC_SYSCON->SYSAHBCLKCTRL &= ~(1 << 18);
|
||||||
|
LPC_SYSCON->SSP1CLKDIV = 0;
|
||||||
NVICDisableVector(SSP1_IRQn);
|
NVICDisableVector(SSP1_IRQn);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue