maybe OK version

This commit is contained in:
2024-09-21 01:28:42 +08:00
parent ba3209550e
commit 46f5f8a452
7 changed files with 468 additions and 423 deletions

View File

@@ -1,47 +1,27 @@
/*!
\file systick.h
\brief the header file of systick
\version 2024-02-22, V2.1.0, firmware for GD32E23x
*/
/*
Copyright (c) 2024, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#ifndef SYSTICK_H
#define SYSTICK_H
/**
* ************************************************************************
*
* @file systick.h
* @author GD32
* @brief
*
* ************************************************************************
* @copyright Copyright (c) 2024 GD32
* ************************************************************************
*/
#ifndef SYS_TICK_H
#define SYS_TICK_H
#include <stdint.h>
/* function declarations */
/* configure systick */
void systick_config(void);
/* delay a time in milliseconds */
void delay_1ms(uint32_t count);
/* delay decrement */
void delay_decrement(void);
#endif /* SYSTICK_H */
/* delay a time in milliseconds */
void delay_ms(uint32_t count);
/* delay a time in microseconds */
void delay_us(uint32_t count);
#endif /* SYS_TICK_H */

View File

@@ -5,6 +5,53 @@
#ifndef WC_BLDC_CONTROL_H
#define WC_BLDC_CONTROL_H
#include "gd32e23x.h"
#define RS485_GPIO_RCU RCU_GPIOA
#define RS485_COM_RCU RCU_USART0
#define RS485_PORT GPIOA
#define RS485_DI_PIN GPIO_PIN_2
#define RS485_RO_PIN GPIO_PIN_3
#define RS485_RE_PIN GPIO_PIN_4
#define RS485_COM USART0
#define GPIO_PORT_SPEED_CTRL GPIOA
#define GPIO_PIN_SPEED_CTRL GPIO_PIN_10
#define GPIO_PORT_SPEED_FB GPIOA
#define GPIO_PIN_SPEED_FB GPIO_PIN_9
#define GPIO_PORT_DRV_ENABLE GPIOF
#define GPIO_PIN_DRV_ENABLE GPIO_PIN_1
#define GPIO_PORT_MOTOR_DIR GPIOF
#define GPIO_PIN_MOTOR_DIR GPIO_PIN_0
#define RCU_SPEED_CTL RCU_GPIOA
#define RCU_SPEED_FB RCU_GPIOA
#define RCU_DRV_ENABLE RCU_GPIOF
#define RCU_MOTOR_DIR RCU_GPIOF
#define TIMER_SPEED_CTL TIMER0
#define TIMER_CH_SPEED_CTL TIMER_CH_2
#define RCU_TIMER_SPEED_CTL RCU_TIMER0
void led_blink_config(void);
/* configure RS485 port & RE/DE Pin */
void rs485_com_config(void);
/* Set transmit enabel */
void rs485_transmit_enable(void);
/* Set receive enabel */
void rs485_receive_enable(void);
void bldc_set_pwm(uint8_t pwm);
void bldc_config(void);
void bldc_enable_set(bit_status status);
void timer2_config(void);
#endif //WC_BLDC_CONTROL_H