qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

board.c (3566B)


      1 /*
      2     ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
      3     ChibiOS - Copyright (C) 2023..2025 HorrorTroll
      4     ChibiOS - Copyright (C) 2023..2025 Zhaqian
      5 
      6     Licensed under the Apache License, Version 2.0 (the "License");
      7     you may not use this file except in compliance with the License.
      8     You may obtain a copy of the License at
      9 
     10         http://www.apache.org/licenses/LICENSE-2.0
     11 
     12     Unless required by applicable law or agreed to in writing, software
     13     distributed under the License is distributed on an "AS IS" BASIS,
     14     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     15     See the License for the specific language governing permissions and
     16     limitations under the License.
     17 */
     18 
     19 #include "hal.h"
     20 
     21 /*===========================================================================*/
     22 /* Driver local definitions.                                                 */
     23 /*===========================================================================*/
     24 
     25 /*===========================================================================*/
     26 /* Driver exported variables.                                                */
     27 /*===========================================================================*/
     28 
     29 /*===========================================================================*/
     30 /* Driver local variables and types.                                         */
     31 /*===========================================================================*/
     32 
     33 /**
     34  * @brief   PAL setup.
     35  * @details Digital I/O ports static configuration as defined in @p board.h.
     36  *          This variable is used by the HAL when initializing the PAL driver.
     37  */
     38 #if HAL_USE_PAL || defined(__DOXYGEN__)
     39 const PALConfig pal_default_config =
     40 {
     41   {VAL_GPIOAODT, VAL_GPIOACFGLR, VAL_GPIOACFGHR},
     42   {VAL_GPIOBODT, VAL_GPIOBCFGLR, VAL_GPIOBCFGHR},
     43 #if AT32_HAS_GPIOC
     44   {VAL_GPIOCODT, VAL_GPIOCCFGLR, VAL_GPIOCCFGHR},
     45 #endif
     46   {VAL_GPIODODT, VAL_GPIODCFGLR, VAL_GPIODCFGHR},
     47 #if AT32_HAS_GPIOF
     48   {VAL_GPIOFODT, VAL_GPIOFCFGLR, VAL_GPIOFCFGHR},
     49 #endif
     50 };
     51 #endif
     52 
     53 /*===========================================================================*/
     54 /* Driver local functions.                                                   */
     55 /*===========================================================================*/
     56 
     57 /*===========================================================================*/
     58 /* Driver interrupt handlers.                                                */
     59 /*===========================================================================*/
     60 
     61 /*===========================================================================*/
     62 /* Driver exported functions.                                                */
     63 /*===========================================================================*/
     64 
     65 /**
     66  * @brief   Early initialization code.
     67  * @details System clocks are initialized before everything else.
     68  */
     69 void __early_init(void) {
     70   at32_clock_init();
     71 }
     72 
     73 #if HAL_USE_SDC || defined(__DOXYGEN__)
     74 /**
     75  * @brief   SDC card detection.
     76  */
     77 bool sdc_lld_is_card_inserted(SDCDriver *sdcp) {
     78   static bool last_status = false;
     79 
     80   if (blkIsTransferring(sdcp))
     81     return last_status;
     82   return last_status = (bool)palReadPad(GPIOC, GPIOC_PIN11);
     83 }
     84 
     85 /**
     86  * @brief   SDC card write protection detection.
     87  */
     88 bool sdc_lld_is_write_protected(SDCDriver *sdcp) {
     89 
     90   (void)sdcp;
     91   return false;
     92 }
     93 #endif /* HAL_USE_SDC */
     94 
     95 /**
     96  * @brief   Board-specific initialization code.
     97  * @note    You can add your board-specific code here.
     98  */
     99 void boardInit(void) {
    100   IOMUX->REMAP |= IOMUX_REMAP_SWJTAG_MUX_JTAGDIS;
    101 }