diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2017-12-30 13:58:28 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2017-12-30 13:58:28 -0500 |
commit | 5f137a4fd613ccccb31f014481ff45be028cbcdf (patch) | |
tree | bea8d470561d4bf4e683f27825fd2b9b560f0be9 /main.c | |
parent | 374c43ba3805c85bf70a86829434eb05731e8083 (diff) |
morse code for debugging
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -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);
+}
|