oscilloscope/User/board.c

161 lines
3.9 KiB
C
Raw Normal View History

2020-10-29 08:46:25 +08:00
/*
*************************************************************************
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD>
*************************************************************************
*/
/* STM32 <20>̼<EFBFBD><CCBC><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> */
#include "stm32f10x.h"
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2>bspͷ<70>ļ<EFBFBD> */
#include "board.h"
#include "bsp_ili9341_lcd.h"
#include "bsp_adc.h"
2020-12-19 09:26:30 +08:00
#include "delay.h"
2020-10-29 08:46:25 +08:00
#include "bsp_led.h"
#include "bsp_usart.h"
#include "bsp_key_exti.h"
#include "bsp_PS2.h"
2020-11-26 23:15:56 +08:00
#include "OSC.h"
2020-10-29 08:46:25 +08:00
/* RT-Thread<61><64><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> */
#include <rthw.h>
#include <rtthread.h>
#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
#define RT_HEAP_SIZE 1024
/* <20><><EFBFBD>ڲ<EFBFBD>SRAM<41><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>־<EFBFBD>̬<EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>Ϊrtt<74>Ķѿռ<D5BC><E4A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ4KB */
static uint32_t rt_heap[RT_HEAP_SIZE];
RT_WEAK void *rt_heap_begin_get(void)
{
return rt_heap;
}
RT_WEAK void *rt_heap_end_get(void)
{
return rt_heap + RT_HEAP_SIZE;
}
#endif
/**
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param <EFBFBD><EFBFBD>
* @retval <EFBFBD><EFBFBD>
*
* @attention
* RTT<EFBFBD>ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>صij<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳһ<EFBFBD>ŵ<EFBFBD>board.c<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>֣<EFBFBD>
* <EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳһ<EFBFBD>ŵ<EFBFBD>main.c<EFBFBD>ļ<EFBFBD>Ҳ<EFBFBD>ǿ<EFBFBD><EFBFBD>Եġ<EFBFBD>
*/
void rt_hw_board_init()
{
/* <20><>ʼ<EFBFBD><CABC>SysTick */
SysTick_Config( SystemCoreClock / RT_TICK_PER_SECOND );
2020-12-19 09:26:30 +08:00
2020-10-29 08:46:25 +08:00
/* Ӳ<><D3B2>BSP<53><50>ʼ<EFBFBD><CABC>ͳͳ<CDB3><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFA3AC><EFBFBD><EFBFBD>LED<45><44><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>LCD<43><44> */
ILI9341_Init ();//LCD <20><>ʼ<EFBFBD><CABC>
LED_GPIO_Config();
USART_Config();
ADCx_Init();
2020-11-03 23:31:18 +08:00
EXTI_Key_Config();
2020-10-29 08:46:25 +08:00
PS2_Key_Config();
//<2F><><EFBFBD><EFBFBD>0<EFBFBD><30>3<EFBFBD><33>5<EFBFBD><35>6 ģʽ<C4A3>ʺϴ<CABA><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>֣<EFBFBD>
//<2F><><EFBFBD>Ƽ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>ʾ<EFBFBD><CABE><EFBFBD>ֻ<EFBFBD><D6BB>о<EFBFBD><D0BE><EFBFBD>Ч<EFBFBD><D0A7>
//<2F><><EFBFBD><EFBFBD> 6 ģʽΪ<CABD>󲿷<EFBFBD>Һ<EFBFBD><D2BA><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
ILI9341_GramScan ( 3 );
LCD_SetColors(WHITE, BLACK);
ILI9341_Clear(0,0,LCD_X_LENGTH,LCD_Y_LENGTH);
2020-11-26 23:15:56 +08:00
2020-12-13 22:16:54 +08:00
//<2F><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
PlotBlackground();
2020-11-26 23:15:56 +08:00
char dispBuff[100];
uint8_t StartPos_X=10, StartPos_Y=7, Div=50;
ILI9341_Clear(0, 0, 320, 30);
2020-11-26 23:15:56 +08:00
sprintf(dispBuff,"%.1fkHz", CurWaveFrq);
ILI9341_DispString_EN(Div*0+StartPos_X, StartPos_Y, dispBuff);
2020-12-14 23:46:15 +08:00
/*ʹ<><CAB9>c<EFBFBD><63>׼<EFBFBD><D7BC><EFBFBD>ѱ<EFBFBD><D1B1><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>*/
sprintf(dispBuff,"%.1fV", CurTriggerValue);
ILI9341_DispString_EN(Div*1+StartPos_X+10, StartPos_Y, dispBuff);
ILI9341_DispString_EN(Div*2+StartPos_X+15, StartPos_Y, CurTriggerMode);
ILI9341_DispString_EN(Div*3+StartPos_X, StartPos_Y, CurSamplingMode);
sprintf(dispBuff,"%dms", CurTimePerDiv);
ILI9341_DispString_EN(Div*4+StartPos_X, StartPos_Y, dispBuff);
ILI9341_DispString_EN(Div*5+StartPos_X, StartPos_Y, CurSamplStatus);
2020-12-14 23:46:15 +08:00
2020-10-29 08:46:25 +08:00
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (use INIT_BOARD_EXPORT()) */
#ifdef RT_USING_COMPONENTS_INIT
rt_components_board_init();
#endif
#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#endif
#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
rt_system_heap_init(rt_heap_begin_get(), rt_heap_end_get());
#endif
}
/**
* @brief SysTick<EFBFBD>жϷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param <EFBFBD><EFBFBD>
* @retval <EFBFBD><EFBFBD>
*
* @attention
* SysTick<EFBFBD>жϷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڹ̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>stm32f10x_it.c<EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD>board.c<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>Σ<EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD>󣬽<EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><EFBFBD>԰<EFBFBD>stm32f10x_it.c<EFBFBD>е<EFBFBD>ע<EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɡ<EFBFBD>
*/
void SysTick_Handler(void)
{
/* <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD> */
rt_interrupt_enter();
/* <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> */
rt_tick_increase();
/* <20><EFBFBD>ж<EFBFBD> */
rt_interrupt_leave();
}
/**
* @brief <EFBFBD><EFBFBD>ӳ<EFBFBD><EFBFBD><EFBFBD>DEBUG_USARTx<EFBFBD><EFBFBD>rt_kprintf()<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* Note<EFBFBD><EFBFBD>DEBUG_USARTx<EFBFBD><EFBFBD><EFBFBD><EFBFBD>bsp_usart.h<EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺĬ<EFBFBD><EFBFBD>ʹ<EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD>1
* @param str<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
* @retval <EFBFBD><EFBFBD>
*
* @attention
*
*/
void rt_hw_console_output(const char *str)
{
/* <20><><EFBFBD><EFBFBD><EFBFBD>ٽ<EFBFBD><D9BD><EFBFBD> */
rt_enter_critical();
/* ֱ<><D6B1><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
while (*str!='\0')
{
/* <20><><EFBFBD><EFBFBD> */
if (*str=='\n')
{
USART_SendData(DEBUG_USARTx, '\r');
while (USART_GetFlagStatus(DEBUG_USARTx, USART_FLAG_TXE) == RESET);
}
USART_SendData(DEBUG_USARTx, *str++);
while (USART_GetFlagStatus(DEBUG_USARTx, USART_FLAG_TXE) == RESET);
}
/* <20>˳<EFBFBD><CBB3>ٽ<EFBFBD><D9BD><EFBFBD> */
rt_exit_critical();
}