Skip to content

Commit

Permalink
Sync with local development
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvught committed May 25, 2024
1 parent bae66de commit ef87754
Show file tree
Hide file tree
Showing 5 changed files with 472 additions and 0 deletions.
80 changes: 80 additions & 0 deletions lib-dmx/include/gd32/board_gd32h759i_eval.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* @file board_gd32h759i_eval.h
*
*/
/* Copyright (C) 2024 by Arjan van Vught mailto:[email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#ifndef GD32_BOARD_GD32H759I_EVAL_H_
#define GD32_BOARD_GD32H759I_EVAL_H_

#include "gd32_board.h"

namespace max {
static constexpr auto OUT = 2U;
static constexpr auto IN = 2U;
}

#define DMX_MAX_PORTS 2

//#define DMX_USE_USART0
//#define DMX_USE_USART1
#define DMX_USE_USART2
//#define DMX_USE_UART3
//#define DMX_USE_UART4
#define DMX_USE_USART5
//#define DMX_USE_UART6
//#define DMX_USE_UART7

//static constexpr auto USART0_PORT = 7;
//tatic constexpr auto USART1_PORT = 0;
static constexpr auto USART2_PORT = 0;
//static constexpr auto UART3_PORT = 2;
//static constexpr auto UART4_PORT = 3;
static constexpr auto USART5_PORT = 1;
//static constexpr auto UART6_PORT = 5;
//static constexpr auto UART7_PORT = 6;

static constexpr auto DIR_PORT_0_GPIO_PORT = GPIOA;
static constexpr auto DIR_PORT_0_GPIO_PIN = GPIO_PIN_5;

static constexpr auto DIR_PORT_1_GPIO_PORT = GPIOA;
static constexpr auto DIR_PORT_1_GPIO_PIN = GPIO_PIN_6;

static constexpr auto DIR_PORT_2_GPIO_PORT = GPIOA;
static constexpr auto DIR_PORT_2_GPIO_PIN = GPIO_PIN_5;

static constexpr auto DIR_PORT_3_GPIO_PORT = GPIOA;
static constexpr auto DIR_PORT_3_GPIO_PIN = GPIO_PIN_6;

static constexpr auto DIR_PORT_4_GPIO_PORT = GPIOA;
static constexpr auto DIR_PORT_4_GPIO_PIN = GPIO_PIN_5;

static constexpr auto DIR_PORT_5_GPIO_PORT = GPIOA;
static constexpr auto DIR_PORT_5_GPIO_PIN = GPIO_PIN_6;

static constexpr auto DIR_PORT_6_GPIO_PORT = GPIOA;
static constexpr auto DIR_PORT_6_GPIO_PIN = GPIO_PIN_5;

static constexpr auto DIR_PORT_7_GPIO_PORT = GPIOA;
static constexpr auto DIR_PORT_7_GPIO_PIN = GPIO_PIN_6;

#endif /* GD32_BOARD_GD32H759I_EVAL_H_ */
43 changes: 43 additions & 0 deletions lib-gd32/include/gd32_pwm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @file gd32_pwm.h
*
*/
/* Copyright (C) 2024 by Arjan van Vught mailto:[email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#ifndef GD32_PWM_H_
#define GD32_PWM_H_

#include <cstdint>

namespace pwm {
enum class Channel {
PWM_CHANNEL_0,
PWM_CHANNEL_1,
PWM_CHANNEL_2,
PWM_CHANNEL_3
};
} // namespace pwm

void gd32_pwm_begin();
void gd32_pwm_set_duty_cycle(const pwm::Channel channel, const uint32_t nDutyCycle);

#endif /* GD32_PWM_H_ */
60 changes: 60 additions & 0 deletions lib-gd32/include/mcu/gd32f30x_mcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,66 @@
# define SPI2_NSS_GPIO_PINx GPIO_PIN_15
#endif

/**
* TIMER GPIO
*/

#define TIMER2CH0_RCU_GPIOx RCU_GPIOA
#define TIMER2CH0_GPIOx GPIOA
#define TIMER2CH0_GPIO_PINx GPIO_PIN_6

