Skip to content

Commit

Permalink
Merge pull request #1 from sj15712795029/master
Browse files Browse the repository at this point in the history
sync
  • Loading branch information
ryze-wang committed Sep 8, 2020
2 parents a499b7b + 21edf95 commit 3e212e5
Show file tree
Hide file tree
Showing 108 changed files with 32,448 additions and 482 deletions.
9 changes: 5 additions & 4 deletions board/board_wrapper.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#ifndef BOARD_WRAPPER_H_H_H
#define BOARD_WRAPPER_H_H_H

#include "hw_misc.h"
#include "hw_uart.h"
#include "hw_systick.h"
#include "hw_sdio.h"
#include "hw_led.h"
#include "hw_oled.h"
#include "hw_button.h"
#include "hw_misc.h"
#include "hw_oled.h"
#include "hw_sht2x.h"
#include "hw_spi_flash.h"
#include "hw_ov7670.h"
//#include "usb_lib.h"
#include "usb_lib.h"
#include "fs_wrapper.h"

#endif
55 changes: 11 additions & 44 deletions board/stm32f10x/hw_button.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,65 +12,32 @@
* func name : hw_button_init
* para : NULL
* return : button init result
* description : button init,KEY1->PB1 KEY2->PB0 KEY3->PC5 KEY4->PC4
* description : button init,KEY->PC4
******************************************************************************/
uint8_t hw_button_init()
{
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO,ENABLE);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOB, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4|GPIO_Pin_5;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOC, &GPIO_InitStructure);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);

/* KEY1->PB1 */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB,GPIO_PinSource1);
EXTI_InitStructure.EXTI_Line=EXTI_Line1;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = KEY1_PREE_PRIO;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = KEY1_SUB_PRIO;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);

/* KEY2->PB0 */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB,GPIO_PinSource0);
EXTI_InitStructure.EXTI_Line=EXTI_Line0;
EXTI_Init(&EXTI_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = KEY2_PREE_PRIO;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = KEY2_SUB_PRIO;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);

/* KEY3->PC5 */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOC,GPIO_PinSource5);
EXTI_InitStructure.EXTI_Line=EXTI_Line5;
EXTI_Init(&EXTI_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = KEY3_PREE_PRIO;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = KEY3_SUB_PRIO;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);

/* KEY4->PC4 */
/* KEY->PC4 */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOC,GPIO_PinSource4);
EXTI_InitStructure.EXTI_Line=EXTI_Line4;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);

NVIC_InitStructure.NVIC_IRQChannel = EXTI4_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = KEY4_PREE_PRIO;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = KEY4_SUB_PRIO;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 4;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);

Expand Down
25 changes: 1 addition & 24 deletions board/stm32f10x/hw_exti.c
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@
#include "hw_misc.h"
#include "hw_ov7670.h"

void EXTI1_IRQHandler(void)
{
hw_delay_ms(10);
if(GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_1) == 0)
{
/* USER CODE */
HW_DEBUG("BUTTON KEY 1\n");
}
EXTI_ClearITPendingBit(EXTI_Line1);
}

void EXTI0_IRQHandler(void)
{
hw_delay_ms(10);
if(GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_0) == 0)
{
/* USER CODE */
HW_DEBUG("BUTTON KEY 2\n");
}
EXTI_ClearITPendingBit(EXTI_Line0);
}


void EXTI4_IRQHandler(void)
Expand All @@ -30,7 +7,7 @@ void EXTI4_IRQHandler(void)
if(GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_4) == 0)
{
/* USER CODE */
HW_DEBUG("BUTTON KEY 4\n");
HW_DEBUG("BUTTON KEY \n");
}
EXTI_ClearITPendingBit(EXTI_Line4);
}
15 changes: 12 additions & 3 deletions board/stm32f10x/hw_led.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,21 @@ uint8_t hw_led_init()
{
GPIO_InitTypeDef GPIO_InitStructure;

RCC_APB2PeriphClockCmd(LED_PERIPH_CLK, ENABLE);
RCC_APB2PeriphClockCmd(LED1_PERIPH_CLK, ENABLE);

GPIO_InitStructure.GPIO_Pin = LED_PIN;
GPIO_InitStructure.GPIO_Pin = LED1_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(LED_GPIO, &GPIO_InitStructure);
GPIO_Init(LED1_GPIO, &GPIO_InitStructure);

RCC_APB2PeriphClockCmd(LED2_PERIPH_CLK, ENABLE);

GPIO_InitStructure.GPIO_Pin = LED2_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(LED2_GPIO, &GPIO_InitStructure);

LED1_OFF;
LED2_OFF;
return HW_ERR_OK;
}
17 changes: 12 additions & 5 deletions board/stm32f10x/hw_led.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,21 @@

#include "hw_misc.h"

#define LED_PERIPH_CLK RCC_APB2Periph_GPIOA
#define LED_GPIO GPIOA
#define LED_PIN GPIO_Pin_2
#define LED1_PERIPH_CLK RCC_APB2Periph_GPIOB
#define LED1_GPIO GPIOB
#define LED1_PIN GPIO_Pin_0

#define LED2_PERIPH_CLK RCC_APB2Periph_GPIOB
#define LED2_GPIO GPIOB
#define LED2_PIN GPIO_Pin_1


/* Operate LED on/off */
#define LED_ON GPIO_WriteBit(LED_GPIO, LED_PIN, Bit_SET)
#define LED_OFF GPIO_WriteBit(LED_GPIO, LED_PIN, Bit_RESET)
#define LED1_OFF GPIO_WriteBit(LED1_GPIO, LED1_PIN, Bit_SET)
#define LED1_ON GPIO_WriteBit(LED1_GPIO, LED1_PIN, Bit_RESET)

#define LED2_OFF GPIO_WriteBit(LED2_GPIO, LED2_PIN, Bit_SET)
#define LED2_ON GPIO_WriteBit(LED2_GPIO, LED2_PIN, Bit_RESET)

uint8_t hw_led_init(void);

Expand Down
2 changes: 2 additions & 0 deletions board/stm32f10x/hw_misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ typedef enum

HW_ERR_SHELL_NO_CMD,
HW_ERR_SHELL_INVALID_PARA,

HW_ERR_FS_INIT,

/* OLED err */
HW_ERR_OLED_INVALID_DIRECT,
Expand Down
4 changes: 3 additions & 1 deletion board/stm32f10x/hw_oled.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,9 @@ uint8_t hw_oled_draw_bmp(uint8_t col_start,uint8_t page_start,uint8_t col_end,ui
uint8_t hw_oled_init()
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(SSD1306_PERIPH_CLK, ENABLE);

RCC_APB2PeriphClockCmd(SSD1306_PERIPH_CLK | RCC_APB2Periph_AFIO, ENABLE);
GPIO_PinRemapConfig(GPIO_Remap_SWJ_NoJTRST,ENABLE);
GPIO_InitStructure.GPIO_Pin = SSD1306_SCL_PIN|SSD1306_SDA_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
Expand Down
Loading

0 comments on commit 3e212e5

Please sign in to comment.