2023-01-18 13:10:00 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2023 Gunar Schorcht <gunar@schorcht.net>
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup boards_sipeed_longan_nano
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
2023-08-06 12:54:45 +02:00
|
|
|
* @brief Board specific definitions for the Sipeed Longan Nano board
|
2023-01-18 13:10:00 +01:00
|
|
|
*
|
|
|
|
* @author Gunar Schorcht <gunar@schorcht.net>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PERIPH_CONF_H
|
|
|
|
#define PERIPH_CONF_H
|
|
|
|
|
2023-01-24 00:32:43 +01:00
|
|
|
#include "macros/units.h"
|
2023-01-18 13:10:00 +01:00
|
|
|
|
|
|
|
#ifndef CONFIG_BOARD_HAS_HXTAL
|
|
|
|
#define CONFIG_BOARD_HAS_HXTAL 1 /**< The board provides a high frequency oscillator. */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_BOARD_HAS_LXTAL
|
|
|
|
#define CONFIG_BOARD_HAS_LXTAL 1 /**< The board provides a low frequency oscillator. */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_CLOCK_HXTAL
|
|
|
|
#define CONFIG_CLOCK_HXTAL MHZ(8) /**< HXTAL frequency */
|
|
|
|
#endif
|
|
|
|
|
2023-08-06 12:54:45 +02:00
|
|
|
#ifndef SPI_DEV_1_USED
|
2023-08-06 12:30:41 +02:00
|
|
|
#if defined(BOARD_SIPEED_LONGAN_NANO_TFT)
|
2023-08-06 12:54:45 +02:00
|
|
|
#define SPI_DEV_1_USED 1 /**< Enable SPI_DEV(1) by default for the TFT version */
|
|
|
|
#else
|
|
|
|
#define SPI_DEV_1_USED 0 /**< Disable SPI_DEV(1) by default for the non-TFT version */
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef I2C_DEV_1_USED
|
|
|
|
#define I2C_DEV_1_USED 1 /**< Enable I2C_DEV(1) by default */
|
2023-02-05 18:52:16 +01:00
|
|
|
#endif
|
|
|
|
|
2023-01-24 00:32:43 +01:00
|
|
|
#include "periph_cpu.h"
|
|
|
|
#include "periph_common_conf.h"
|
|
|
|
|
2023-01-29 18:38:11 +01:00
|
|
|
#include "cfg_i2c_default.h"
|
2023-01-30 08:07:22 +01:00
|
|
|
#include "cfg_spi_default.h"
|
2023-01-24 00:32:43 +01:00
|
|
|
#include "cfg_timer_default.h"
|
|
|
|
#include "cfg_uart_default.h"
|
2023-02-07 00:52:03 +01:00
|
|
|
#include "cfg_usbdev_default.h"
|
2023-01-24 00:32:43 +01:00
|
|
|
|
2023-01-18 13:10:00 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2023-01-19 16:52:21 +01:00
|
|
|
/**
|
|
|
|
* @name ADC configuration
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
static const adc_conf_t adc_config[] = {
|
|
|
|
{ .pin = GPIO_PIN(PORT_A, 0), .dev = 0, .chan = 0 },
|
|
|
|
{ .pin = GPIO_PIN(PORT_A, 3), .dev = 0, .chan = 3 },
|
|
|
|
/* ADC Temperature channel */
|
|
|
|
{ .pin = GPIO_UNDEF, .dev = 0, .chan = 16 },
|
|
|
|
/* ADC VREF channel */
|
|
|
|
{ .pin = GPIO_UNDEF, .dev = 0, .chan = 17 },
|
2023-08-06 12:53:25 +02:00
|
|
|
#if !MODULE_PERIPH_DAC
|
|
|
|
/* This conflicts with the DAC */
|
|
|
|
{ .pin = GPIO_PIN(PORT_A, 4), .dev = 0, .chan = 4 },
|
|
|
|
#endif
|
2023-08-06 12:30:41 +02:00
|
|
|
#if !defined(BOARD_SIPEED_LONGAN_NANO_TFT)
|
2023-01-19 16:52:21 +01:00
|
|
|
/* This conflicts with TFT pins if connected. */
|
|
|
|
{ .pin = GPIO_PIN(PORT_B, 0), .dev = 0, .chan = 8 },
|
|
|
|
{ .pin = GPIO_PIN(PORT_B, 1), .dev = 0, .chan = 9 },
|
2023-08-06 12:53:25 +02:00
|
|
|
#if !SPI_DEV_1_USED
|
2023-07-04 12:12:50 +02:00
|
|
|
/* This conflicts with the SPI0 controller which is used if TFT is connected */
|
2023-01-19 16:52:21 +01:00
|
|
|
{ .pin = GPIO_PIN(PORT_A, 6), .dev = 0, .chan = 6 },
|
|
|
|
{ .pin = GPIO_PIN(PORT_A, 7), .dev = 0, .chan = 7 },
|
2023-08-06 12:53:25 +02:00
|
|
|
#if !MODULE_PERIPH_DAC
|
|
|
|
/* This conflicts additionally with the DAC */
|
2023-02-05 18:52:16 +01:00
|
|
|
{ .pin = GPIO_PIN(PORT_A, 5), .dev = 0, .chan = 5 },
|
2023-08-06 12:53:25 +02:00
|
|
|
#endif /* !MODULE_PERIPH_DAC */
|
|
|
|
#endif /* !SPI_DEV_1_USED */
|
2023-08-06 12:30:41 +02:00
|
|
|
#endif /* !defined(BOARD_SIPEED_LONGAN_NANO_TFT) */
|
2023-01-19 16:52:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#define ADC_NUMOF ARRAY_SIZE(adc_config)
|
|
|
|
/** @} */
|
|
|
|
|
2023-02-06 07:15:13 +01:00
|
|
|
/**
|
|
|
|
* @name DAC configuration
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
static const dac_conf_t dac_config[] = {
|
|
|
|
{ .pin = GPIO_PIN(PORT_A, 4), .chan = 0 },
|
2023-08-06 12:53:25 +02:00
|
|
|
#if !SPI_DEV_1_USED
|
2023-02-06 07:15:13 +01:00
|
|
|
{ .pin = GPIO_PIN(PORT_A, 5), .chan = 1 },
|
2023-08-06 12:53:25 +02:00
|
|
|
#endif /* !SPI_DEV_1_USED */
|
2023-07-04 12:12:50 +02:00
|
|
|
};
|
2023-02-06 07:15:13 +01:00
|
|
|
|
|
|
|
#define DAC_NUMOF ARRAY_SIZE(dac_config)
|
|
|
|
/** @} */
|
|
|
|
|
2023-01-28 18:01:16 +01:00
|
|
|
/**
|
|
|
|
* @name PWM configuration
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
static const pwm_conf_t pwm_config[] = {
|
|
|
|
{
|
|
|
|
.dev = TIMER4,
|
|
|
|
.rcu_mask = RCU_APB1EN_TIMER4EN_Msk,
|
|
|
|
.chan = {
|
|
|
|
{ .pin = GPIO_PIN(PORT_A, 1), .cc_chan = 1 },
|
|
|
|
{ .pin = GPIO_PIN(PORT_A, 2), .cc_chan = 2 },
|
|
|
|
/* unused channels have to be defined by GPIO_UNDEF */
|
|
|
|
{ .pin = GPIO_UNDEF, .cc_chan = 0 },
|
|
|
|
{ .pin = GPIO_UNDEF, .cc_chan = 3 },
|
|
|
|
},
|
|
|
|
.af = GPIO_AF_OUT_PP,
|
|
|
|
.bus = APB1,
|
|
|
|
},
|
2023-08-06 12:54:45 +02:00
|
|
|
#if !MODULE_PERIPH_CAN
|
2023-01-28 18:01:16 +01:00
|
|
|
{
|
|
|
|
.dev = TIMER3,
|
|
|
|
.rcu_mask = RCU_APB1EN_TIMER3EN_Msk,
|
|
|
|
.chan = {
|
|
|
|
{ .pin = GPIO_PIN(PORT_B, 8), .cc_chan = 2 },
|
|
|
|
{ .pin = GPIO_PIN(PORT_B, 9), .cc_chan = 3 },
|
|
|
|
/* unused channels have to be defined by GPIO_UNDEF */
|
|
|
|
{ .pin = GPIO_UNDEF, .cc_chan = 0 },
|
|
|
|
{ .pin = GPIO_UNDEF, .cc_chan = 1 },
|
|
|
|
},
|
|
|
|
.af = GPIO_AF_OUT_PP,
|
|
|
|
.bus = APB1,
|
|
|
|
},
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#define PWM_NUMOF ARRAY_SIZE(pwm_config)
|
|
|
|
/** @} */
|
|
|
|
|
2023-01-18 13:10:00 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* PERIPH_CONF_H */
|
|
|
|
/** @} */
|