RobotHardware-UESTC/Hardware/Firmware/GeekRobotTinyFirmware v1.0/DRV/bsp_sys.c

54 lines
2.1 KiB
C
Raw Normal View History

/******************** (C) COPYRIGHT 2023 GeekRebot *****************************
* File Name : bsp_sys.c
* Current Version : V1.0 & ST 3.5.0
* Author : zhanli 719901725@qq.com
* Date of Issued : 2023.04.06 zhanli: Create
* Comments : <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
********************************************************************************/
#include "bsp_sys.h"
/**----------------------------------------------------------------------
* Function : System_Init
* Description : GeekRebot<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
* Author : zhanli&719901725@qq.com
* Date : 2023/04/22 zhanli
*---------------------------------------------------------------------**/
void System_Init(void)
{
Delay_Init(72); // <20>δ<EFBFBD>ʱ<EFBFBD>ӳ<EFBFBD>ʼ<EFBFBD><CABC>
NVIC_Config(); // <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ó<EFBFBD>ʼ<EFBFBD><CABC>
LED_GPIO_Config(); // LED<45><44>ʼ<EFBFBD><CABC>
USART1_Init(115200); // <20><><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><CABC>
IIC_Init(); // IICģ<43><C4A3><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
MOTO_GPIO_Init(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IO<49><4F><EFBFBD><EFBFBD>
MOTO_PWM_Init(3599,0); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PWMƵ<4D>ʳ<EFBFBD>ʼ<EFBFBD><CABC>20KHz
OLED_Init();
OLED_Clear();
OLED_ShowCHinese(0,0,2); // <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD> <20><>
OLED_ShowCHinese(16,0,3); // <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD> <20><>
OLED_ShowString(88,0,(u8*)"m/min",16); // OLED<45><44>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><E5B3B5> <20><>λm/min
OLED_ShowString(0, 2,(u8*)"Left : RPM",12); // <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ת R<><52>λRPM <20><>ʾÿ<CABE><C3BF><EFBFBD>ӳ<EFBFBD><D3B3>ֵ<EFBFBD>Ȧ<EFBFBD><C8A6>
OLED_ShowString(0, 3,(u8*)"Right: RPM",12); // <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ת R<><52>λRPM <20><>ʾÿ<CABE><C3BF><EFBFBD>ӳ<EFBFBD><D3B3>ֵ<EFBFBD>Ȧ<EFBFBD><C8A6>
OLED_ShowString(0, 4,(u8*)"P: I: D: ",16); // <20><>ʾPID<49><44><EFBFBD><EFBFBD>
OLED_ShowString(0, 6,(u8*)"Set_C: RPM",12); // <20><><EFBFBD><EFBFBD><EFBFBD>õij<C3B5><C4B3><EFBFBD>ת<EFBFBD>ٵ<EFBFBD>λRPM
OLED_ShowString(0, 7,(u8*)"Set_P: m/min",12); // <20><><EFBFBD><EFBFBD><EFBFBD>õij<C3B5><C4B3><EFBFBD>ת<EFBFBD>ٵ<EFBFBD>λRPM
Encoder_Init_TIM2();
TIM2 -> CNT=30000;
Encoder_Init_TIM4();
TIM4 -> CNT=30000;
MOTO_PWM_Out(100, 100);
Timer6_Init(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>6
Delay_ms(100); //<2F>ȴ<EFBFBD><C8B4><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int Moto_Left=500;
int Moto_Right=500;
TIM3->CCR3 = Moto_Left; //<2F><><EFBFBD><EFBFBD>pwm
TIM3->CCR4 = Moto_Right; //<2F><><EFBFBD><EFBFBD>pwm
}