Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions board/blue-pill/inc/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ SPDX-License-Identifier: MIT
#include "hal.h"
#endif
#if defined(USE_DRIVERS)
#if defined(GD32F10X)
#include "gd32f10x.h"
#else
#include "stm32f1xx_hal.h"
#endif
#endif

/* === Cabecera C++ ============================================================================ */

Expand All @@ -48,8 +52,8 @@ extern "C" {
#if defined(USE_HAL)
#define LED HAL_GPIO_PC13
#elif defined(USE_DRIVERS)
// #define LED_PORT GPIOC
// #define LED_PIN GPIO_PIN_3
#define LED_PORT GPIOC
#define LED_PIN GPIO_PIN_3
#endif

/* === Public data type declarations =========================================================== */
Expand Down
45 changes: 28 additions & 17 deletions board/blue-pill/src/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ extern void initialise_monitor_handles(void);

/* === Private function implementation ========================================================= */

#if defined(STM32F1XX)
void SystemClock_Config(void) {
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
Expand Down Expand Up @@ -81,8 +82,26 @@ void SystemClock_Config(void) {
}
}

void GPIO_Config(void) {
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOA_CLK_ENABLE();

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_3, GPIO_PIN_RESET);

/*Configure LED GPIO pin : PC13 */
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = LED_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
}
#endif /* STM32F1XX */

/* === Public function implementation ========================================================== */

#if defined(STM32F1XX)
void HAL_MspInit(void) {
/* USER CODE BEGIN MspInit 0 */

Expand All @@ -101,28 +120,20 @@ void HAL_MspInit(void) {

/* USER CODE END MspInit 1 */
}
#endif /* STM32F1XX */

void BoardSetup(void) {
HAL_Init();
SystemClock_Config();
SystemCoreClockUpdate();

#if defined(USE_HAL)
GpioSetDirection(LED, true);
#elif defined(USE_DRIVERS)
GPIO_InitTypeDef GPIO_InitStruct = {0};

/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOA_CLK_ENABLE();

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_3, GPIO_PIN_RESET);

/*Configure LED GPIO pin : PC13 */
GPIO_InitStruct.Pin = LED_PIN GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
#if defined(STM32F1XX)
HAL_Init();
SystemClock_Config();
GPIO_Config();
#else
SystemInit();
#endif
SystemCoreClockUpdate();
#endif

/*
Expand Down
77 changes: 77 additions & 0 deletions board/longan-nano/inc/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/************************************************************************************************
Copyright (c) 2022-2024, Laboratorio de Microprocesadores
Facultad de Ciencias Exactas y Tecnología, Universidad Nacional de Tucumán
https://www.microprocesadores.unt.edu.ar/

Copyright (c) 2022-2024, Esteban Volentini <evolentini@herrera.unt.edu.ar>

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.

SPDX-License-Identifier: MIT
*************************************************************************************************/

#ifndef BOARD_H
#define BOARD_H

/** \brief Longan NANO board declarations
**
** \addtogroup board Board support
** \brief Board agnostic configuration module
** @{ */

/* === Headers files inclusions ================================================================ */

#if defined(USE_HAL)
#include "hal.h"
#endif
#if defined(USE_DRIVERS)
#include "gd32vf103.h"
#endif

/* === Cabecera C++ ============================================================================ */

#ifdef __cplusplus
extern "C" {
#endif

/* === Public macros definitions =============================================================== */

#if defined(USE_HAL)

#elif defined(USE_DRIVERS)

#endif

/* === Public data type declarations =========================================================== */

/* === Public variable declarations ============================================================ */

/* === Public function declarations ============================================================ */

/**
* @brief Function to initilize board configuration
*/
void BoardSetup(void);

/* === End of documentation ==================================================================== */

#ifdef __cplusplus
}
#endif

/** @} End of module definition for doxygen */

#endif /* BOARD_H */
28 changes: 28 additions & 0 deletions board/longan-nano/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
##################################################################################################
# Copyright (c) 2022-2024, Laboratorio de Microprocesadores
# Facultad de Ciencias Exactas y Tecnología, Universidad Nacional de Tucumán
# https://www.microprocesadores.unt.edu.ar/
#
# Copyright (c) 2022-2024, Esteban Volentini <evolentini@herrera.unt.edu.ar>
#
# 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.
#
# SPDX-License-Identifier: MIT
##################################################################################################

MCU ?= gd32vf103cbt6

USE_DRIVERS ?= y
63 changes: 63 additions & 0 deletions board/longan-nano/src/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/************************************************************************************************
Copyright (c) 2022-2024, Laboratorio de Microprocesadores
Facultad de Ciencias Exactas y Tecnología, Universidad Nacional de Tucumán
https://www.microprocesadores.unt.edu.ar/

Copyright (c) 2022-2024, Esteban Volentini <evolentini@herrera.unt.edu.ar>

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.

SPDX-License-Identifier: MIT
*************************************************************************************************/

/** \brief Longan NANO board configuration implementation
**
** \addtogroup board Board support
** \brief Board agnostic configuration module
** @{ */

/* === Headers files inclusions =============================================================== */

#include "board.h"
#include "gd32vf103.h"

/* === Macros definitions ====================================================================== */

/* === Private data type declarations ========================================================== */

/* === Private variable declarations =========================================================== */

/* === Private function declarations =========================================================== */

/* === Public variable definitions ============================================================= */

/* === Private variable definitions ============================================================ */

/* === Private function implementation ========================================================= */

/* === Public function implementation ========================================================== */

void BoardSetup(void) {
#ifdef USE_DRIVERS
SystemInit();
SystemCoreClockUpdate();
#endif
}

/* === End of documentation ====================================================================
*/

/** @} End of module definition for doxygen */
Loading