Replaced port+pad by line in the demos and testhal.
This commit is contained in:
parent
d10aa9e7a1
commit
4435bdec24
|
@ -20,9 +20,8 @@
|
|||
|
||||
typedef struct led_config
|
||||
{
|
||||
ioportid_t port;
|
||||
ioportid_t line;
|
||||
uint32_t sleep;
|
||||
uint8_t pin;
|
||||
} led_config_t;
|
||||
|
||||
/*
|
||||
|
@ -36,11 +35,11 @@ static THD_FUNCTION(blinkLed, arg) {
|
|||
|
||||
chRegSetThreadName("Blinker");
|
||||
|
||||
palSetPadMode(ledConfig->port, ledConfig->pin, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(ledConfig->line, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
|
||||
while (TRUE) {
|
||||
chThdSleepMilliseconds(ledConfig->sleep);
|
||||
palTogglePad(ledConfig->port, ledConfig->pin);
|
||||
palToggleLine(ledConfig->line);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,37 +61,43 @@ int main(void)
|
|||
chSysInit();
|
||||
|
||||
/* Configure RX and TX pins for UART0.*/
|
||||
palSetPadMode(GPIOA, GPIOA_UART0_RX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
|
||||
palSetPadMode(GPIOA, GPIOA_UART0_TX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
|
||||
palSetLineMode(LINE_UART0_RX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
|
||||
palSetLineMode(LINE_UART0_TX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
|
||||
|
||||
/* Start the serial driver with the default configuration.*/
|
||||
sdStart(&SD1, NULL);
|
||||
|
||||
if (!palReadPad(GPIOF, GPIOF_SW2)) {
|
||||
if (!palReadLine(LINE_SW2)) {
|
||||
test_execute((BaseSequentialStream *)&SD1);
|
||||
}
|
||||
|
||||
ledRed.port = GPIOF;
|
||||
ledRed.pin = GPIOF_LED_RED;
|
||||
ledRed.line = LINE_LED_RED;
|
||||
ledRed.sleep = 100;
|
||||
|
||||
ledGreen.port = GPIOF;
|
||||
ledGreen.pin = GPIOF_LED_GREEN;
|
||||
ledGreen.line = LINE_LED_GREEN;
|
||||
ledGreen.sleep = 101;
|
||||
|
||||
ledBlue.port = GPIOF;
|
||||
ledBlue.pin = GPIOF_LED_BLUE;
|
||||
ledBlue.line = LINE_LED_BLUE;
|
||||
ledBlue.sleep = 102;
|
||||
|
||||
/* Creating the blinker threads.*/
|
||||
chThdCreateStatic(waBlinkLedRed, sizeof(waBlinkLedRed), NORMALPRIO, blinkLed,
|
||||
chThdCreateStatic(waBlinkLedRed,
|
||||
sizeof(waBlinkLedRed),
|
||||
NORMALPRIO,
|
||||
blinkLed,
|
||||
&ledRed);
|
||||
|
||||
chThdCreateStatic(waBlinkLedGreen, sizeof(waBlinkLedGreen), NORMALPRIO,
|
||||
blinkLed, &ledGreen);
|
||||
chThdCreateStatic(waBlinkLedGreen,
|
||||
sizeof(waBlinkLedGreen),
|
||||
NORMALPRIO,
|
||||
blinkLed,
|
||||
&ledGreen);
|
||||
|
||||
chThdCreateStatic(waBlinkLedBlue, sizeof(waBlinkLedBlue), NORMALPRIO,
|
||||
blinkLed, &ledBlue);
|
||||
chThdCreateStatic(waBlinkLedBlue,
|
||||
sizeof(waBlinkLedBlue),
|
||||
NORMALPRIO,
|
||||
blinkLed,
|
||||
&ledBlue);
|
||||
|
||||
/* Normal main() thread activity.*/
|
||||
while (TRUE) {
|
||||
|
|
|
@ -20,9 +20,8 @@
|
|||
|
||||
typedef struct led_config
|
||||
{
|
||||
ioportid_t port;
|
||||
ioportid_t line;
|
||||
uint32_t sleep;
|
||||
uint8_t pin;
|
||||
} led_config_t;
|
||||
|
||||
/*
|
||||
|
@ -38,11 +37,11 @@ static THD_FUNCTION(blinkLed, arg) {
|
|||
chRegSetThreadName("Blinker");
|
||||
|
||||
/* Configure pin as push-pull output.*/
|
||||
palSetPadMode(ledConfig->port, ledConfig->pin, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(ledConfig->line, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
|
||||
while (TRUE) {
|
||||
chThdSleepMilliseconds(ledConfig->sleep);
|
||||
palTogglePad(ledConfig->port, ledConfig->pin);
|
||||
palToggleLine(ledConfig->line);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,43 +63,51 @@ int main(void)
|
|||
chSysInit();
|
||||
|
||||
/* Configure RX and TX pins for UART0.*/
|
||||
palSetPadMode(GPIOA, GPIOA_UART0_RX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
|
||||
palSetPadMode(GPIOA, GPIOA_UART0_TX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
|
||||
palSetLineMode(LINE_UART0_RX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
|
||||
palSetLineMode(LINE_UART0_TX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
|
||||
|
||||
/* Start the serial driver with the default configuration.*/
|
||||
sdStart(&SD1, NULL);
|
||||
|
||||
if (!palReadPad(GPIOJ, GPIOJ_SW1)) {
|
||||
if (!palReadLine(LINE_SW1)) {
|
||||
test_execute((BaseSequentialStream *)&SD1);
|
||||
}
|
||||
|
||||
led1.port = GPIOF;
|
||||
led1.pin = GPIOF_LED0;
|
||||
led1.line = LINE_LED0;
|
||||
led1.sleep = 100;
|
||||
|
||||
led2.port = GPIOF;
|
||||
led2.pin = GPIOF_LED1;
|
||||
led2.line = LINE_LED1;
|
||||
led2.sleep = 101;
|
||||
|
||||
led3.port = GPION;
|
||||
led3.pin = GPION_LED2;
|
||||
led3.line = LINE_LED2;
|
||||
led3.sleep = 102;
|
||||
|
||||
led4.port = GPION;
|
||||
led4.pin = GPION_LED3;
|
||||
led4.line = LINE_LED3;
|
||||
led4.sleep = 103;
|
||||
|
||||
/* Creating the blinker threads.*/
|
||||
chThdCreateStatic(waBlinkLed1, sizeof(waBlinkLed1), NORMALPRIO, blinkLed,
|
||||
chThdCreateStatic(waBlinkLed1,
|
||||
sizeof(waBlinkLed1),
|
||||
NORMALPRIO,
|
||||
blinkLed,
|
||||
&led1);
|
||||
|
||||
chThdCreateStatic(waBlinkLed2, sizeof(waBlinkLed2), NORMALPRIO, blinkLed,
|
||||
chThdCreateStatic(waBlinkLed2,
|
||||
sizeof(waBlinkLed2),
|
||||
NORMALPRIO,
|
||||
blinkLed,
|
||||
&led2);
|
||||
|
||||
chThdCreateStatic(waBlinkLed3, sizeof(waBlinkLed3), NORMALPRIO, blinkLed,
|
||||
chThdCreateStatic(waBlinkLed3,
|
||||
sizeof(waBlinkLed3),
|
||||
NORMALPRIO,
|
||||
blinkLed,
|
||||
&led3);
|
||||
|
||||
chThdCreateStatic(waBlinkLed4, sizeof(waBlinkLed4), NORMALPRIO, blinkLed,
|
||||
chThdCreateStatic(waBlinkLed4,
|
||||
sizeof(waBlinkLed4),
|
||||
NORMALPRIO,
|
||||
blinkLed,
|
||||
&led4);
|
||||
|
||||
/*
|
||||
|
|
|
@ -22,7 +22,7 @@ static void extcb1(EXTDriver *extp, expchannel_t channel)
|
|||
(void)extp;
|
||||
(void)channel;
|
||||
|
||||
palTogglePad(GPIOF, GPIOF_LED_RED);
|
||||
palToggleLine(LINE_LED_RED);
|
||||
}
|
||||
|
||||
static void extcb2(EXTDriver *extp, expchannel_t channel)
|
||||
|
@ -30,7 +30,7 @@ static void extcb2(EXTDriver *extp, expchannel_t channel)
|
|||
(void)extp;
|
||||
(void)channel;
|
||||
|
||||
palTogglePad(GPIOF, GPIOF_LED_GREEN);
|
||||
palToggleLine(LINE_LED_GREEN);
|
||||
}
|
||||
|
||||
static const EXTConfig extcfg =
|
||||
|
@ -108,10 +108,10 @@ int main(void)
|
|||
halInit();
|
||||
chSysInit();
|
||||
|
||||
palSetPadMode(GPIOF, GPIOF_LED_RED, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOF, GPIOF_LED_GREEN, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOF, GPIOF_SW1, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(GPIOF, GPIOF_SW2, PAL_MODE_INPUT_PULLUP);
|
||||
palSetLineMode(LINE_LED_RED, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_LED_GREEN, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_SW1, PAL_MODE_INPUT_PULLUP);
|
||||
palSetLineMode(LINE_SW2, PAL_MODE_INPUT_PULLUP);
|
||||
|
||||
extStart(&EXTD1, &extcfg);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
static void gpt1cb(GPTDriver *gptp)
|
||||
{
|
||||
(void)gptp;
|
||||
palClearPad(GPIOF, GPIOF_LED_RED);
|
||||
palClearLine(LINE_LED_RED);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -32,7 +32,7 @@ static void gpt1cb(GPTDriver *gptp)
|
|||
static void gpt7cb(GPTDriver *gptp)
|
||||
{
|
||||
(void)gptp;
|
||||
palSetPad(GPIOF, GPIOF_LED_RED);
|
||||
palSetLine(LINE_LED_RED);
|
||||
chSysLockFromISR();
|
||||
gptStartOneShotI(&GPTD1, 31250); /* 0.1 second pulse.*/
|
||||
chSysUnlockFromISR();
|
||||
|
@ -71,7 +71,7 @@ int main(void)
|
|||
halInit();
|
||||
chSysInit();
|
||||
|
||||
palSetPadMode(GPIOF, GPIOF_LED_RED, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_LED_RED, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
|
||||
/*
|
||||
* Start the gpt drivers with the custom configurations.
|
||||
|
|
|
@ -70,8 +70,8 @@ int main(void)
|
|||
chSysInit();
|
||||
|
||||
/* Configure RX and TX pins for UART0.*/
|
||||
palSetPadMode(GPIOA, GPIOA_UART0_RX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
|
||||
palSetPadMode(GPIOA, GPIOA_UART0_TX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
|
||||
palSetLineMode(LINE_UART0_RX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
|
||||
palSetLineMode(LINE_UART0_TX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1));
|
||||
|
||||
/*
|
||||
* Start the serial driver with the default configuration.
|
||||
|
@ -79,8 +79,8 @@ int main(void)
|
|||
sdStart(&SD1, NULL);
|
||||
|
||||
/* Configure SCK and SCL pins for I2C0.*/
|
||||
palSetPadMode(GPIOB, GPIOB_I2C0_SCL, PAL_MODE_OUTPUT_PUSHPULL | PAL_MODE_ALTERNATE(3));
|
||||
palSetPadMode(GPIOB, GPIOB_I2C0_SDA, PAL_MODE_OUTPUT_OPENDRAIN | PAL_MODE_ALTERNATE(3));
|
||||
palSetLineMode(LINE_I2C0_SCL, PAL_MODE_OUTPUT_PUSHPULL | PAL_MODE_ALTERNATE(3));
|
||||
palSetLineMode(LINE_I2C0_SDA, PAL_MODE_OUTPUT_OPENDRAIN | PAL_MODE_ALTERNATE(3));
|
||||
|
||||
/*
|
||||
* Start the i2c driver with the custom configuration.
|
||||
|
|
|
@ -20,27 +20,27 @@
|
|||
static void pwmpcb(PWMDriver *pwmp)
|
||||
{
|
||||
(void)pwmp;
|
||||
palClearPad(GPIOF, GPIOF_LED_RED);
|
||||
palClearPad(GPIOF, GPIOF_LED_GREEN);
|
||||
palClearPad(GPIOF, GPIOF_LED_BLUE);
|
||||
palClearLine(LINE_LED_RED);
|
||||
palClearLine(LINE_LED_GREEN);
|
||||
palClearLine(LINE_LED_BLUE);
|
||||
}
|
||||
|
||||
static void pwmc1cb0(PWMDriver *pwmp)
|
||||
{
|
||||
(void)pwmp;
|
||||
palSetPad(GPIOF, GPIOF_LED_RED);
|
||||
palSetLine(LINE_LED_RED);
|
||||
}
|
||||
|
||||
static void pwmc1cb1(PWMDriver *pwmp)
|
||||
{
|
||||
(void)pwmp;
|
||||
palSetPad(GPIOF, GPIOF_LED_GREEN);
|
||||
palSetLine(LINE_LED_GREEN);
|
||||
}
|
||||
|
||||
static void pwmc1cb2(PWMDriver *pwmp)
|
||||
{
|
||||
(void)pwmp;
|
||||
palSetPad(GPIOF, GPIOF_LED_BLUE);
|
||||
palSetLine(LINE_LED_BLUE);
|
||||
}
|
||||
|
||||
static PWMConfig pwmcfg = {
|
||||
|
@ -74,9 +74,9 @@ int main(void)
|
|||
halInit();
|
||||
chSysInit();
|
||||
|
||||
palSetPadMode(GPIOF, GPIOF_LED_RED, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOF, GPIOF_LED_GREEN, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOF, GPIOF_LED_BLUE, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_LED_RED, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_LED_GREEN, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_LED_BLUE, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
|
||||
/*
|
||||
* Start PWM driver
|
||||
|
|
|
@ -104,15 +104,11 @@ int main(void)
|
|||
halInit();
|
||||
chSysInit();
|
||||
|
||||
palSetPadMode(GPIOA, GPIOA_SSI0_CLK, PAL_MODE_OUTPUT_PUSHPULL |
|
||||
PAL_MODE_ALTERNATE(2));
|
||||
palSetPadMode(GPIOA, GPIOA_SSI0_RX, PAL_MODE_OUTPUT_PUSHPULL |
|
||||
PAL_MODE_ALTERNATE(2));
|
||||
palSetPadMode(GPIOA, GPIOA_SSI0_TX, PAL_MODE_OUTPUT_PUSHPULL |
|
||||
PAL_MODE_ALTERNATE(2));
|
||||
palSetPadMode(GPIOA, GPIOA_PIN3, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
|
||||
palSetPadMode(GPIOF, GPIOF_LED_GREEN, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_SSI0_CLK, PAL_MODE_OUTPUT_PUSHPULL | PAL_MODE_ALTERNATE(2));
|
||||
palSetLineMode(LINE_SSI0_RX, PAL_MODE_OUTPUT_PUSHPULL | PAL_MODE_ALTERNATE(2));
|
||||
palSetLineMode(LINE_SSI0_TX, PAL_MODE_OUTPUT_PUSHPULL | PAL_MODE_ALTERNATE(2));
|
||||
palSetLineMode(LINE_LED_GREEN, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOA, GPIOA_PIN3, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
|
||||
/*
|
||||
* Prepare transmit pattern.
|
||||
|
@ -124,10 +120,16 @@ int main(void)
|
|||
/*
|
||||
* Starting the transmitter and receiver threads.
|
||||
*/
|
||||
chThdCreateStatic(spi_thread_1_wa, sizeof(spi_thread_1_wa),
|
||||
NORMALPRIO + 1, spi_thread_1, NULL);
|
||||
chThdCreateStatic(spi_thread_2_wa, sizeof(spi_thread_2_wa),
|
||||
NORMALPRIO + 1, spi_thread_2, NULL);
|
||||
chThdCreateStatic(spi_thread_1_wa,
|
||||
sizeof(spi_thread_1_wa),
|
||||
NORMALPRIO + 1,
|
||||
spi_thread_1,
|
||||
NULL);
|
||||
chThdCreateStatic(spi_thread_2_wa,
|
||||
sizeof(spi_thread_2_wa),
|
||||
NORMALPRIO + 1,
|
||||
spi_thread_2,
|
||||
NULL);
|
||||
|
||||
/*
|
||||
* Normal main() thread activity
|
||||
|
|
|
@ -21,7 +21,7 @@ static bool watchdog_timeout(WDGDriver *wdgp)
|
|||
{
|
||||
(void)wdgp;
|
||||
|
||||
palSetPad(GPIOF, GPIOF_LED_RED);
|
||||
palSetLine(LINE_LED_RED);
|
||||
|
||||
/* Return true to prevent a reset on the next timeout.*/
|
||||
return true;
|
||||
|
@ -54,11 +54,10 @@ int main(void) {
|
|||
halInit();
|
||||
chSysInit();
|
||||
|
||||
palSetPadMode(GPIOF, GPIOF_LED_RED, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOF, GPIOF_LED_BLUE, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_LED_RED, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_LED_BLUE, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
|
||||
palSetPadMode(GPIOF, GPIOF_SW1, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(GPIOF, GPIOF_SW2, PAL_MODE_INPUT_PULLUP);
|
||||
palSetLineMode(LINE_SW1, PAL_MODE_INPUT_PULLUP);
|
||||
|
||||
/*
|
||||
* Starting the watchdog driver.
|
||||
|
@ -69,13 +68,13 @@ int main(void) {
|
|||
* Normal main() thread activity, it resets the watchdog.
|
||||
*/
|
||||
while (true) {
|
||||
if (palReadPad(GPIOF, GPIOF_SW1)) {
|
||||
if (palReadLine(LINE_SW1)) {
|
||||
/* Only reset the watchdog if the button is not pressed */
|
||||
wdgReset(&WDGD1);
|
||||
palClearPad(GPIOF, GPIOF_LED_RED);
|
||||
palClearLine(LINE_LED_RED);
|
||||
}
|
||||
|
||||
palTogglePad(GPIOF, GPIOF_LED_BLUE);
|
||||
palToggleLine(LINE_LED_BLUE);
|
||||
|
||||
chThdSleepMilliseconds(500);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue