Skip to content

Commit

Permalink
UART: shut down interrupt before jumping to user code
Browse files Browse the repository at this point in the history
  • Loading branch information
triffid committed Mar 6, 2013
1 parent 86f8cc3 commit 4e9091b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,13 @@ int main()

while (UART_busy());
printf("Jump!\n");
while (UART_busy());
UART_deinit();

new_execute_user_code();

UART_init(UART_RX, UART_TX, 2000000);

printf("This should never happen\n");

while (UART_busy());
Expand Down
18 changes: 18 additions & 0 deletions uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,24 @@ int UART_baud(int baud)
return baud;
}

void UART_deinit() {
switch(port)
{
case 0:
NVIC_DisableIRQ(UART0_IRQn);
break;
case 1:
NVIC_DisableIRQ(UART1_IRQn);
break;
case 2:
NVIC_DisableIRQ(UART2_IRQn);
break;
case 3:
NVIC_DisableIRQ(UART3_IRQn);
break;
}
}

uint32_t UART_send(const uint8_t *data, uint32_t buflen) {
uint32_t bytes = 0;

Expand Down
1 change: 1 addition & 0 deletions uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ typedef struct

// UART_init(PinName rxpin, PinName txpin);
void UART_init(PinName rxpin, PinName txpin, int baud);
void UART_deinit();
void UART_pin_init(PinName rxpin, PinName txpin);
int UART_baud(int baud);
uint32_t UART_send(const uint8_t *buf, uint32_t buflen);
Expand Down

0 comments on commit 4e9091b

Please sign in to comment.