Fix src/main.c for target MCU.

This commit is contained in:
Ruben Ayrapetyan
2014-07-14 20:53:06 +04:00
parent 7a2397f235
commit 18a5852914
+23 -15
View File
@@ -55,10 +55,12 @@ fake_exit (void)
// //
// Initilaise the GPIO port. // Initilaise the GPIO port.
// //
GPIOD->MODER |= mode; volatile GPIO_TypeDef* gpio = GPIOD;
GPIOD->OSPEEDR |= speed;
GPIOD->OTYPER |= type; gpio->MODER |= mode;
GPIOD->PUPDR |= pullup; gpio->OSPEEDR |= speed;
gpio->OTYPER |= type;
gpio->PUPDR |= pullup;
// //
// Toggle the selected LED indefinitely. // Toggle the selected LED indefinitely.
// //
@@ -71,17 +73,17 @@ fake_exit (void)
while (1) while (1)
{ {
GPIOD->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); GPIOD->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
GPIOD->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); GPIOD->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
GPIOD->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); GPIOD->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
GPIOD->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); GPIOD->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
GPIOD->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); GPIOD->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
GPIOD->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); GPIOD->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
GPIOD->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); GPIOD->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
GPIOD->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); GPIOD->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
GPIOD->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); GPIOD->BSRRH = (uint16_t) (1 << pin); gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin);
for (index = 0; index < dash * 7; index++); for (index = 0; index < dash * 7; index++);
} }
@@ -90,19 +92,26 @@ fake_exit (void)
#endif #endif
} }
#ifdef __HOST
int int
main (int argc, char **argv) main (int argc, char **argv)
#endif /* __HOST */
#ifdef __TARGET_MCU
int
main (void)
#endif /* __TARGET_MCU */
{ {
statement st; statement st;
bool dump_tokens = false; bool dump_tokens = false;
bool dump_ast = false; bool dump_ast = false;
const char *file_name = NULL;
#ifdef __HOST #ifdef __HOST
const char *file_name = NULL;
FILE *file = NULL; FILE *file = NULL;
#endif #endif
mem_Init (); mem_Init ();
#ifdef __HOST
if (argc > 0) if (argc > 0)
for (int i = 1; i < argc; i++) for (int i = 1; i < argc; i++)
{ {
@@ -125,7 +134,6 @@ main (int argc, char **argv)
if (!dump_tokens) if (!dump_tokens)
dump_ast = true; dump_ast = true;
#ifdef __HOST
file = __fopen (file_name, "r"); file = __fopen (file_name, "r");
if (file == NULL) if (file == NULL)