#if defined(TIMER2_FULL_REMAP)
# define TIMER2_REMAP GPIO_TIMER2_FULL_REMAP
# define TIMER2_CH0_RCU_GPIOx RCU_GPIOC
# define TIMER2_CH0_GPIOx GPIOC
# define TIMER2_CH0_GPIO_PINx GPIO_PIN_6

# define TIMER2_CH1_RCU_GPIOx RCU_GPIOC
# define TIMER2_CH1_GPIOx GPIOC
# define TIMER2_CH1_GPIO_PINx GPIO_PIN_7

# define TIMER2_CH2_RCU_GPIOx RCU_GPIOC
# define TIMER2_CH2_GPIOx GPIOC
# define TIMER2_CH2_GPIO_PINx GPIO_PIN_8

# define TIMER2_CH3_RCU_GPIOx RCU_GPIOC
# define TIMER2_CH3_GPIOx GPIOC
# define TIMER2_CH3_GPIO_PINx GPIO_PIN_9
#elif defined(TIMER2_PARTIAL_REMAP)
# define TIMER2_REMAP GPIO_TIMER2_PARTIAL_REMAP
# define TIMER2_CH0_RCU_GPIOx RCU_GPIOB
# define TIMER2_CH0_GPIOx GPIOB
# define TIMER2_CH0_GPIO_PINx GPIO_PIN_4

# define TIMER2_CH1_RCU_GPIOx RCU_GPIOB
# define TIMER2_CH1_GPIOx GPIOB
# define TIMER2_CH1_GPIO_PINx GPIO_PIN_5

# define TIMER2_CH2_RCU_GPIOx RCU_GPIOB
# define TIMER2_CH2_GPIOx GPIOB
# define TIMER2_CH2_GPIO_PINx GPIO_PIN_0

# define TIMER2_CH3_RCU_GPIOx RCU_GPIOB
# define TIMER2_CH3_GPIOx GPIOB
# define TIMER2_CH3_GPIO_PINx GPIO_PIN_1
#else
# define TIMER2_CH0_RCU_GPIOx RCU_GPIOA
# define TIMER2_CH0_GPIOx GPIOA
# define TIMER2_CH0_GPIO_PINx GPIO_PIN_6

# define TIMER2_CH1_RCU_GPIOx RCU_GPIOA
# define TIMER2_CH1_GPIOx GPIOA
# define TIMER2_CH1_GPIO_PINx GPIO_PIN_7

# define TIMER2_CH2_RCU_GPIOx RCU_GPIOB
# define TIMER2_CH2_GPIOx GPIOB
# define TIMER2_CH2_GPIO_PINx GPIO_PIN_0

# define TIMER2_CH3_RCU_GPIOx RCU_GPIOB
# define TIMER2_CH3_GPIOx GPIOB
# define TIMER2_CH3_GPIO_PINx GPIO_PIN_1
#endif

/**
* DMA
*/
Expand Down
1 change: 1 addition & 0 deletions lib-gd32/src/f/gd32_i2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ static void gpio_config() {
gpio_af_set(I2C_SCL_GPIOx, I2C_GPIO_AFx, I2C_SCL_GPIO_PINx);
gpio_mode_set(I2C_SCL_GPIOx, GPIO_MODE_AF, GPIO_PUPD_PULLUP, I2C_SCL_GPIO_PINx);
gpio_output_options_set(I2C_SCL_GPIOx, GPIO_OTYPE_OD, GPIO_OSPEED_50MHZ, I2C_SCL_GPIO_PINx);

gpio_af_set(I2C_SDA_GPIOx, I2C_GPIO_AFx, I2C_SDA_GPIO_PINx);
gpio_mode_set(I2C_SDA_GPIOx, GPIO_MODE_AF, GPIO_PUPD_PULLUP, I2C_SDA_GPIO_PINx);
gpio_output_options_set(I2C_SDA_GPIOx, GPIO_OTYPE_OD, GPIO_OSPEED_50MHZ, I2C_SDA_GPIO_PINx);
Expand Down
Loading

0 comments on commit ef87754

Please sign in to comment.