Beginners - Blinking LED

This forum is about you. Feel free to discuss anything is related to embedded and electronics, your awesome projects, your ideas, your announcements, not necessarily related to ChibiOS but to embedded in general. This forum is NOT for support.
Juzujka
Posts: 3
Joined: Wed Jun 11, 2014 10:24 am
Location: Russia
Contact:

Beginners - Blinking LED

Postby Juzujka » Wed Jun 11, 2014 10:56 am

Code sample for blinking LED

Here is example for
  • creating thread
  • IO pin toggle
Example uses STM32VL discovery
board.h considers

Code: Select all

...
/*
 * Port C setup.
 * Everything input with pull-up except:
 * PC8  - Push-pull output (LED4), initially low state.
 * PC9  - Push-pull output (LED3), initially low state.
 */
#define VAL_GPIOCCRL            0x88888888      /*  PC7...PC0 */
#define VAL_GPIOCCRH            0x88888833      /* PC15...PC8 */
#define VAL_GPIOCODR            0xFFFFFCFF
...


main.c

Code: Select all

#include <ch.h>
#include <hal.h>
#include <stm32f10x.h>
#include <chtypes.h>
#include <chmsg.h>

static WORKING_AREA(wa_blinker, 128);
static msg_t blinker(void *arg) {
  (void)arg;
  chRegSetThreadName("blinker");
  while (!chThdShouldTerminate()) {
    palTogglePad(GPIOC, GPIOC_LED3);
    chThdSleepMilliseconds(500);
  }
  return 0;
}
int main(void) {
  halInit();
  chSysInit();

  chThdCreateStatic(wa_blinker, sizeof(wa_blinker), NORMALPRIO, blinker, NULL);
  while (!chThdShouldTerminate()) {
    chThdSleepMilliseconds(500);
  }
  return 0;
}

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Beginners - Blinking LED

Postby Tectu » Sun Jun 22, 2014 1:20 am

Thank you for sharing.
Probably you should add some information about the ChibiOS/RT version you are using. Comparing to the current /demos and /testhal this seems to be "old" code.


~ Tectu


Return to “User Projects”

Who is online

Users browsing this forum: No registered users and 12 guests