📄 main.c
字号:
/****************************************************************************
* Copyright (C), 2010 安富莱电子 www.armfly.com
*
* 【本例程在安富莱STM32F103ZE-EK开发板上调试通过 】
* 【QQ: 1295744630, 旺旺:armfly, Email: armfly@qq.com 】
*
* 文件名: main.c
* 内容简述: 本例程是一个简单的手持双踪示波器(距离实用还有一定距离)
* PC0管脚采集通道1的波形,用了ADC1 和DMA1_1。
* PC1管脚采集通道2的波形,用了ADC3 和DMA2_5。
* 使用TIM1_CC2作为ADC1和ADC3的外部触发源,TIM1频率决定了ADC采样频率。
* 接线端子的DAC1的输出频率10KHz的正弦波。可以通过示波器探头去探测。
*
* 操作提示:
* TAMPER键 = 切换通道焦点。CH1或CH2
* WAKEUP键 = 显示帮助或退出帮助
* USER 键 = 暂停或实时运行
* 摇杆上键 = 放大波形垂直幅度或向上移动
* 摇杆下键 = 缩小波形垂直幅度或向下移动
* 摇杆左键 = 水平展宽波形
* 摇杆右键 = 水平缩小波形
* 摇杆OK键 = 切换摇杆调节模式。幅度或位置
*
* 注意:在运行本例程前,需要先烧写汉字库到CPU内部Flash
* 字库文件:XZKs1516.bin 字库文件大小 :267,616 ,占用 1046个扇区
* 请使用J-LINK烧写bin文件,地址填 :0x803EA00
*
* 文件历史:
* 版本号 日期 作者 说明
* v0.1 2010-03-18 armfly 创建该文件
*
*/
#include "stm32f10x.h"
#include <stdio.h>
#include "usart_printf.h"
#include "systick.h"
#include "button.h"
#include "BackLight.h"
#include "tft_lcd.h"
#include "dso.h"
/*
#include "bmp.h"
#include "wave.h"
*/
#define EXAMPLE_NAME "TFT DSO Demo"
#define EXAMPLE_DATE "2010-03-16"
#define DEMO_COUNT 89 /* Demo界面个数 */
static void InitBoard(void);
static void DispLogo(void);
/*******************************************************************************
函数名:main
输 入:
输 出:
功能说明:用户程序入口
*/
int main(void)
{
InitBoard(); /* 为了是main函数看起来更简洁些,我们将初始化的代码封装到这个函数 */
DispLogo(); /* 显示例程Logo */
DsoMain(); /* 进入DSO主程序 */
}
/*******************************************************************************
函数名:GPIO_Configuration
输 入:
输 出:
功能说明:配置7个按键为输入口线,4个LED为输出口线
按键口线分配:
USER键 : PG8 (低电平表示按下)
TAMPEER键 : PC13 (低电平表示按下)
WKUP键 : PA0 (!!!高电平表示按下)
摇杆UP键 : PG15 (低电平表示按下)
摇杆DOWN键 : PD3 (低电平表示按下)
摇杆LEFT键 : PG14 (低电平表示按下)
摇杆RIGHT键: PG13 (低电平表示按下)
摇杆SELECT键: PG7 (低电平表示按下)
LED口线分配:
LED1 : PF6 (输出0点亮)
LED2 : PF7 (输出0点亮)
LED3 : PF8 (输出0点亮)
LED4 : PF9 (输出0点亮)
*/
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* 第1步:打开GPIOA GPIOC GPIOD GPIOF GPIOG的时钟
注意:这个地方可以一次性全打开
*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC
| RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG,
ENABLE);
/* 第2步:配置所有的按键GPIO为浮动输入模式(实际上CPUf复位后就是输入状态) */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure); /* PA0 */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_Init(GPIOC, &GPIO_InitStructure); /* PC13 */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
GPIO_Init(GPIOD, &GPIO_InitStructure); /* PD3 */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_13
| GPIO_Pin_14 | GPIO_Pin_15;
GPIO_Init(GPIOG, &GPIO_InitStructure); /* PG7,8,13,14,15 */
/* 第3步:配置所有的LED指示灯GPIO为推挽输出模式 */
/* 由于将GPIO设置为输出时,GPIO输出寄存器的值缺省是0,因此会驱动LED点亮
这是我不希望的,因此在改变GPIO为输出前,先修改输出寄存器的值为1 */
GPIO_SetBits(GPIOF, GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOF, &GPIO_InitStructure);
}
/*******************************************************************************
函数名:InitBoard
输 入:
输 出:
功能说明:初始化硬件设备
*/
static void InitBoard(void)
{
/*
这个函数是ST库中的函数,函数实体在
Libraries\CMSIS\Core\CM3\system_stm32f10x.c
配置内部Flash接口,初始化PLL,配置系统频率
系统时钟缺省配置为72MHz,你如果需要更改,则需要去修改相关的头文件中的宏定义
*/
SystemInit();
/* 配置按键GPIO和LED GPIO */
GPIO_Configuration();
/* 配置串口 */
USART_Configuration();
/* 在 SysTick_Config()前,必须先调用 */
InitButtonVar();
/* 配置systic作为1ms中断,这个函数在
\Libraries\CMSIS\Core\CM3\core_cm3.h */
SysTick_Config(SystemFrequency / 1000);
/* 通过串口输出例程名和更新日期 */
PrintfLogo(EXAMPLE_NAME, EXAMPLE_DATE);
}
/*******************************************************************************
函数名: DispLogo
输 入:
输 出:
功能说明:显示例程Logo (通过串口打印到PC机的超级终端显示)
*/
static void DispLogo(void)
{
/* 通过串口输出例程名和更新日期 */
PrintfLogo(EXAMPLE_NAME, EXAMPLE_DATE);
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
/**
* @}
*/
/**
* @}
*/
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -