1 /* 2 * Copyright 2021 QuickLogic 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 * SPDX-License-Identifier: Apache-2.0 17 */ 18 #include "rtconfig.h" 19 #include "core-v-mcu-config.h" 20 #include "hal_apb_soc_ctrl_regs.h" 21 #include "hal_pinmux.h" 22 #ifdef PKG_USING_FREERTOS_WRAPPER 23 #include "FreeRTOS.h" 24 #endif hal_setpullup(uint8_t io_num,uint8_t on)25 void hal_setpullup(uint8_t io_num, uint8_t on) { 26 SocCtrl_t* psoc_ctrl = SOC_CTRL_START_ADDR; 27 28 configASSERT (io_num < N_IO); 29 psoc_ctrl->io_ctrl_b[io_num].cfg = on; 30 } 31 hal_setpinmux(uint8_t io_num,uint8_t mux_sel)32 void hal_setpinmux(uint8_t io_num, uint8_t mux_sel) { 33 SocCtrl_t* psoc_ctrl = SOC_CTRL_START_ADDR; 34 35 configASSERT (io_num < N_IO); 36 psoc_ctrl->io_ctrl_b[io_num].mux = mux_sel; 37 } 38 hal_getpinmux(uint8_t io_num)39 uint8_t hal_getpinmux(uint8_t io_num) { 40 SocCtrl_t* psoc_ctrl = SOC_CTRL_START_ADDR; 41 42 configASSERT (io_num < N_IO); 43 return psoc_ctrl->io_ctrl_b[io_num].mux; 44 } 45