Skip to content

Commit

Permalink
feat: (make isp) automatical jump to built-in bootloader without powe…
Browse files Browse the repository at this point in the history
…r off and config BOOT option
  • Loading branch information
but0n committed Jun 10, 2017
1 parent 32c3be3 commit 182dee7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 46 deletions.
18 changes: 0 additions & 18 deletions libs/include/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,5 @@ extern void jump2ISP();
} while(0)
#define UART_CLEAR() uart_sendStr("\033[H\033[J")

#define CMD_MAX_LENGTH 32
#define pop gCmdCache[top--]
#define push(s) gCmdCache[++top] = s
#define clrCache() {\
while (top > -1) {\
pop = '\0';\
}\
}
#define STACK_OVERFLOW (top == CMD_MAX_LENGTH - 1)

// decode
#define TOKEN_START '$'
#define TOKEN_SEND 'S'
#define TOKEN_LEARN 'L'
#define TOKEN_OFFSET 0x01
#define CMD_NUM_MAX '8'
#define CMD_NUM_MIN '1'
#define ISLEGAL_NUM(k) (((k) >= CMD_NUM_MIN) && ((k) <= CMD_NUM_MAX))

#endif
31 changes: 3 additions & 28 deletions libs/source/uart.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#include "uart.h"
#include "stm32f10x.h"
#include "MPU6050.h"
SixAxis data;

int top = -1; //Stack Pointer
char gCmdCache[CMD_MAX_LENGTH];
#include "uart.h"


void uart_init(unsigned int pclk2, unsigned int bound) {
Expand Down Expand Up @@ -34,40 +29,20 @@ void uart_init(unsigned int pclk2, unsigned int bound) {

USART1->SR; //Read Reg SR to Clean TXE and TE,(Reset value: 0x00C0)



NVIC_EnableIRQ(USART1_IRQn);
NVIC_SetPriority(USART1_IRQn, 3);

}

void USART1_IRQHandler(void) {
if(USART1->SR & USART_SR_RXNE) {
const char cmd = USART1->DR; // 读取串口接收寄存器来清除 RXNE 标志
const char cmd = USART1->DR;
switch (cmd) {
case TOKEN_START: //$ - 命令起始标志
MPU6050_getStructData(&data);
IMU_Comput(data);

// MPU6050_debug(&data);
// UART_CR();

// uart_sendStr("Pitch: ");
uart_Float2Char(g_Pitch);
uart_sendStr("@");
// uart_sendStr("\tRoll: ");
uart_Float2Char(g_Roll);
uart_sendStr("@");

// uart_sendStr("\tYaw: ");
uart_Float2Char(g_Yaw);
uart_sendStr("\n\r");
break;
case '>': // Jump to bootloader
uart_sendStr("Running bootloader...");
jump2ISP();
// NOTE: running bootloader
default: //其它按键
default:
break;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "stm32f10x.h"
#include "uart.h"

#define NVIC_GROUPING 3

Expand Down

0 comments on commit 182dee7

Please sign in to comment.