Skip to content

Commit

Permalink
Update board and mcuconf files.
Browse files Browse the repository at this point in the history
  • Loading branch information
HorrorTroll committed Aug 26, 2024
1 parent 4dfba4f commit d8395b9
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 44 deletions.
58 changes: 52 additions & 6 deletions platforms/chibios/boards/GENERIC_AT32_F415XX/board/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@

#include "hal.h"

/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/

/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/

/*===========================================================================*/
/* Driver local variables and types. */
/*===========================================================================*/

/**
* @brief PAL setup.
* @details Digital I/O ports static configuration as defined in @p board.h.
Expand All @@ -38,17 +50,51 @@ const PALConfig pal_default_config =
};
#endif

/*
* Early initialization code.
* This initialization must be performed just after stack setup and before
* any other initialization.
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/

/*===========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/

/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/

/**
* @brief Early initialization code.
* @details System clocks are initialized before everything else.
*/
void __early_init(void) {
at32_clock_init();
}

/*
* Board-specific initialization code.
#if HAL_USE_SDC || defined(__DOXYGEN__)
/**
* @brief SDC card detection.
*/
bool sdc_lld_is_card_inserted(SDCDriver *sdcp) {
static bool last_status = false;

if (blkIsTransferring(sdcp))
return last_status;
return last_status = (bool)palReadPad(GPIOC, GPIOC_PIN11);
}

/**
* @brief SDC card write protection detection.
*/
bool sdc_lld_is_write_protected(SDCDriver *sdcp) {

(void)sdcp;
return false;
}
#endif /* HAL_USE_SDC */

