![]() |
|
|||
File indexing completed on 2025-05-11 08:22:48
0001 /** 0002 * @file 0003 * 0004 * @ingroup arm_beagle 0005 * 0006 * @brief Support for eQEP for the BeagleBone Black. 0007 */ 0008 0009 /* 0010 * SPDX-License-Identifier: BSD-2-Clause 0011 * 0012 * Copyright (c) 2020, 2021 James Fitzsimons <james.fitzsimons@gmail.com> 0013 * 0014 * Redistribution and use in source and binary forms, with or without 0015 * modification, are permitted provided that the following conditions 0016 * are met: 0017 * 1. Redistributions of source code must retain the above copyright 0018 * notice, this list of conditions and the following disclaimer. 0019 * 2. Redistributions in binary form must reproduce the above copyright 0020 * notice, this list of conditions and the following disclaimer in the 0021 * documentation and/or other materials provided with the distribution. 0022 * 0023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0024 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0025 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0026 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0027 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0028 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0029 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0030 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0031 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0032 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0033 * POSSIBILITY OF SUCH DAMAGE. 0034 */ 0035 0036 #include <libcpu/am335x.h> 0037 #include <stdio.h> 0038 #include <bsp.h> 0039 #include <bsp/pwmss.h> 0040 #include <bsp/beagleboneblack.h> 0041 #include <rtems/error.h> 0042 0043 /** 0044 * @brief This function configures the L3 and L4_PER system clocks. 0045 * It also configures the system clocks for the specified ePWMSS 0046 * instance. 0047 * 0048 * @param pwmss_id The instance number of ePWMSS whose system clocks 0049 * have to be configured. 0050 * 0051 * 'pwmss_id' can take one of the following values: 0052 * (0 <= pwmss_id <= 2) 0053 * 0054 * @return True if successful 0055 * False if Unsuccessful 0056 */ 0057 rtems_status_code pwmss_module_clk_config(BBB_PWMSS pwmss_id) 0058 { 0059 /* we initialize clkctrl here to nonsentical value as this is going 0060 * to be assigned later anyway. Here assigning 0 is just to kill 0061 * warning emitted by the C compiler. */ 0062 uint32_t clkctrl = 0; 0063 0064 /* calculate the address of the clock control register for the PWMSS 0065 * module we are configuring */ 0066 if(pwmss_id == BBB_PWMSS0) { 0067 clkctrl = AM335X_CM_PER_ADDR + AM335X_CM_PER_EPWMSS0_CLKCTRL; 0068 } else if(pwmss_id == BBB_PWMSS1) { 0069 clkctrl = AM335X_CM_PER_ADDR + AM335X_CM_PER_EPWMSS1_CLKCTRL; 0070 } else if(pwmss_id == BBB_PWMSS2) { 0071 clkctrl = AM335X_CM_PER_ADDR + AM335X_CM_PER_EPWMSS2_CLKCTRL; 0072 } else { 0073 /* wrong clock configuration, let's panic here. */ 0074 rtems_error(RTEMS_ERROR_PANIC, "beagle: unsupported pwmss module clock configuration value!"); 0075 } 0076 0077 /* when the module is functional the IDLEST bits (16 -17) of the 0078 * CM_PER_EPWMSSx_CLKCTRL register will be 0x0. */ 0079 const uint32_t is_functional = 0x0; 0080 const uint32_t idle_bits = AM335X_CM_PER_EPWMSSx_CLKCTRL_IDLEST; 0081 const uint32_t is_enable = AM335X_CM_PER_EPWMSSx_CLKCTRL_MODULEMODE_ENABLE; 0082 const uint32_t module_mode = AM335X_CM_PER_EPWMSSx_CLKCTRL_MODULEMODE; 0083 0084 REG(clkctrl) |= is_enable; 0085 while((REG(clkctrl) & module_mode) != is_enable); 0086 while((REG(clkctrl) & idle_bits) != is_functional); 0087 0088 return RTEMS_SUCCESSFUL; 0089 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |