mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-02 08:40:33 +08:00
剔除多余空行格式化文件
This commit is contained in:
1 parent
74d045093b
commit
a716028850
15 files changed
+272
-472
No files matched your search
@@ -15,6 +15,6 @@
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* user app entry */
|
||||
return 0;
|
||||
/* user app entry */
|
||||
return 0;
|
||||
}
|
||||
@@ -24,12 +24,9 @@
|
||||
|
||||
/*@{*/
|
||||
|
||||
|
||||
void HAL_MspInit(void)
|
||||
{
|
||||
|
||||
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
|
||||
|
||||
/* System interrupt init*/
|
||||
__HAL_RCC_AFIO_CLK_ENABLE();
|
||||
/* MemoryManagement_IRQn interrupt configuration */
|
||||
@@ -46,16 +43,14 @@ void HAL_MspInit(void)
|
||||
HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0);
|
||||
/* SysTick_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(SysTick_IRQn, 15, 0);
|
||||
|
||||
/**DISABLE: JTAG-DP Disabled and SW-DP Disabled**/
|
||||
__HAL_AFIO_REMAP_SWJ_NOJTAG();
|
||||
}
|
||||
|
||||
void SystemClock_Config(void)
|
||||
{
|
||||
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct;
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
||||
|
||||
/**Initializes the CPU, AHB and APB busses clocks
|
||||
*/
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
||||
@@ -73,22 +68,17 @@ void SystemClock_Config(void)
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
||||
|
||||
RT_ASSERT(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) == HAL_OK);
|
||||
|
||||
/**Configure the Systick interrupt time
|
||||
*/
|
||||
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / RT_TICK_PER_SECOND);
|
||||
|
||||
/**Configure the Systick
|
||||
*/
|
||||
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
|
||||
|
||||
/* SysTick_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(SysTick_IRQn, 15, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is the timer interrupt service routine.
|
||||
*
|
||||
@@ -97,10 +87,8 @@ void SysTick_Handler(void)
|
||||
{
|
||||
/* enter interrupt */
|
||||
rt_interrupt_enter();
|
||||
|
||||
HAL_IncTick();
|
||||
rt_tick_increase();
|
||||
|
||||
/* leave interrupt */
|
||||
rt_interrupt_leave();
|
||||
}
|
||||
@@ -115,15 +103,10 @@ void rt_hw_board_init(void)
|
||||
#ifdef RT_USING_HEAP
|
||||
rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
rt_components_board_init();
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_CONSOLE
|
||||
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
@@ -197,7 +197,6 @@
|
||||
#define STM32_SRAM_SIZE 64
|
||||
//#define STM32F107xC
|
||||
#endif
|
||||
|
||||
/* whether use board external SRAM memory */
|
||||
// <e>Use external SRAM memory on the board
|
||||
// <i>Enable External SRAM memory
|
||||
@@ -209,10 +208,8 @@
|
||||
// <i>Default: 0x68080000
|
||||
#define STM32_EXT_SRAM_END 0x68080000 /* the end address of external SRAM */
|
||||
// </e>
|
||||
|
||||
// <o> Internal SRAM memory size[Kbytes] <8-64>
|
||||
// <i>Default: 64
|
||||
|
||||
#define STM32_SRAM_END (0x20000000 + STM32_SRAM_SIZE * 1024)
|
||||
#ifdef __CC_ARM
|
||||
extern int Image$$RW_IRAM1$$ZI$$Limit;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -14,18 +14,12 @@
|
||||
*/
|
||||
#ifndef GPIO_H__
|
||||
#define GPIO_H__
|
||||
|
||||
|
||||
struct stm32_hw_pin_userdata
|
||||
{
|
||||
int pin;
|
||||
uint32_t mode;
|
||||
};
|
||||
|
||||
#define PIN_USERDATA_END {-1,0}
|
||||
|
||||
extern struct stm32_hw_pin_userdata stm32_pins[];
|
||||
|
||||
int rt_hw_pin_init(void);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -22,9 +22,9 @@
|
||||
* 2018-01-13 Liu2guang the first version.
|
||||
*/
|
||||
|
||||
#ifndef __DRV_SDCARD_H_
|
||||
#define __DRV_SDCARD_H_
|
||||
#ifndef __DRV_SDCARD_H_
|
||||
#define __DRV_SDCARD_H_
|
||||
|
||||
int rt_hw_sdcard_init(void);
|
||||
int rt_hw_sdcard_init(void);
|
||||
|
||||
#endif
|
||||
@@ -16,30 +16,25 @@
|
||||
#include <board.h>
|
||||
#include <drv_spi.h>
|
||||
#ifdef RT_USING_SPI
|
||||
|
||||
#define SPIRXEVENT 0x01
|
||||
#define SPITXEVENT 0x02
|
||||
#define SPITIMEOUT 2
|
||||
#define SPICRCEN 0
|
||||
|
||||
struct stm32_hw_spi_cs
|
||||
{
|
||||
rt_uint32_t pin;
|
||||
};
|
||||
|
||||
|
||||
struct stm32_spi
|
||||
{
|
||||
SPI_TypeDef *Instance;
|
||||
struct rt_spi_configuration *cfg;
|
||||
};
|
||||
|
||||
|
||||
static rt_err_t stm32_spi_init(SPI_TypeDef *spix, struct rt_spi_configuration *cfg)
|
||||
{
|
||||
SPI_HandleTypeDef hspi;
|
||||
hspi.Instance = spix;
|
||||
|
||||
if (cfg->mode & RT_SPI_SLAVE)
|
||||
{
|
||||
hspi.Init.Mode = SPI_MODE_SLAVE;
|
||||
@@ -145,6 +140,7 @@ static rt_err_t stm32_spi_init(SPI_TypeDef *spix, struct rt_spi_configuration *c
|
||||
__HAL_SPI_ENABLE(&hspi);
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
#define SPISTEP(datalen) (((datalen) == 8) ? 1 : 2)
|
||||
#define SPISEND_1(reg, ptr, datalen) \
|
||||
do \
|
||||
@@ -195,6 +191,7 @@ static rt_err_t spitxrx1b(struct stm32_spi *hspi, void *rcvb, const void *sndb)
|
||||
SPIRECV_1(hspi->Instance->DR, rcvb, hspi->cfg->data_width);
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *message)
|
||||
{
|
||||
rt_err_t res;
|
||||
@@ -203,7 +200,6 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
|
||||
RT_ASSERT(device->bus->parent.user_data != RT_NULL);
|
||||
struct stm32_spi *hspi = (struct stm32_spi *)device->bus->parent.user_data;
|
||||
struct stm32_hw_spi_cs *cs = device->parent.user_data;
|
||||
|
||||
if (message->cs_take)
|
||||
{
|
||||
rt_pin_write(cs->pin, 0);
|
||||
@@ -238,7 +234,6 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
|
||||
return message->length - length;
|
||||
}
|
||||
|
||||
|
||||
rt_err_t spi_configure(struct rt_spi_device *device,
|
||||
struct rt_spi_configuration *configuration)
|
||||
{
|
||||
@@ -378,34 +373,3 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef *spiHandle)
|
||||
}
|
||||
}
|
||||
#endif /*RT_USING_SPI*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -18,21 +18,7 @@
|
||||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
|
||||
|
||||
extern int stm32_spi_register_bus(SPI_TypeDef * SPIx,const char * name);
|
||||
extern rt_err_t stm32_spi_bus_attach_device(rt_uint32_t pin,const char * bus_name,const char * device_name);
|
||||
extern int stm32_spi_register_bus(SPI_TypeDef *SPIx, const char *name);
|
||||
extern rt_err_t stm32_spi_bus_attach_device(rt_uint32_t pin, const char *bus_name, const char *device_name);
|
||||
extern int stm32_hw_spi_init(void);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -11,12 +11,9 @@
|
||||
* Date Author Notes
|
||||
* 2009-01-05 Bernard the first version
|
||||
*/
|
||||
|
||||
#ifndef __USART_H__
|
||||
#define __USART_H__
|
||||
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
int rt_hw_usart_init(void);
|
||||
|
||||
#endif
|
||||
@@ -16,9 +16,7 @@
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include "board.h"
|
||||
|
||||
#define USB_DISCONNECT_PIN 30 //PA9
|
||||
|
||||
#define USB_DISCONNECT_PIN 30 //PA9
|
||||
static PCD_HandleTypeDef _stm_pcd;
|
||||
static struct udcd _stm_udc;
|
||||
static struct ep_id _ep_pool[] =
|
||||
@@ -35,9 +33,7 @@ static struct ep_id _ep_pool[] =
|
||||
void USB_LP_CAN1_RX0_IRQHandler(void)
|
||||
{
|
||||
rt_interrupt_enter();
|
||||
|
||||
HAL_PCD_IRQHandler(&_stm_pcd);
|
||||
|
||||
rt_interrupt_leave();
|
||||
}
|
||||
|
||||
@@ -51,10 +47,9 @@ void HAL_PCD_ResetCallback(PCD_HandleTypeDef *pcd)
|
||||
|
||||
void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd)
|
||||
{
|
||||
rt_usbd_ep0_setup_handler(&_stm_udc, (struct urequest*)hpcd->Setup);
|
||||
rt_usbd_ep0_setup_handler(&_stm_udc, (struct urequest *)hpcd->Setup);
|
||||
}
|
||||
|
||||
|
||||
void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
|
||||
{
|
||||
if (epnum == 0)
|
||||
@@ -63,7 +58,7 @@ void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_usbd_ep_in_handler(&_stm_udc, 0x80|epnum,hpcd->IN_ep[epnum].xfer_count);
|
||||
rt_usbd_ep_in_handler(&_stm_udc, 0x80 | epnum, hpcd->IN_ep[epnum].xfer_count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,46 +85,43 @@ void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_usbd_ep0_out_handler(&_stm_udc,hpcd->OUT_ep[0].xfer_count);
|
||||
rt_usbd_ep0_out_handler(&_stm_udc, hpcd->OUT_ep[0].xfer_count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state)
|
||||
{
|
||||
if(state == 1)
|
||||
if (state == 1)
|
||||
{
|
||||
rt_pin_write(USB_DISCONNECT_PIN,PIN_HIGH);
|
||||
rt_pin_write(USB_DISCONNECT_PIN, PIN_HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_pin_write(USB_DISCONNECT_PIN,PIN_LOW);
|
||||
}
|
||||
rt_pin_write(USB_DISCONNECT_PIN, PIN_LOW);
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
|
||||
void HAL_PCD_MspInit(PCD_HandleTypeDef *pcdHandle)
|
||||
{
|
||||
if(pcdHandle->Instance==USB)
|
||||
if (pcdHandle->Instance == USB)
|
||||
{
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
rt_pin_mode(USB_DISCONNECT_PIN,PIN_MODE_OUTPUT);
|
||||
rt_pin_write(USB_DISCONNECT_PIN,PIN_LOW);
|
||||
rt_pin_mode(USB_DISCONNECT_PIN, PIN_MODE_OUTPUT);
|
||||
rt_pin_write(USB_DISCONNECT_PIN, PIN_LOW);
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_USB_CLK_ENABLE();
|
||||
|
||||
/* Peripheral interrupt init */
|
||||
HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 5, 0);
|
||||
HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn);
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle)
|
||||
void HAL_PCD_MspDeInit(PCD_HandleTypeDef *pcdHandle)
|
||||
{
|
||||
if(pcdHandle->Instance==USB)
|
||||
if (pcdHandle->Instance == USB)
|
||||
{
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_USB_CLK_DISABLE();
|
||||
|
||||
/* Peripheral interrupt Deinit*/
|
||||
HAL_NVIC_DisableIRQ(USB_LP_CAN1_RX0_IRQn);
|
||||
}
|
||||
@@ -143,7 +135,7 @@ static rt_err_t _ep_set_stall(rt_uint8_t address)
|
||||
|
||||
static rt_err_t _ep_clear_stall(rt_uint8_t address)
|
||||
{
|
||||
HAL_PCD_EP_ClrStall(&_stm_pcd, address);
|
||||
HAL_PCD_EP_ClrStall(&_stm_pcd, address);
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
@@ -164,7 +156,6 @@ static rt_err_t _ep_enable(uep_t ep)
|
||||
RT_ASSERT(ep->ep_desc != RT_NULL);
|
||||
HAL_PCD_EP_Open(&_stm_pcd, ep->ep_desc->bEndpointAddress,
|
||||
ep->ep_desc->wMaxPacketSize, ep->ep_desc->bmAttributes);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
@@ -196,7 +187,7 @@ static rt_size_t _ep_write(rt_uint8_t address, void *buffer, rt_size_t size)
|
||||
}
|
||||
|
||||
static rt_err_t _ep0_send_status(void)
|
||||
{
|
||||
{
|
||||
HAL_PCD_EP_Transmit(&_stm_pcd, 0x00, NULL, 0);
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -214,10 +205,8 @@ static rt_err_t _wakeup(void)
|
||||
static rt_err_t _init(rt_device_t device)
|
||||
{
|
||||
PCD_HandleTypeDef *pcd;
|
||||
|
||||
/* Set LL Driver parameters */
|
||||
pcd = (PCD_HandleTypeDef*)device->user_data;
|
||||
|
||||
pcd = (PCD_HandleTypeDef *)device->user_data;
|
||||
pcd->Instance = USB;
|
||||
pcd->Init.dev_endpoints = 8;
|
||||
pcd->Init.speed = PCD_SPEED_FULL;
|
||||
@@ -225,19 +214,16 @@ static rt_err_t _init(rt_device_t device)
|
||||
pcd->Init.low_power_enable = DISABLE;
|
||||
pcd->Init.lpm_enable = DISABLE;
|
||||
pcd->Init.battery_charging_enable = DISABLE;
|
||||
|
||||
/* Initialize LL Driver */
|
||||
HAL_PCD_Init(pcd);
|
||||
|
||||
HAL_PCDEx_PMAConfig(pcd , 0x00 , PCD_SNG_BUF, 0x18);
|
||||
HAL_PCDEx_PMAConfig(pcd , 0x80 , PCD_SNG_BUF, 0x58);
|
||||
HAL_PCDEx_PMAConfig(pcd , 0x81 , PCD_SNG_BUF, 0x98);
|
||||
HAL_PCDEx_PMAConfig(pcd , 0x01 , PCD_SNG_BUF, 0x118);
|
||||
HAL_PCDEx_PMAConfig(pcd , 0x82 , PCD_SNG_BUF, 0xD8);
|
||||
HAL_PCDEx_PMAConfig(pcd , 0x02 , PCD_SNG_BUF, 0x158);
|
||||
HAL_PCDEx_PMAConfig(pcd , 0x83 , PCD_SNG_BUF, 0x198);
|
||||
HAL_PCDEx_PMAConfig(pcd, 0x00, PCD_SNG_BUF, 0x18);
|
||||
HAL_PCDEx_PMAConfig(pcd, 0x80, PCD_SNG_BUF, 0x58);
|
||||
HAL_PCDEx_PMAConfig(pcd, 0x81, PCD_SNG_BUF, 0x98);
|
||||
HAL_PCDEx_PMAConfig(pcd, 0x01, PCD_SNG_BUF, 0x118);
|
||||
HAL_PCDEx_PMAConfig(pcd, 0x82, PCD_SNG_BUF, 0xD8);
|
||||
HAL_PCDEx_PMAConfig(pcd, 0x02, PCD_SNG_BUF, 0x158);
|
||||
HAL_PCDEx_PMAConfig(pcd, 0x83, PCD_SNG_BUF, 0x198);
|
||||
HAL_PCD_Start(pcd);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
@@ -257,11 +243,9 @@ const static struct udcd_ops _udc_ops =
|
||||
_wakeup,
|
||||
};
|
||||
|
||||
|
||||
int stm_usbd_register(void)
|
||||
{
|
||||
rt_memset((void *)&_stm_udc, 0, sizeof(struct udcd));
|
||||
|
||||
_stm_udc.parent.type = RT_Device_Class_USBDevice;
|
||||
_stm_udc.parent.init = _init;
|
||||
_stm_udc.parent.user_data = &_stm_pcd;
|
||||
@@ -269,10 +253,9 @@ int stm_usbd_register(void)
|
||||
/* Register endpoint infomation */
|
||||
_stm_udc.ep_pool = _ep_pool;
|
||||
_stm_udc.ep0.id = &_ep_pool[0];
|
||||
|
||||
rt_device_register((rt_device_t)&_stm_udc, "usbd", 0);
|
||||
rt_usb_device_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
INIT_DEVICE_EXPORT(stm_usbd_register);
|
||||
|
||||
@@ -14,7 +14,5 @@
|
||||
#ifndef __STM32_USB_H__
|
||||
#define __STM32_USB_H__
|
||||
#include <rtthread.h>
|
||||
|
||||
int stm_usbd_register(void);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -36,8 +36,8 @@
|
||||
#define __STM32F1xx_IT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
Reference in new issue
Block a user