pikapython/package/STM32/STM32_common.h

94 lines
1.8 KiB
C
Raw Normal View History

2021-10-01 20:00:15 +08:00
#ifndef __STM32__COMMON__H
#define __STM32__COMMON__H
#include "PikaObj.h"
2021-11-12 16:14:20 +08:00
#include "main.h"
#include <stdint.h>
2021-11-09 21:46:34 +08:00
/* support std lib for stm32 */
#define delay_ms HAL_Delay
2021-11-12 10:58:38 +08:00
#undef u16
#undef u8
#undef u32
#define u16 uint16_t
#define u8 uint8_t
#define u32 uint32_t
2021-10-01 20:00:15 +08:00
2021-11-09 21:46:34 +08:00
#define GPIO_Pin_0 GPIO_PIN_0
#define GPIO_Pin_1 GPIO_PIN_1
#define GPIO_Pin_2 GPIO_PIN_2
#define GPIO_Pin_3 GPIO_PIN_3
#define GPIO_Pin_4 GPIO_PIN_4
#define GPIO_Pin_5 GPIO_PIN_5
#define GPIO_Pin_6 GPIO_PIN_6
#define GPIO_Pin_7 GPIO_PIN_7
#define GPIO_Pin_8 GPIO_PIN_8
#define GPIO_Pin_9 GPIO_PIN_9
#define GPIO_Pin_10 GPIO_PIN_10
#define GPIO_Pin_11 GPIO_PIN_11
#define GPIO_Pin_12 GPIO_PIN_12
#define GPIO_Pin_13 GPIO_PIN_13
#define GPIO_Pin_14 GPIO_PIN_14
#define GPIO_Pin_15 GPIO_PIN_15
2021-10-01 20:00:15 +08:00
#ifdef STM32G070xx
#include "stm32g0xx_hal.h"
#define UART1_EXIST
#define UART2_EXIST
#define UART3_EXIST
#define UART4_EXIST
2021-10-04 00:44:57 +08:00
#define TIM1_EXIST
#define TIM3_EXIST
#define TIM14_EXIST
#define TIM16_EXIST
#define TIM17_EXIST
#define Code_ENABLE
2021-10-01 20:00:15 +08:00
#endif
#ifdef STM32F103xB
#include "stm32f1xx_hal.h"
#define UART1_EXIST
#define UART2_EXIST
#define UART3_EXIST
#define TIM1_EXIST
#define TIM2_EXIST
#define TIM3_EXIST
#define TIM4_EXIST
#endif
#ifdef STM32G030xx
#include "stm32g0xx_hal.h"
2021-11-12 10:58:38 +08:00
#include "stm32g030_pika_msp.h"
2021-10-01 20:00:15 +08:00
#define UART1_EXIST
#define UART2_EXIST
#define TIM1_EXIST
#define TIM3_EXIST
#define TIM14_EXIST
#define TIM16_EXIST
#define TIM17_EXIST
2021-10-02 19:20:18 +08:00
#define Code_ENABLE
2021-10-01 20:00:15 +08:00
#endif
2021-11-12 16:45:31 +08:00
typedef struct pika_IIC_info_t {
GPIO_TypeDef* SCL_GPIO;
GPIO_TypeDef* SDA_GPIO;
uint32_t SCL_GPIO_Pin;
uint32_t SDA_GPIO_Pin;
uint8_t deviceAddr;
uint8_t readBuff[32];
} pika_IIC_info;
2021-11-12 16:14:20 +08:00
GPIO_TypeDef* GPIO_get_Group(char* pin);
uint16_t GPIO_get_pin(char* pin);
2021-10-01 20:00:15 +08:00
uint32_t getPinMode(char* mode);
2021-11-12 16:14:20 +08:00
uint8_t GPIO_enable_clock(char* pin);
2021-10-01 20:00:15 +08:00
void delay_us(uint32_t delay);
void delay_unit(uint32_t delay);
2021-11-12 10:58:38 +08:00
2021-11-14 19:22:45 +08:00
#endif