| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #include "includes.h"
- void RCC_ClockInit(unsigned char enable)
- {
- RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA |
- RCC_AHBPeriph_GPIOB |
- RCC_AHBPeriph_GPIOC |
- RCC_AHBPeriph_GPIOD |
- RCC_AHBPeriph_GPIOF, enable);
- }
- void MY_NVIC_Init(void)
- {
- NVIC_InitTypeDef NVIC_InitStructure;
- //串口1
- NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
- NVIC_InitStructure.NVIC_IRQChannelPriority = 1;
- NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
- NVIC_Init(&NVIC_InitStructure);
-
- // NVIC_InitStructure.NVIC_IRQChannel = EXTI0_1_IRQn;
- // NVIC_InitStructure.NVIC_IRQChannelPriority=0;
- // NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
- // NVIC_Init(&NVIC_InitStructure);
- //
- // NVIC_InitStructure.NVIC_IRQChannel = EXTI2_3_IRQn;
- // NVIC_InitStructure.NVIC_IRQChannelPriority=1;
- // NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
- // NVIC_Init(&NVIC_InitStructure);
- }
- void AllGPIO_Init(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA |
- RCC_AHBPeriph_GPIOB |
- RCC_AHBPeriph_GPIOC |
- RCC_AHBPeriph_GPIOD |
- RCC_AHBPeriph_GPIOF, ENABLE);
-
- GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_InitStructure.GPIO_Pin = HC165_READ_PIN;
- GPIO_Init(HC165_READ_PORT, &GPIO_InitStructure);
-
-
- GPIO_InitStructure.GPIO_Mode=GPIO_Mode_OUT;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
- GPIO_InitStructure.GPIO_Pin = RS485_DIR_PIN;
- GPIO_Init(RS485_DIR_PORT, &GPIO_InitStructure);
-
-
- //LED配置
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
-
-
- // GPIO_InitStructure.GPIO_Pin = MODEM_LED1_PIN;
- // GPIO_Init(MODEM_LED1_PORT, &GPIO_InitStructure);
- // GPIO_InitStructure.GPIO_Pin = MODEM_LED2_PIN;
- // GPIO_Init(MODEM_LED2_PORT, &GPIO_InitStructure);
-
-
- //串入并出
- GPIO_InitStructure.GPIO_Pin = HC595_SCLR_PIN;
- GPIO_Init(HC595_SCLR_PORT, &GPIO_InitStructure);
- GPIO_InitStructure.GPIO_Pin = HC595_SCK_PIN;
- GPIO_Init(HC595_SCK_PORT, &GPIO_InitStructure);
- GPIO_InitStructure.GPIO_Pin = HC595_RCK_PIN;
- GPIO_Init(HC595_RCK_PORT, &GPIO_InitStructure);
- GPIO_InitStructure.GPIO_Pin = HC595_DATA_PIN;
- GPIO_Init(HC595_DATA_PORT, &GPIO_InitStructure);
-
- //并入串出
- GPIO_InitStructure.GPIO_Pin = HC165_CP_PIN;
- GPIO_Init(HC165_CP_PORT, &GPIO_InitStructure);
- GPIO_InitStructure.GPIO_Pin = HC165_PL_PIN;
- GPIO_Init(HC165_PL_PORT, &GPIO_InitStructure);
-
- GPIO_SetBits(HC595_SCLR_PORT, HC595_SCLR_PIN|HC595_SCK_PIN|HC595_DATA_PIN|HC595_RCK_PIN);
- //GPIO_ResetBits(HC595_SCLR_PORT, HC595_SCLR_PIN|HC595_SCK_PIN|HC595_DATA_PIN|HC595_RCK_PIN);
-
- }
|