forked from xuos/xiuos
move UartConfig function to common.c
This commit is contained in:
parent
bbb8dd75f8
commit
a9deff5cd0
|
@ -22,6 +22,32 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
static uint32_t UartSrcFreq(void)
|
||||||
|
{
|
||||||
|
uint32_t freq;
|
||||||
|
|
||||||
|
if (CLOCK_GetMux(kCLOCK_UartMux) == 0){
|
||||||
|
freq = (CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6U) / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U);
|
||||||
|
} else {
|
||||||
|
freq = CLOCK_GetOscFreq() / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U);
|
||||||
|
}
|
||||||
|
|
||||||
|
return freq;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UartConfig(void)
|
||||||
|
{
|
||||||
|
lpuart_config_t config;
|
||||||
|
LPUART_GetDefaultConfig(&config);
|
||||||
|
config.baudRate_Bps = 115200u;
|
||||||
|
config.enableTx = true;
|
||||||
|
config.enableRx = true;
|
||||||
|
|
||||||
|
LPUART_Init(LPUART1, &config, UartSrcFreq());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Convert an Integer to a string
|
* @brief Convert an Integer to a string
|
||||||
* @param str: The string
|
* @param str: The string
|
||||||
|
|
|
@ -23,32 +23,6 @@
|
||||||
#ifdef MCUBOOT_BOOTLOADER
|
#ifdef MCUBOOT_BOOTLOADER
|
||||||
extern void ImxrtMsDelay(uint32 ms);
|
extern void ImxrtMsDelay(uint32 ms);
|
||||||
|
|
||||||
static uint32_t UartSrcFreq(void)
|
|
||||||
{
|
|
||||||
uint32_t freq;
|
|
||||||
|
|
||||||
/* To make it simple, we assume default PLL and divider settings, and the only variable
|
|
||||||
from application is use PLL3 source or OSC source */
|
|
||||||
if (CLOCK_GetMux(kCLOCK_UartMux) == 0) /* PLL3 div6 80M */ {
|
|
||||||
freq = (CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6U) / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U);
|
|
||||||
} else {
|
|
||||||
freq = CLOCK_GetOscFreq() / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U);
|
|
||||||
}
|
|
||||||
|
|
||||||
return freq;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void UartConfig(void)
|
|
||||||
{
|
|
||||||
lpuart_config_t config;
|
|
||||||
LPUART_GetDefaultConfig(&config);
|
|
||||||
config.baudRate_Bps = 115200u;
|
|
||||||
config.enableTx = true;
|
|
||||||
config.enableRx = true;
|
|
||||||
|
|
||||||
LPUART_Init(LPUART1, &config, UartSrcFreq());
|
|
||||||
}
|
|
||||||
|
|
||||||
static void jump_to_application(void)
|
static void jump_to_application(void)
|
||||||
{
|
{
|
||||||
SCB->VTOR = (uint32_t)XIUOS_FLAH_ADDRESS;
|
SCB->VTOR = (uint32_t)XIUOS_FLAH_ADDRESS;
|
||||||
|
@ -62,6 +36,7 @@ static void jump_to_application(void)
|
||||||
asm volatile("BX R0");
|
asm volatile("BX R0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BootLoaderJumpApp(void)
|
void BootLoaderJumpApp(void)
|
||||||
{
|
{
|
||||||
uint8_t ch1, ch2;
|
uint8_t ch1, ch2;
|
||||||
|
|
|
@ -19,12 +19,10 @@
|
||||||
* @date: 2023/3/24
|
* @date: 2023/3/24
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
#include "ymodem.h"
|
#include "ymodem.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
|
|
||||||
|
|
||||||
uint8_t tab_1024[1024] ={0};
|
uint8_t tab_1024[1024] ={0};
|
||||||
uint8_t FileName[FILE_NAME_LENGTH];
|
uint8_t FileName[FILE_NAME_LENGTH];
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#define CONVERTHEX_alpha(c) (IS_AF(c) ? (c - 'A'+10) : (c - 'a'+10))
|
#define CONVERTHEX_alpha(c) (IS_AF(c) ? (c - 'A'+10) : (c - 'a'+10))
|
||||||
#define CONVERTHEX(c) (IS_09(c) ? (c - '0') : CONVERTHEX_alpha(c))
|
#define CONVERTHEX(c) (IS_09(c) ? (c - '0') : CONVERTHEX_alpha(c))
|
||||||
|
|
||||||
|
void UartConfig(void);
|
||||||
void Int2Str(uint8_t* str,int32_t intnum);
|
void Int2Str(uint8_t* str,int32_t intnum);
|
||||||
uint32_t Str2Int(uint8_t *inputstr,int32_t *intnum);
|
uint32_t Str2Int(uint8_t *inputstr,int32_t *intnum);
|
||||||
uint32_t GetIntegerInput(int32_t * num);
|
uint32_t GetIntegerInput(int32_t * num);
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#define _YMODEM_H_
|
#define _YMODEM_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
#define USER_FLASH_SIZE 0x100000 //Application package size is limited to 1M
|
#define USER_FLASH_SIZE 0x100000 //Application package size is limited to 1M
|
||||||
#define PACKET_SEQNO_INDEX (1)
|
#define PACKET_SEQNO_INDEX (1)
|
||||||
|
|
Loading…
Reference in New Issue