morse code for debugging

master
Clyne Sullivan 7 years ago
parent 374c43ba38
commit 5f137a4fd6

@ -13,8 +13,14 @@ extern void delay(uint32_t count);
* - got to 40MHz clock * - got to 40MHz clock
*/ */
void pulse(uint8_t byte);
int main(void) int main(void)
{ {
// prepare flash latency for 40MHz operation
FLASH->ACR &= ~(FLASH_ACR_LATENCY);
FLASH->ACR |= FLASH_ACR_LATENCY_2WS;
// turn on HSI // turn on HSI
RCC->CR |= RCC_CR_HSION; RCC->CR |= RCC_CR_HSION;
while ((RCC->CR & RCC_CR_HSIRDY) != RCC_CR_HSIRDY); 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 | GPIO_PUPDR_PUPD0);
GPIOA->PUPDR |= GPIO_PUPDR_PUPD5_0 | GPIO_PUPDR_PUPD0_1; // pd for button GPIOA->PUPDR |= GPIO_PUPDR_PUPD5_0 | GPIO_PUPDR_PUPD0_1; // pd for button
while (1) { pulse(*((uint8_t *)0x08080000)); // 0b00100101
while (1);/* {
delay(500); delay(500);
//if (GPIOA->IDR & 0x01) //if (GPIOA->IDR & 0x01)
GPIOA->BSRR |= 1 << 5; GPIOA->BSRR |= 1 << 5;
delay(500); delay(500);
//else //else
GPIOA->BRR |= 1 << 5; GPIOA->BRR |= 1 << 5;
} }*/
} }
void _exit(int code) void _exit(int code)
{ for (;;); } { 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);
}

Loading…
Cancel
Save