123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334 |
- //==================================================================
- //
- // Filename: mapp_gpio.c
- // Description: System driver.
- //
- //------------------------------------------------------------------
- //
- // version:
- // date: 17:53, 05.Seb.2019, written by dwd
- // Description:
- //
- //------------------------------------------------------------------
- //==================================================================
- /*------------------------------------------------------------------------------
- * I N C L U D E
- *------------------------------------------------------------------------------*/
- #include "stm32f0xx.h"
- #include "general.h"
- #include "mapp_gpio.h"
- #include "mapp_arm.h"
- #include "mapp_msg.h"
- #include "mapp_ami.h"
- #include "main.h"
- /*------------------------------------------------------------------------------
- * D E F I N E
- *------------------------------------------------------------------------------*/
- /*--- ADC1 DMA base address ---*/
- /*------------------------------------------------------------------------------
- * S T R U C T
- *------------------------------------------------------------------------------*/
- /*------------------------------------------------------------------------------
- * S T A T I C - V A R I A B L E S
- *------------------------------------------------------------------------------*/
- /*------------------------------------------------------------------------------
- * G L O B A L
- *------------------------------------------------------------------------------*/
- /*------------------------------------------------------------------------------
- * P R O T O T Y P E
- *------------------------------------------------------------------------------*/
- /*----------------------------------------------------------------------
- // Function uses : GpioCfgInit
- // Input parameter :
- // Output parameter :
- // Use Function : Configuration all GPIOs for system.
- // Reserve date : 17:53, 05.Seb.2019, written by dwd
- ----------------------------------------------------------------------*/
- void GpioCfgInit(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- /* Enable GPIO clocks */
- RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA|RCC_AHBPeriph_GPIOB|RCC_AHBPeriph_GPIOC, ENABLE);
- RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF, ENABLE);
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
- //GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
- RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
-
-
- GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_0); //uart1——tx stm32f030C8
- GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_0);
-
- /* Configure pins as AF pushpull */
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;//TXRX GPIO_Pin_6|
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
-
- GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_1); //uart2 stm32f030C8
- GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_1);
-
- /* Configure pins as AF pushpull */
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_3;//TXRX
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
- /************PA0:VOICERSW******************/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 ;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
-
- /************PA1:mute*******/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 ;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
-
- /************PA4:HADLE KEY******************/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
- /************PA5:CHANGE KEY******************/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
-
-
-
- /************PA6.PA7:PWM******************/
-
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 ;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
- GPIO_PinAFConfig(GPIOA,GPIO_PinSource6,GPIO_AF_0);//GPIO_AF_1
-
- // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
- // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; // 设置为输出模式
- // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- // GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- // GPIO_Init(GPIOA, &GPIO_InitStructure);
- // // 设置引脚为低电平
- // GPIO_ResetBits(GPIOA, GPIO_Pin_6);
- /************PA8:BUS_IN ******************/
-
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 ;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
- /* Connect TIM pin to TIM1_CH1 */
- GPIO_PinAFConfig(GPIOA, GPIO_PinSource8, GPIO_AF_2);
-
- /************PA15:NURSE KEY******************/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
-
- /************PF7:VOIVCE SPEAK CONTROL******************/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOF,&GPIO_InitStructure);
- #if 0
- /************PB0,PB1:BUS_IN ******************/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
-
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 ;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
- /* Connect TIM pin to TIM3_CH4 */
- // GPIO_PinAFConfig(GPIOB, GPIO_PinSource1, GPIO_AF_1);
- /* Connect TIM pin to TIM14_CH1 */
- GPIO_PinAFConfig(GPIOB, GPIO_PinSource1, GPIO_AF_0);
- #endif
- /************PB3:REINFORCE KEY******************/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
- /************PB4:CANCEL KEY******************/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
- /************PB5:CALL KEY******************/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
- VOICE_PB15_ON;
-
- /************PB11:RALAY******************/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
- /************PB15:D0*****************/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15 ;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
- /************PC13:LEDY******************/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOC, &GPIO_InitStructure);
- LED_Y_OFF;
-
-
- /************Pc14:sw_spk******************/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOC, &GPIO_InitStructure);
-
- GPIO_SetBits(GPIOC, GPIO_Pin_14); //原来是用来切换二三线制,现在改为默认高电平,支持切换喇叭
-
-
- /************Pc15:GPIO_MIC_SW******************/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOC, &GPIO_InitStructure);
-
- }
- void GpioLedInit(void)
- {
-
- GPIO_InitTypeDef GPIO_InitStructure;
- /* Enable GPIO clocks */
- RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
-
-
- /************PA******************
-
- PA13---------------- KEY_LED USB_BATTER_LED
- PA14---------------- BK-LED
- ****************************************/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_14;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
- }
- /*----------------------------------------------------------------------
- // Function uses : GpioCfgReset
- // Input parameter :
- // Output parameter :
- // Use Function : Reset all IO except specified usage.
- // Reserve date : 17:53, 05.Seb.2019, written by dwd
- ----------------------------------------------------------------------*/
- void GpioCfgReset(void)
- {
- }
- void GpioSpiCSCfg(FlagStatus flag){
- if (flag == SET) {
- GPIO_SetBits(GPIOA, GPIO_Pin_1);
- } else {
- GPIO_ResetBits(GPIOA, GPIO_Pin_1);
- }
- }
- void GpioSpiSclCfg(FlagStatus flag){
- if (flag == SET) {
- GPIO_SetBits(GPIOA, GPIO_Pin_7);
- } else {
- GPIO_ResetBits(GPIOA, GPIO_Pin_7);
- }
- }
- void GpioMOSICfg(FlagStatus flag)
- {
- if (flag == SET) {
- GPIO_SetBits(GPIOA, GPIO_Pin_9);
- } else {
- GPIO_ResetBits(GPIOA, GPIO_Pin_9);
- }
- }
- /*------------------------------- E O F ----------------------------------------*/
|