/**
* @brief Board-specific initialization code.
* @note You can add your board-specific code here.
*/
void boardInit(void) {
IOMUX->REMAP |= IOMUX_REMAP_SWJTAG_MUX_JTAGDIS;
Expand Down
70 changes: 37 additions & 33 deletions platforms/chibios/boards/GENERIC_AT32_F415XX/board/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#ifndef _BOARD_H_
#define _BOARD_H_

/*===========================================================================*/
/* Driver constants. */
/*===========================================================================*/

/*
* Setup for a Generic AT32F415 board.
*/
Expand All @@ -30,10 +34,15 @@
#define BOARD_NAME "GENERIC AT32F415 board"

/*
* Board frequencies.
* Board oscillators-related settings.
*/
#if !defined(AT32_LEXTCLK)
#define AT32_LEXTCLK 32768
#endif

#if !defined(AT32_HEXTCLK)
#define AT32_HEXTCLK 8000000
#endif

/*
* MCU type, supported types are defined in ./os/hal/platforms/hal_lld.h.
Expand All @@ -56,8 +65,8 @@
#define GPIOA_PIN10 10U
#define GPIOA_PIN11 11U
#define GPIOA_PIN12 12U
#define GPIOA_PIN13 13U
#define GPIOA_PIN14 14U
#define GPIOA_SWDIO 13U
#define GPIOA_SWCLK 14U
#define GPIOA_PIN15 15U

#define GPIOB_PIN0 0U
Expand Down Expand Up @@ -94,39 +103,30 @@
#define GPIOC_PIN14 14U
#define GPIOC_PIN15 15U

#define GPIOD_PIN0 0U
#define GPIOD_PIN1 1U
#define GPIOD_HEXT_IN 0U
#define GPIOD_HEXT_OUT 1U
#define GPIOD_PIN2 2U
#define GPIOD_PIN3 3U
#define GPIOD_PIN4 4U
#define GPIOD_PIN5 5U
#define GPIOD_PIN6 6U
#define GPIOD_PIN7 7U
#define GPIOD_PIN8 8U
#define GPIOD_PIN9 9U
#define GPIOD_PIN10 10U
#define GPIOD_PIN11 11U
#define GPIOD_PIN12 12U
#define GPIOD_PIN13 13U
#define GPIOD_PIN14 14U
#define GPIOD_PIN15 15U

#define GPIOF_PIN0 0U
#define GPIOF_PIN1 1U
#define GPIOF_PIN2 2U
#define GPIOF_PIN3 3U

#define GPIOF_PIN4 4U
#define GPIOF_PIN5 5U
#define GPIOF_PIN6 6U
#define GPIOF_PIN7 7U
#define GPIOF_PIN8 8U
#define GPIOF_PIN9 9U
#define GPIOF_PIN10 10U
#define GPIOF_PIN11 11U
#define GPIOF_PIN12 12U
#define GPIOF_PIN13 13U
#define GPIOF_PIN14 14U
#define GPIOF_PIN15 15U

/*===========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/

/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/

/*===========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/

/*===========================================================================*/
/* Driver macros. */
/*===========================================================================*/

/*
* I/O ports initial setup, this configuration is established soon after reset
Expand Down Expand Up @@ -176,8 +176,8 @@
/*
* Port D setup.
* Everything input with pull-up except:
* PD0 - Normal input (XTAL).
* PD1 - Normal input (XTAL).
* PD0 - Normal input (GPIOD_HEXT_IN).
* PD1 - Normal input (GPIOD_HEXT_OUT).
*/
#define VAL_GPIODCFGLR 0x88888844 /* PD7...PD0 */
#define VAL_GPIODCFGHR 0x88888888 /* PD15...PD8 */
Expand All @@ -190,6 +190,10 @@
#define VAL_GPIOFCFGHR 0x88888888 /* PF15...PF8 */
#define VAL_GPIOFODT 0xFFFFFFFF

/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/

#if !defined(_FROM_ASM_)
#ifdef __cplusplus
extern "C" {
Expand Down
24 changes: 19 additions & 5 deletions platforms/chibios/boards/GENERIC_AT32_F415XX/configs/mcuconf.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
ChibiOS - Copyright (C) 2006..2020 Giovanni Di Sirio
ChibiOS - Copyright (C) 2023..2024 HorrorTroll
ChibiOS - Copyright (C) 2023..2024 Zhaqian
Expand All @@ -19,8 +19,6 @@
#ifndef MCUCONF_H
#define MCUCONF_H

#define AT32F415_MCUCONF

/*
* AT32F415 drivers configuration.
* The following settings override the default settings present in
Expand All @@ -35,10 +33,16 @@
* 0...3 Lowest...Highest.
*/

#define AT32F415_MCUCONF

/*
* HAL driver system settings.
* General settings.
*/
#define AT32_NO_INIT FALSE

/*
* HAL driver system settings.
*/
#define AT32_HICK_ENABLED TRUE
#define AT32_LICK_ENABLED FALSE
#define AT32_HEXT_ENABLED TRUE
Expand All @@ -58,6 +62,7 @@
#define AT32_USB_CLOCK_REQUIRED TRUE
#define AT32_USBDIV AT32_USBDIV_DIV3
#define AT32_CLKOUT_SEL AT32_CLKOUT_SEL_NOCLOCK
#define AT32_CLKOUTDIV AT32_CLKOUTDIV_DIV1
#define AT32_ERTCSEL AT32_ERTCSEL_HEXTDIV
#define AT32_PVM_ENABLE FALSE
#define AT32_PVMSEL AT32_PVMSEL_LEV1
Expand Down Expand Up @@ -169,6 +174,16 @@
#define AT32_ERTC_CTRL_INIT 0
#define AT32_ERTC_TAMP_INIT 0

/*
* SDC driver system settings.
*/
#define AT32_SDC_SDIO_DMA_PRIORITY 3
#define AT32_SDC_SDIO_IRQ_PRIORITY 9
#define AT32_SDC_WRITE_TIMEOUT_MS 1000
#define AT32_SDC_READ_TIMEOUT_MS 1000
#define AT32_SDC_CLOCK_ACTIVATION_DELAY 10
#define AT32_SDC_SDIO_UNALIGNED_SUPPORT TRUE

/*
* SERIAL driver system settings.
*/
Expand Down Expand Up @@ -212,7 +227,6 @@
#define AT32_USB_USE_OTG1 TRUE
#define AT32_USB_OTG1_IRQ_PRIORITY 14
#define AT32_USB_OTG1_RX_FIFO_SIZE 512
#define AT32_USB_HOST_WAKEUP_DURATION 2

/*
* WDG driver system settings.
Expand Down

0 comments on commit d8395b9

Please sign in to comment.