collab/mm20
git clone https://git.julia.blue/collab/mm20
39a929c
pcb
1#include <stdbool.h> 2#include <stdint.h> 3//***************************************************************************** 4// 5// pwm.h - API function protoypes for Pulse Width Modulation (PWM) ports 6// 7// Copyright (c) 2005-2017 Texas Instruments Incorporated. All rights reserved. 8// Software License Agreement 9// 10// Redistribution and use in source and binary forms, with or without 11// modification, are permitted provided that the following conditions 12// are met: 13// 14// Redistributions of source code must retain the above copyright 15// notice, this list of conditions and the following disclaimer. 16// 17// Redistributions in binary form must reproduce the above copyright 18// notice, this list of conditions and the following disclaimer in the 19// documentation and/or other materials provided with the 20// distribution. 21// 22// Neither the name of Texas Instruments Incorporated nor the names of 23// its contributors may be used to endorse or promote products derived 24// from this software without specific prior written permission. 25// 26// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37// 38// This is part of revision 2.1.4.178 of the Tiva Peripheral Driver Library. 39// 40//***************************************************************************** 41 42#ifndef __DRIVERLIB_PWM_H__ 43#define __DRIVERLIB_PWM_H__ 44 45//***************************************************************************** 46// 47// If building with a C++ compiler, make all of the definitions in this header 48// have a C binding. 49// 50//***************************************************************************** 51#ifdef __cplusplus 52extern "C" 53{ 54#endif 55 56//***************************************************************************** 57// 58// The following defines are passed to PWMGenConfigure() as the ui32Config 59// parameter and specify the configuration of the PWM generator. 60// 61//***************************************************************************** 62#define PWM_GEN_MODE_DOWN 0x00000000 // Down count mode 63#define PWM_GEN_MODE_UP_DOWN 0x00000002 // Up/Down count mode 64#define PWM_GEN_MODE_SYNC 0x00000038 // Synchronous updates 65#define PWM_GEN_MODE_NO_SYNC 0x00000000 // Immediate updates 66#define PWM_GEN_MODE_DBG_RUN 0x00000004 // Continue running in debug mode 67#define PWM_GEN_MODE_DBG_STOP 0x00000000 // Stop running in debug mode 68#define PWM_GEN_MODE_FAULT_LATCHED \ 69 0x00040000 // Fault is latched 70#define PWM_GEN_MODE_FAULT_UNLATCHED \ 71 0x00000000 // Fault is not latched 72#define PWM_GEN_MODE_FAULT_MINPER \ 73 0x00020000 // Enable min fault period 74#define PWM_GEN_MODE_FAULT_NO_MINPER \ 75 0x00000000 // Disable min fault period 76#define PWM_GEN_MODE_FAULT_EXT 0x00010000 // Enable extended fault support 77#define PWM_GEN_MODE_FAULT_LEGACY \ 78 0x00000000 // Disable extended fault support 79#define PWM_GEN_MODE_DB_NO_SYNC 0x00000000 // Deadband updates occur 80// immediately 81#define PWM_GEN_MODE_DB_SYNC_LOCAL \ 82 0x0000A800 // Deadband updates locally 83// synchronized 84#define PWM_GEN_MODE_DB_SYNC_GLOBAL \ 85 0x0000FC00 // Deadband updates globally 86// synchronized 87#define PWM_GEN_MODE_GEN_NO_SYNC \ 88 0x00000000 // Generator mode updates occur 89// immediately 90#define PWM_GEN_MODE_GEN_SYNC_LOCAL \ 91 0x00000280 // Generator mode updates locally 92// synchronized 93#define PWM_GEN_MODE_GEN_SYNC_GLOBAL \ 94 0x000003C0 // Generator mode updates globally 95// synchronized 96 97//***************************************************************************** 98// 99// Defines for enabling, disabling, and clearing PWM generator interrupts and 100// triggers. 101// 102//***************************************************************************** 103#define PWM_INT_CNT_ZERO 0x00000001 // Int if COUNT = 0 104#define PWM_INT_CNT_LOAD 0x00000002 // Int if COUNT = LOAD 105#define PWM_INT_CNT_AU 0x00000004 // Int if COUNT = CMPA U 106#define PWM_INT_CNT_AD 0x00000008 // Int if COUNT = CMPA D 107#define PWM_INT_CNT_BU 0x00000010 // Int if COUNT = CMPA U 108#define PWM_INT_CNT_BD 0x00000020 // Int if COUNT = CMPA D 109#define PWM_TR_CNT_ZERO 0x00000100 // Trig if COUNT = 0 110#define PWM_TR_CNT_LOAD 0x00000200 // Trig if COUNT = LOAD 111#define PWM_TR_CNT_AU 0x00000400 // Trig if COUNT = CMPA U 112#define PWM_TR_CNT_AD 0x00000800 // Trig if COUNT = CMPA D 113#define PWM_TR_CNT_BU 0x00001000 // Trig if COUNT = CMPA U 114#define PWM_TR_CNT_BD 0x00002000 // Trig if COUNT = CMPA D 115 116//***************************************************************************** 117// 118// Defines for enabling, disabling, and clearing PWM interrupts. 119// 120//***************************************************************************** 121#define PWM_INT_GEN_0 0x00000001 // Generator 0 interrupt 122#define PWM_INT_GEN_1 0x00000002 // Generator 1 interrupt 123#define PWM_INT_GEN_2 0x00000004 // Generator 2 interrupt 124#define PWM_INT_GEN_3 0x00000008 // Generator 3 interrupt 125#define PWM_INT_FAULT0 0x00010000 // Fault0 interrupt 126#define PWM_INT_FAULT1 0x00020000 // Fault1 interrupt 127#define PWM_INT_FAULT2 0x00040000 // Fault2 interrupt 128#define PWM_INT_FAULT3 0x00080000 // Fault3 interrupt 129#define PWM_INT_FAULT_M 0x000F0000 // Fault interrupt source mask 130 131//***************************************************************************** 132// 133// Defines to identify the generators within a module. 134// 135//***************************************************************************** 136#define PWM_GEN_0 0x00000040 // Offset address of Gen0 137#define PWM_GEN_1 0x00000080 // Offset address of Gen1 138#define PWM_GEN_2 0x000000C0 // Offset address of Gen2 139#define PWM_GEN_3 0x00000100 // Offset address of Gen3 140 141#define PWM_GEN_0_BIT 0x00000001 // Bit-wise ID for Gen0 142#define PWM_GEN_1_BIT 0x00000002 // Bit-wise ID for Gen1 143#define PWM_GEN_2_BIT 0x00000004 // Bit-wise ID for Gen2 144#define PWM_GEN_3_BIT 0x00000008 // Bit-wise ID for Gen3 145 146#define PWM_GEN_EXT_0 0x00000800 // Offset of Gen0 ext address range 147#define PWM_GEN_EXT_1 0x00000880 // Offset of Gen1 ext address range 148#define PWM_GEN_EXT_2 0x00000900 // Offset of Gen2 ext address range 149#define PWM_GEN_EXT_3 0x00000980 // Offset of Gen3 ext address range 150 151//***************************************************************************** 152// 153// Defines to identify the outputs within a module. 154// 155//***************************************************************************** 156#define PWM_OUT_0 0x00000040 // Encoded offset address of PWM0 157#define PWM_OUT_1 0x00000041 // Encoded offset address of PWM1 158#define PWM_OUT_2 0x00000082 // Encoded offset address of PWM2 159#define PWM_OUT_3 0x00000083 // Encoded offset address of PWM3 160#define PWM_OUT_4 0x000000C4 // Encoded offset address of PWM4 161#define PWM_OUT_5 0x000000C5 // Encoded offset address of PWM5 162#define PWM_OUT_6 0x00000106 // Encoded offset address of PWM6 163#define PWM_OUT_7 0x00000107 // Encoded offset address of PWM7 164 165#define PWM_OUT_0_BIT 0x00000001 // Bit-wise ID for PWM0 166#define PWM_OUT_1_BIT 0x00000002 // Bit-wise ID for PWM1 167#define PWM_OUT_2_BIT 0x00000004 // Bit-wise ID for PWM2 168#define PWM_OUT_3_BIT 0x00000008 // Bit-wise ID for PWM3 169#define PWM_OUT_4_BIT 0x00000010 // Bit-wise ID for PWM4 170#define PWM_OUT_5_BIT 0x00000020 // Bit-wise ID for PWM5 171#define PWM_OUT_6_BIT 0x00000040 // Bit-wise ID for PWM6 172#define PWM_OUT_7_BIT 0x00000080 // Bit-wise ID for PWM7 173 174//***************************************************************************** 175// 176// Defines to identify each of the possible fault trigger conditions in 177// PWM_FAULT_GROUP_0. 178// 179//***************************************************************************** 180#define PWM_FAULT_GROUP_0 0 181 182#define PWM_FAULT_FAULT0 0x00000001 183#define PWM_FAULT_FAULT1 0x00000002 184#define PWM_FAULT_FAULT2 0x00000004 185#define PWM_FAULT_FAULT3 0x00000008 186#define PWM_FAULT_ACMP0 0x00010000 187#define PWM_FAULT_ACMP1 0x00020000 188#define PWM_FAULT_ACMP2 0x00040000 189 190//***************************************************************************** 191// 192// Defines to identify each of the possible fault trigger conditions in 193// PWM_FAULT_GROUP_1. 194// 195//***************************************************************************** 196#define PWM_FAULT_GROUP_1 1 197 198#define PWM_FAULT_DCMP0 0x00000001 199#define PWM_FAULT_DCMP1 0x00000002 200#define PWM_FAULT_DCMP2 0x00000004 201#define PWM_FAULT_DCMP3 0x00000008 202#define PWM_FAULT_DCMP4 0x00000010 203#define PWM_FAULT_DCMP5 0x00000020 204#define PWM_FAULT_DCMP6 0x00000040 205#define PWM_FAULT_DCMP7 0x00000080 206 207//***************************************************************************** 208// 209// Defines to identify the sense of each of the external FAULTn signals 210// 211//***************************************************************************** 212#define PWM_FAULT0_SENSE_HIGH 0x00000000 213#define PWM_FAULT0_SENSE_LOW 0x00000001 214#define PWM_FAULT1_SENSE_HIGH 0x00000000 215#define PWM_FAULT1_SENSE_LOW 0x00000002 216#define PWM_FAULT2_SENSE_HIGH 0x00000000 217#define PWM_FAULT2_SENSE_LOW 0x00000004 218#define PWM_FAULT3_SENSE_HIGH 0x00000000 219#define PWM_FAULT3_SENSE_LOW 0x00000008 220 221//***************************************************************************** 222// 223// Defines that can be passed to the PWMClockSet() API as the ui32Config 224// parameter, and can be returned by the PWMClockGet() API. 225// 226//***************************************************************************** 227#define PWM_SYSCLK_DIV_1 0x00000000 // PWM clock is system clock 228#define PWM_SYSCLK_DIV_2 0x00000100 // PWM clock is system clock /2 229#define PWM_SYSCLK_DIV_4 0x00000101 // PWM clock is system clock /4 230#define PWM_SYSCLK_DIV_8 0x00000102 // PWM clock is system clock /8 231#define PWM_SYSCLK_DIV_16 0x00000103 // PWM clock is system clock /16 232#define PWM_SYSCLK_DIV_32 0x00000104 // PWM clock is system clock /32 233#define PWM_SYSCLK_DIV_64 0x00000105 // PWM clock is system clock /64 234 235//***************************************************************************** 236// 237// Defines passed to PWMOutputUpdateMode() to identify the synchronization mode 238// to use when enabling or disabling outputs using PWMOutputState(). 239// 240//***************************************************************************** 241#define PWM_OUTPUT_MODE_NO_SYNC 0x00000000 // Updates to occur immediately 242#define PWM_OUTPUT_MODE_SYNC_LOCAL \ 243 0x00000002 // Updates are locally synchronized 244#define PWM_OUTPUT_MODE_SYNC_GLOBAL \ 245 0x00000003 // Updates are globally synchronized 246 247//***************************************************************************** 248// 249// API Function prototypes 250// 251//***************************************************************************** 252extern void PWMGenConfigure (uint32_t ui32Base ,uint32_t ui32Gen , 253uint32_t ui32Config ); 254extern void PWMGenPeriodSet (uint32_t ui32Base ,uint32_t ui32Gen , 255uint32_t ui32Period ); 256extern uint32_t PWMGenPeriodGet (uint32_t ui32Base , 257uint32_t ui32Gen ); 258extern void PWMGenEnable (uint32_t ui32Base ,uint32_t ui32Gen ); 259extern void PWMGenDisable (uint32_t ui32Base ,uint32_t ui32Gen ); 260extern void PWMPulseWidthSet (uint32_t ui32Base ,uint32_t ui32PWMOut , 261uint32_t ui32Width ); 262extern uint32_t PWMPulseWidthGet (uint32_t ui32Base , 263uint32_t ui32PWMOut ); 264extern void PWMDeadBandEnable (uint32_t ui32Base ,uint32_t ui32Gen , 265uint16_t ui16Rise ,uint16_t ui16Fall ); 266extern void PWMDeadBandDisable (uint32_t ui32Base ,uint32_t ui32Gen ); 267extern void PWMSyncUpdate (uint32_t ui32Base ,uint32_t ui32GenBits ); 268extern void PWMSyncTimeBase (uint32_t ui32Base ,uint32_t ui32GenBits ); 269extern void PWMOutputState (uint32_t ui32Base ,uint32_t ui32PWMOutBits , 270bool bEnable ); 271extern void PWMOutputInvert (uint32_t ui32Base ,uint32_t ui32PWMOutBits , 272bool bInvert ); 273extern void PWMOutputFaultLevel (uint32_t ui32Base , 274uint32_t ui32PWMOutBits , 275bool bDriveHigh ); 276extern void PWMOutputFault (uint32_t ui32Base ,uint32_t ui32PWMOutBits , 277bool bFaultSuppress ); 278extern void PWMGenIntRegister (uint32_t ui32Base ,uint32_t ui32Gen , 279void (* pfnIntHandler )(void )); 280extern void PWMGenIntUnregister (uint32_t ui32Base ,uint32_t ui32Gen ); 281extern void PWMFaultIntRegister (uint32_t ui32Base , 282void (* pfnIntHandler )(void )); 283extern void PWMFaultIntUnregister (uint32_t ui32Base ); 284extern void PWMGenIntTrigEnable (uint32_t ui32Base ,uint32_t ui32Gen , 285uint32_t ui32IntTrig ); 286extern void PWMGenIntTrigDisable (uint32_t ui32Base ,uint32_t ui32Gen , 287uint32_t ui32IntTrig ); 288extern uint32_t PWMGenIntStatus (uint32_t ui32Base ,uint32_t ui32Gen , 289bool bMasked ); 290extern void PWMGenIntClear (uint32_t ui32Base ,uint32_t ui32Gen , 291uint32_t ui32Ints ); 292extern void PWMIntEnable (uint32_t ui32Base ,uint32_t ui32GenFault ); 293extern void PWMIntDisable (uint32_t ui32Base ,uint32_t ui32GenFault ); 294extern void PWMFaultIntClear (uint32_t ui32Base ); 295extern uint32_t PWMIntStatus (uint32_t ui32Base ,bool bMasked ); 296extern void PWMFaultIntClearExt (uint32_t ui32Base , 297uint32_t ui32FaultInts ); 298extern void PWMGenFaultConfigure (uint32_t ui32Base ,uint32_t ui32Gen , 299uint32_t ui32MinFaultPeriod , 300uint32_t ui32FaultSenses ); 301extern void PWMGenFaultTriggerSet (uint32_t ui32Base ,uint32_t ui32Gen , 302uint32_t ui32Group , 303uint32_t ui32FaultTriggers ); 304extern uint32_t PWMGenFaultTriggerGet (uint32_t ui32Base , 305uint32_t ui32Gen , 306uint32_t ui32Group ); 307extern uint32_t PWMGenFaultStatus (uint32_t ui32Base , 308uint32_t ui32Gen , 309uint32_t ui32Group ); 310extern void PWMGenFaultClear (uint32_t ui32Base ,uint32_t ui32Gen , 311uint32_t ui32Group , 312uint32_t ui32FaultTriggers ); 313extern void PWMClockSet (uint32_t ui32Base ,uint32_t ui32Config ); 314extern uint32_t PWMClockGet (uint32_t ui32Base ); 315extern void PWMOutputUpdateMode (uint32_t ui32Base , 316uint32_t ui32PWMOutBits , 317uint32_t ui32Mode ); 318 319//***************************************************************************** 320// 321// Mark the end of the C bindings section for C++ compilers. 322// 323//***************************************************************************** 324#ifdef __cplusplus 325} 326#endif 327 328#endif // __DRIVERLIB_PWM_H__