From 5f137a4fd613ccccb31f014481ff45be028cbcdf Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sat, 30 Dec 2017 13:58:28 -0500 Subject: [PATCH] morse code for debugging --- main.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index e4594e6..148f053 100644 --- a/main.c +++ b/main.c @@ -13,8 +13,14 @@ extern void delay(uint32_t count); * - got to 40MHz clock */ +void pulse(uint8_t byte); + int main(void) { + // prepare flash latency for 40MHz operation + FLASH->ACR &= ~(FLASH_ACR_LATENCY); + FLASH->ACR |= FLASH_ACR_LATENCY_2WS; + // turn on HSI RCC->CR |= RCC_CR_HSION; while ((RCC->CR & RCC_CR_HSIRDY) != RCC_CR_HSIRDY); @@ -49,15 +55,28 @@ int main(void) GPIOA->PUPDR &= ~(GPIO_PUPDR_PUPD5 | GPIO_PUPDR_PUPD0); GPIOA->PUPDR |= GPIO_PUPDR_PUPD5_0 | GPIO_PUPDR_PUPD0_1; // pd for button - while (1) { + pulse(*((uint8_t *)0x08080000)); // 0b00100101 + + while (1);/* { delay(500); //if (GPIOA->IDR & 0x01) GPIOA->BSRR |= 1 << 5; delay(500); //else GPIOA->BRR |= 1 << 5; - } + }*/ } void _exit(int code) { for (;;); } + +void pulse(uint8_t byte) +{ + int8_t i = 7; + do { + GPIOA->BSRR |= 1 << 5; + delay((byte & (1 << i)) ? 400 : 100); + GPIOA->BRR |= 1 << 5; + delay((byte & (1 << i)) ? 100 : 400); + } while (--i >= 0); +}