EE445M RTOS
Taken at the University of Texas Spring 2015
pwm.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // pwm.c - API for the PWM modules
4 //
5 // Copyright (c) 2005-2014 Texas Instruments Incorporated. All rights reserved.
6 // Software License Agreement
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions
10 // are met:
11 //
12 // Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright
16 // notice, this list of conditions and the following disclaimer in the
17 // documentation and/or other materials provided with the
18 // distribution.
19 //
20 // Neither the name of Texas Instruments Incorporated nor the names of
21 // its contributors may be used to endorse or promote products derived
22 // from this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 //
36 // This is part of revision 2.1.0.12573 of the Tiva Peripheral Driver Library.
37 //
38 //*****************************************************************************
39 
40 //*****************************************************************************
41 //
44 //
45 //*****************************************************************************
46 
47 #include <stdbool.h>
48 #include <stdint.h>
49 #include "inc/hw_ints.h"
50 #include "inc/hw_memmap.h"
51 #include "inc/hw_pwm.h"
52 #include "inc/hw_sysctl.h"
53 #include "inc/hw_types.h"
54 #include "driverlib/debug.h"
55 #include "driverlib/interrupt.h"
56 #include "driverlib/pwm.h"
57 
58 //*****************************************************************************
59 //
60 // Misc macros for manipulating the encoded generator and output defines used
61 // by the API.
62 //
63 //*****************************************************************************
64 #define PWM_GEN_BADDR(_mod_, _gen_) \
65  ((_mod_) + (_gen_))
66 #define PWM_GEN_EXT_BADDR(_mod_, _gen_) \
67  ((_mod_) + PWM_GEN_EXT_0 + \
68  ((_gen_) - PWM_GEN_0) * 2)
69 #define PWM_OUT_BADDR(_mod_, _out_) \
70  ((_mod_) + ((_out_) & 0xFFFFFFC0))
71 #define PWM_IS_OUTPUT_ODD(_out_) \
72  ((_out_) & 0x00000001)
73 
74 //*****************************************************************************
75 //
85 //
86 //*****************************************************************************
87 #ifdef DEBUG
88 static bool
89 _PWMGenValid(uint32_t ui32Gen)
90 {
91  return((ui32Gen == PWM_GEN_0) || (ui32Gen == PWM_GEN_1) ||
92  (ui32Gen == PWM_GEN_2) || (ui32Gen == PWM_GEN_3));
93 }
94 #endif
95 
96 //*****************************************************************************
97 //
107 //
108 //*****************************************************************************
109 #ifdef DEBUG
110 static bool
111 _PWMOutValid(uint32_t ui32PWMOut)
112 {
113  return((ui32PWMOut == PWM_OUT_0) || (ui32PWMOut == PWM_OUT_1) ||
114  (ui32PWMOut == PWM_OUT_2) || (ui32PWMOut == PWM_OUT_3) ||
115  (ui32PWMOut == PWM_OUT_4) || (ui32PWMOut == PWM_OUT_5) ||
116  (ui32PWMOut == PWM_OUT_6) || (ui32PWMOut == PWM_OUT_7));
117 }
118 #endif
119 
120 //*****************************************************************************
121 //
197 //
198 //*****************************************************************************
199 void
200 PWMGenConfigure(uint32_t ui32Base, uint32_t ui32Gen,
201  uint32_t ui32Config)
202 {
203  //
204  // Check the arguments.
205  //
206  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
207  ASSERT(_PWMGenValid(ui32Gen));
208 
209  //
210  // Compute the generator's base address.
211  //
212  ui32Gen = PWM_GEN_BADDR(ui32Base, ui32Gen);
213 
214  //
215  // Change the global configuration of the generator.
216  //
217  HWREG(ui32Gen + PWM_O_X_CTL) = ((HWREG(ui32Gen + PWM_O_X_CTL) &
227  PWM_X_CTL_CMPBUPD)) | ui32Config);
228 
229  //
230  // Set the individual PWM generator controls.
231  //
232  if(ui32Config & PWM_X_CTL_MODE)
233  {
234  //
235  // In up/down count mode, set the signal high on up count comparison
236  // and low on down count comparison (that is, center align the
237  // signals).
238  //
243  }
244  else
245  {
246  //
247  // In down count mode, set the signal high on load and low on count
248  // comparison (that is, left align the signals).
249  //
254  }
255 }
256 
257 //*****************************************************************************
258 //
275 //
276 //*****************************************************************************
277 void
278 PWMGenPeriodSet(uint32_t ui32Base, uint32_t ui32Gen,
279  uint32_t ui32Period)
280 {
281  //
282  // Check the arguments.
283  //
284  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
285  ASSERT(_PWMGenValid(ui32Gen));
286 
287  //
288  // Compute the generator's base address.
289  //
290  ui32Gen = PWM_GEN_BADDR(ui32Base, ui32Gen);
291 
292  //
293  // Set the reload register based on the mode.
294  //
295  if(HWREG(ui32Gen + PWM_O_X_CTL) & PWM_X_CTL_MODE)
296  {
297  //
298  // In up/down count mode, set the reload register to half the requested
299  // period.
300  //
301  ASSERT((ui32Period / 2) < 65536);
302  HWREG(ui32Gen + PWM_O_X_LOAD) = ui32Period / 2;
303  }
304  else
305  {
306  //
307  // In down count mode, set the reload register to the requested period
308  // minus one.
309  //
310  ASSERT((ui32Period <= 65536) && (ui32Period != 0));
311  HWREG(ui32Gen + PWM_O_X_LOAD) = ui32Period - 1;
312  }
313 }
314 
315 //*****************************************************************************
316 //
333 //
334 //*****************************************************************************
335 uint32_t
336 PWMGenPeriodGet(uint32_t ui32Base, uint32_t ui32Gen)
337 {
338  //
339  // Check the arguments.
340  //
341  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
342  ASSERT(_PWMGenValid(ui32Gen));
343 
344  //
345  // Compute the generator's base address.
346  //
347  ui32Gen = PWM_GEN_BADDR(ui32Base, ui32Gen);
348 
349  //
350  // Figure out the counter mode.
351  //
352  if(HWREG(ui32Gen + PWM_O_X_CTL) & PWM_X_CTL_MODE)
353  {
354  //
355  // The period is twice the reload register value.
356  //
357  return(HWREG(ui32Gen + PWM_O_X_LOAD) * 2);
358  }
359  else
360  {
361  //
362  // The period is the reload register value plus one.
363  //
364  return(HWREG(ui32Gen + PWM_O_X_LOAD) + 1);
365  }
366 }
367 
368 //*****************************************************************************
369 //
380 //
381 //*****************************************************************************
382 void
383 PWMGenEnable(uint32_t ui32Base, uint32_t ui32Gen)
384 {
385  //
386  // Check the arguments.
387  //
388  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
389  ASSERT(_PWMGenValid(ui32Gen));
390 
391  //
392  // Enable the PWM generator.
393  //
394  HWREG(PWM_GEN_BADDR(ui32Base, ui32Gen) + PWM_O_X_CTL) |= PWM_X_CTL_ENABLE;
395 }
396 
397 //*****************************************************************************
398 //
409 //
410 //*****************************************************************************
411 void
412 PWMGenDisable(uint32_t ui32Base, uint32_t ui32Gen)
413 {
414  //
415  // Check the arguments.
416  //
417  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
418  ASSERT(_PWMGenValid(ui32Gen));
419 
420  //
421  // Disable the PWM generator.
422  //
423  HWREG(PWM_GEN_BADDR(ui32Base, ui32Gen) + PWM_O_X_CTL) &=
424  ~(PWM_X_CTL_ENABLE);
425 }
426 
427 //*****************************************************************************
428 //
444 //
445 //*****************************************************************************
446 void
447 PWMPulseWidthSet(uint32_t ui32Base, uint32_t ui32PWMOut,
448  uint32_t ui32Width)
449 {
450  uint32_t ui32GenBase, ui32Reg;
451 
452  //
453  // Check the arguments.
454  //
455  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
456  ASSERT(_PWMOutValid(ui32PWMOut));
457 
458  //
459  // Compute the generator's base address.
460  //
461  ui32GenBase = PWM_OUT_BADDR(ui32Base, ui32PWMOut);
462 
463  //
464  // If the counter is in up/down count mode, divide the width by two.
465  //
466  if(HWREG(ui32GenBase + PWM_O_X_CTL) & PWM_X_CTL_MODE)
467  {
468  ui32Width /= 2;
469  }
470 
471  //
472  // Get the period.
473  //
474  ui32Reg = HWREG(ui32GenBase + PWM_O_X_LOAD);
475 
476  //
477  // Make sure the width is not too large.
478  //
479  ASSERT(ui32Width < ui32Reg);
480 
481  //
482  // Compute the compare value.
483  //
484  ui32Reg = ui32Reg - ui32Width;
485 
486  //
487  // Write to the appropriate registers.
488  //
489  if(PWM_IS_OUTPUT_ODD(ui32PWMOut))
490  {
491  HWREG(ui32GenBase + PWM_O_X_CMPB) = ui32Reg;
492  }
493  else
494  {
495  HWREG(ui32GenBase + PWM_O_X_CMPA) = ui32Reg;
496  }
497 }
498 
499 //*****************************************************************************
500 //
515 //
516 //*****************************************************************************
517 uint32_t
518 PWMPulseWidthGet(uint32_t ui32Base, uint32_t ui32PWMOut)
519 {
520  uint32_t ui32GenBase, ui32Reg, ui32Load;
521 
522  //
523  // Check the arguments.
524  //
525  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
526  ASSERT(_PWMOutValid(ui32PWMOut));
527 
528  //
529  // Compute the generator's base address.
530  //
531  ui32GenBase = PWM_OUT_BADDR(ui32Base, ui32PWMOut);
532 
533  //
534  // Then compute the pulse width. If mode is UpDown, set
535  // width = (load - compare) * 2. Otherwise, set width = load - compare.
536  //
537  ui32Load = HWREG(ui32GenBase + PWM_O_X_LOAD);
538  if(PWM_IS_OUTPUT_ODD(ui32PWMOut))
539  {
540  ui32Reg = HWREG(ui32GenBase + PWM_O_X_CMPB);
541  }
542  else
543  {
544  ui32Reg = HWREG(ui32GenBase + PWM_O_X_CMPA);
545  }
546  ui32Reg = ui32Load - ui32Reg;
547 
548  //
549  // If in up/down count mode, double the pulse width.
550  //
551  if(HWREG(ui32GenBase + PWM_O_X_CTL) & PWM_X_CTL_MODE)
552  {
553  ui32Reg = ui32Reg * 2;
554  }
555 
556  //
557  // Return the pulse width.
558  //
559  return(ui32Reg);
560 }
561 
562 //*****************************************************************************
563 //
578 //
579 //*****************************************************************************
580 void
581 PWMDeadBandEnable(uint32_t ui32Base, uint32_t ui32Gen,
582  uint16_t ui16Rise, uint16_t ui16Fall)
583 {
584  //
585  // Check the arguments.
586  //
587  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
588  ASSERT(_PWMGenValid(ui32Gen));
589  ASSERT(ui16Rise < 4096);
590  ASSERT(ui16Fall < 4096);
591 
592  //
593  // Compute the generator's base address.
594  //
595  ui32Gen = PWM_GEN_BADDR(ui32Base, ui32Gen);
596 
597  //
598  // Write the dead band delay values.
599  //
600  HWREG(ui32Gen + PWM_O_X_DBRISE) = ui16Rise;
601  HWREG(ui32Gen + PWM_O_X_DBFALL) = ui16Fall;
602 
603  //
604  // Enable the deadband functionality.
605  //
606  HWREG(ui32Gen + PWM_O_X_DBCTL) |= PWM_X_DBCTL_ENABLE;
607 }
608 
609 //*****************************************************************************
610 //
621 //
622 //*****************************************************************************
623 void
624 PWMDeadBandDisable(uint32_t ui32Base, uint32_t ui32Gen)
625 {
626  //
627  // Check the arguments.
628  //
629  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
630  ASSERT(_PWMGenValid(ui32Gen));
631 
632  //
633  // Disable the deadband functionality.
634  //
635  HWREG(PWM_GEN_BADDR(ui32Base, ui32Gen) + PWM_O_X_DBCTL) &=
637 }
638 
639 //*****************************************************************************
640 //
653 //
654 //*****************************************************************************
655 void
656 PWMSyncUpdate(uint32_t ui32Base, uint32_t ui32GenBits)
657 {
658  //
659  // Check the arguments.
660  //
661  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
662  ASSERT(!(ui32GenBits & ~(PWM_GEN_0_BIT | PWM_GEN_1_BIT | PWM_GEN_2_BIT |
663  PWM_GEN_3_BIT)));
664 
665  //
666  // Synchronize pending PWM register changes.
667  //
668  HWREG(ui32Base + PWM_O_CTL) = ui32GenBits;
669 }
670 
671 //*****************************************************************************
672 //
685 //
686 //*****************************************************************************
687 void
688 PWMSyncTimeBase(uint32_t ui32Base, uint32_t ui32GenBits)
689 {
690  //
691  // Check the arguments.
692  //
693  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
694  ASSERT(!(ui32GenBits & ~(PWM_GEN_0_BIT | PWM_GEN_1_BIT | PWM_GEN_2_BIT |
695  PWM_GEN_3_BIT)));
696 
697  //
698  // Synchronize the counters in the specified generators by writing to the
699  // module's synchronization register.
700  //
701  HWREG(ui32Base + PWM_O_SYNC) = ui32GenBits;
702 }
703 
704 //*****************************************************************************
705 //
723 //
724 //*****************************************************************************
725 void
726 PWMOutputState(uint32_t ui32Base, uint32_t ui32PWMOutBits,
727  bool bEnable)
728 {
729  //
730  // Check the arguments.
731  //
732  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
733  ASSERT(!(ui32PWMOutBits & ~(PWM_OUT_0_BIT | PWM_OUT_1_BIT | PWM_OUT_2_BIT |
736 
737  //
738  // Read the module's ENABLE output control register and set or clear the
739  // requested bits.
740  //
741  if(bEnable == true)
742  {
743  HWREG(ui32Base + PWM_O_ENABLE) |= ui32PWMOutBits;
744  }
745  else
746  {
747  HWREG(ui32Base + PWM_O_ENABLE) &= ~(ui32PWMOutBits);
748  }
749 }
750 
751 //*****************************************************************************
752 //
771 //
772 //*****************************************************************************
773 void
774 PWMOutputInvert(uint32_t ui32Base, uint32_t ui32PWMOutBits,
775  bool bInvert)
776 {
777  //
778  // Check the arguments.
779  //
780  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
781  ASSERT(!(ui32PWMOutBits & ~(PWM_OUT_0_BIT | PWM_OUT_1_BIT | PWM_OUT_2_BIT |
784 
785  //
786  // Read the module's INVERT output control register and set or clear the
787  // requested bits.
788  //
789  if(bInvert == true)
790  {
791  HWREG(ui32Base + PWM_O_INVERT) |= ui32PWMOutBits;
792  }
793  else
794  {
795  HWREG(ui32Base + PWM_O_INVERT) &= ~(ui32PWMOutBits);
796  }
797 }
798 
799 //*****************************************************************************
800 //
827 //
828 //*****************************************************************************
829 void
830 PWMOutputFaultLevel(uint32_t ui32Base, uint32_t ui32PWMOutBits,
831  bool bDriveHigh)
832 {
833  //
834  // Check the arguments.
835  //
836  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
837  ASSERT(!(ui32PWMOutBits & ~(PWM_OUT_0_BIT | PWM_OUT_1_BIT | PWM_OUT_2_BIT |
840 
841  //
842  // Read the module's FAULT output control register and set or clear the
843  // requested bits.
844  //
845  if(bDriveHigh == true)
846  {
847  HWREG(ui32Base + PWM_O_FAULTVAL) |= ui32PWMOutBits;
848  }
849  else
850  {
851  HWREG(ui32Base + PWM_O_FAULTVAL) &= ~(ui32PWMOutBits);
852  }
853 }
854 
855 //*****************************************************************************
856 //
880 //
881 //*****************************************************************************
882 void
883 PWMOutputFault(uint32_t ui32Base, uint32_t ui32PWMOutBits,
884  bool bFaultSuppress)
885 {
886  //
887  // Check the arguments.
888  //
889  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
890  ASSERT(!(ui32PWMOutBits & ~(PWM_OUT_0_BIT | PWM_OUT_1_BIT | PWM_OUT_2_BIT |
893 
894  //
895  // Read the module's FAULT output control register and set or clear the
896  // requested bits.
897  //
898  if(bFaultSuppress == true)
899  {
900  HWREG(ui32Base + PWM_O_FAULT) |= ui32PWMOutBits;
901  }
902  else
903  {
904  HWREG(ui32Base + PWM_O_FAULT) &= ~(ui32PWMOutBits);
905  }
906 }
907 
908 //*****************************************************************************
909 //
920 //
921 //*****************************************************************************
922 static uint32_t
923 _PWMGenIntNumberGet(uint32_t ui32Base, uint32_t ui32Gen)
924 {
925  //
926  // Determine the generator and PWM module in question.
927  //
928  switch(ui32Base + ui32Gen)
929  {
930  //
931  // The first PWM generator in the first PWM module.
932  //
933  case PWM0_BASE + PWM_GEN_0:
934  {
935  if(CLASS_IS_TM4C123)
936  {
937  return(INT_PWM0_0_TM4C123);
938  }
939  else if(CLASS_IS_TM4C129)
940  {
941  return(INT_PWM0_0_TM4C129);
942  }
943  else
944  {
945  return(0);
946  }
947  }
948 
949  //
950  // The second PWM generator in the first PWM module.
951  //
952  case PWM0_BASE + PWM_GEN_1:
953  {
954  if(CLASS_IS_TM4C129)
955  {
956  return(INT_PWM0_1_TM4C129);
957  }
958  else
959  {
960  return(0);
961  }
962  }
963 
964  //
965  // The third PWM generator in the first PWM module.
966  //
967  case PWM0_BASE + PWM_GEN_2:
968  {
969  if(CLASS_IS_TM4C129)
970  {
971  return(INT_PWM0_2_TM4C129);
972  }
973  else
974  {
975  return(0);
976  }
977  }
978 
979  //
980  // The fourth PWM generator in the first PWM module.
981  //
982  case PWM0_BASE + PWM_GEN_3:
983  {
984  if(CLASS_IS_TM4C129)
985  {
986  return(INT_PWM0_3_TM4C129);
987  }
988  else
989  {
990  return(0);
991  }
992  }
993 
994  //
995  // The first PWM generator in the second PWM module.
996  //
997  case PWM1_BASE + PWM_GEN_0:
998  {
999  if(CLASS_IS_TM4C123)
1000  {
1001  return(INT_PWM1_0_TM4C123);
1002  }
1003  else
1004  {
1005  return(0);
1006  }
1007  }
1008 
1009  //
1010  // The first PWM generator in the second PWM module.
1011  //
1012  case PWM1_BASE + PWM_GEN_1:
1013  {
1014  if(CLASS_IS_TM4C123)
1015  {
1016  return(INT_PWM1_1_TM4C123);
1017  }
1018  else
1019  {
1020  return(0);
1021  }
1022  }
1023 
1024  //
1025  // The first PWM generator in the second PWM module.
1026  //
1027  case PWM1_BASE + PWM_GEN_2:
1028  {
1029  if(CLASS_IS_TM4C123)
1030  {
1031  return(INT_PWM1_2_TM4C123);
1032  }
1033  else
1034  {
1035  return(0);
1036  }
1037  }
1038 
1039  //
1040  // The first PWM generator in the second PWM module.
1041  //
1042  case PWM1_BASE + PWM_GEN_3:
1043  {
1044  if(CLASS_IS_TM4C123)
1045  {
1046  return(INT_PWM1_3_TM4C123);
1047  }
1048  else
1049  {
1050  return(0);
1051  }
1052  }
1053 
1054  //
1055  // An unknown PWM module/generator was specified.
1056  //
1057  default:
1058  {
1059  return(0);
1060  }
1061  }
1062 }
1063 
1064 //*****************************************************************************
1065 //
1085 //
1086 //*****************************************************************************
1087 void
1088 PWMGenIntRegister(uint32_t ui32Base, uint32_t ui32Gen,
1089  void (*pfnIntHandler)(void))
1090 {
1091  uint32_t ui32Int;
1092 
1093  //
1094  // Check the arguments.
1095  //
1096  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1097  ASSERT(_PWMGenValid(ui32Gen));
1098 
1099  //
1100  // Get the interrupt number associated with the specified generator.
1101  //
1102  ui32Int = _PWMGenIntNumberGet(ui32Base, ui32Gen);
1103 
1104  ASSERT(ui32Int != 0);
1105 
1106  //
1107  // Register the interrupt handler.
1108  //
1109  IntRegister(ui32Int, pfnIntHandler);
1110 
1111  //
1112  // Enable the PWMx interrupt.
1113  //
1114  IntEnable(ui32Int);
1115 }
1116 
1117 //*****************************************************************************
1118 //
1135 //
1136 //*****************************************************************************
1137 void
1138 PWMGenIntUnregister(uint32_t ui32Base, uint32_t ui32Gen)
1139 {
1140  uint32_t ui32Int;
1141 
1142  //
1143  // Check the arguments.
1144  //
1145  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1146  ASSERT(_PWMGenValid(ui32Gen));
1147 
1148  //
1149  // Get the interrupt number associated with the specified generator.
1150  //
1151  ui32Int = _PWMGenIntNumberGet(ui32Base, ui32Gen);
1152 
1153  ASSERT(ui32Int != 0);
1154 
1155  //
1156  // Disable the PWMx interrupt.
1157  //
1158  IntDisable(ui32Int);
1159 
1160  //
1161  // Unregister the interrupt handler.
1162  //
1163  IntUnregister(ui32Int);
1164 }
1165 
1166 //*****************************************************************************
1167 //
1176 //
1177 //*****************************************************************************
1178 static uint32_t
1179 _PWMFaultIntNumberGet(uint32_t ui32Base)
1180 {
1181  //
1182  // Return the fault interrupt number.
1183  //
1184  if(CLASS_IS_TM4C123)
1185  {
1186  return((ui32Base == PWM0_BASE) ? INT_PWM0_FAULT_TM4C123 :
1188  }
1189  else if(CLASS_IS_TM4C129)
1190  {
1191  return((ui32Base == PWM0_BASE) ? INT_PWM0_FAULT_TM4C129 : 0);
1192  }
1193  else
1194  {
1195  return(0);
1196  }
1197 }
1198 
1199 //*****************************************************************************
1200 //
1218 //
1219 //*****************************************************************************
1220 void
1221 PWMFaultIntRegister(uint32_t ui32Base, void (*pfnIntHandler)(void))
1222 {
1223  uint32_t ui32Int;
1224 
1225  //
1226  // Check the arguments.
1227  //
1228  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1229 
1230  //
1231  // Get the interrupt number associated with the specified module.
1232  //
1233  ui32Int = _PWMFaultIntNumberGet(ui32Base);
1234 
1235  ASSERT(ui32Int != 0);
1236 
1237  //
1238  // Register the interrupt handler, returning an error if one occurs.
1239  //
1240  IntRegister(ui32Int, pfnIntHandler);
1241 
1242  //
1243  // Enable the PWM fault interrupt.
1244  //
1245  IntEnable(ui32Int);
1246 }
1247 
1248 //*****************************************************************************
1249 //
1263 //
1264 //*****************************************************************************
1265 void
1266 PWMFaultIntUnregister(uint32_t ui32Base)
1267 {
1268  uint32_t ui32Int;
1269 
1270  //
1271  // Check the arguments.
1272  //
1273  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1274 
1275  //
1276  // Get the interrupt number associated with the specified module.
1277  //
1278  ui32Int = _PWMFaultIntNumberGet(ui32Base);
1279 
1280  ASSERT(ui32Int != 0);
1281 
1282  //
1283  // Disable the PWM fault interrupt.
1284  //
1285  IntDisable(ui32Int);
1286 
1287  //
1288  // Unregister the interrupt handler, returning an error if one occurs.
1289  //
1290  IntUnregister(ui32Int);
1291 }
1292 
1293 //*****************************************************************************
1294 //
1312 //
1313 //*****************************************************************************
1314 void
1315 PWMGenIntTrigEnable(uint32_t ui32Base, uint32_t ui32Gen,
1316  uint32_t ui32IntTrig)
1317 {
1318  //
1319  // Check the arguments.
1320  //
1321  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1322  ASSERT(_PWMGenValid(ui32Gen));
1323  ASSERT((ui32IntTrig & ~(PWM_INT_CNT_ZERO | PWM_INT_CNT_LOAD |
1327  PWM_TR_CNT_BU | PWM_TR_CNT_BD)) == 0);
1328 
1329  //
1330  // Enable the specified interrupts/triggers.
1331  //
1332  HWREG(PWM_GEN_BADDR(ui32Base, ui32Gen) + PWM_O_X_INTEN) |= ui32IntTrig;
1333 }
1334 
1335 //*****************************************************************************
1336 //
1354 //
1355 //*****************************************************************************
1356 void
1357 PWMGenIntTrigDisable(uint32_t ui32Base, uint32_t ui32Gen,
1358  uint32_t ui32IntTrig)
1359 {
1360  //
1361  // Check the arguments.
1362  //
1363  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1364  ASSERT(_PWMGenValid(ui32Gen));
1365  ASSERT((ui32IntTrig & ~(PWM_INT_CNT_ZERO | PWM_INT_CNT_LOAD |
1369  PWM_TR_CNT_BU | PWM_TR_CNT_BD)) == 0);
1370 
1371  //
1372  // Disable the specified interrupts/triggers.
1373  //
1374  HWREG(PWM_GEN_BADDR(ui32Base, ui32Gen) + PWM_O_X_INTEN) &= ~(ui32IntTrig);
1375 }
1376 
1377 //*****************************************************************************
1378 //
1393 //
1394 //*****************************************************************************
1395 uint32_t
1396 PWMGenIntStatus(uint32_t ui32Base, uint32_t ui32Gen, bool bMasked)
1397 {
1398  //
1399  // Check the arguments.
1400  //
1401  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1402  ASSERT(_PWMGenValid(ui32Gen));
1403 
1404  //
1405  // Compute the generator's base address.
1406  //
1407  ui32Gen = PWM_GEN_BADDR(ui32Base, ui32Gen);
1408 
1409  //
1410  // Read and return the specified generator's raw or enabled interrupt
1411  // status.
1412  //
1413  if(bMasked == true)
1414  {
1415  return(HWREG(ui32Gen + PWM_O_X_ISC));
1416  }
1417  else
1418  {
1419  return(HWREG(ui32Gen + PWM_O_X_RIS));
1420  }
1421 }
1422 
1423 //*****************************************************************************
1424 //
1448 //
1449 //*****************************************************************************
1450 void
1451 PWMGenIntClear(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Ints)
1452 {
1453  //
1454  // Check the arguments.
1455  //
1456  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1457  ASSERT(_PWMGenValid(ui32Gen));
1458  ASSERT((ui32Ints &
1461 
1462  //
1463  // Clear the requested interrupts by writing ones to the specified bit
1464  // of the module's interrupt enable register.
1465  //
1466  HWREG(PWM_GEN_BADDR(ui32Base, ui32Gen) + PWM_O_X_ISC) = ui32Ints;
1467 }
1468 
1469 //*****************************************************************************
1470 //
1483 //
1484 //*****************************************************************************
1485 void
1486 PWMIntEnable(uint32_t ui32Base, uint32_t ui32GenFault)
1487 {
1488  //
1489  // Check the arguments.
1490  //
1491  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1492  ASSERT((ui32GenFault & ~(PWM_INT_GEN_0 | PWM_INT_GEN_1 | PWM_INT_GEN_2 |
1494  PWM_INT_FAULT2 | PWM_INT_FAULT3)) == 0);
1495 
1496  //
1497  // Read the module's interrupt enable register and enable interrupts
1498  // for the specified PWM generators.
1499  //
1500  HWREG(ui32Base + PWM_O_INTEN) |= ui32GenFault;
1501 }
1502 
1503 //*****************************************************************************
1504 //
1517 //
1518 //*****************************************************************************
1519 void
1520 PWMIntDisable(uint32_t ui32Base, uint32_t ui32GenFault)
1521 {
1522  //
1523  // Check the arguments.
1524  //
1525  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1526  ASSERT((ui32GenFault & ~(PWM_INT_GEN_0 | PWM_INT_GEN_1 | PWM_INT_GEN_2 |
1528  PWM_INT_FAULT2 | PWM_INT_FAULT3)) == 0);
1529 
1530  //
1531  // Read the module's interrupt enable register and disable interrupts
1532  // for the specified PWM generators.
1533  //
1534  HWREG(ui32Base + PWM_O_INTEN) &= ~(ui32GenFault);
1535 }
1536 
1537 //*****************************************************************************
1538 //
1561 //
1562 //*****************************************************************************
1563 void
1564 PWMFaultIntClear(uint32_t ui32Base)
1565 {
1566  //
1567  // Check the arguments.
1568  //
1569  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1570 
1571  //
1572  // Write the only writeable bit in the module's interrupt register.
1573  //
1574  HWREG(ui32Base + PWM_O_ISC) = PWM_ISC_INTFAULT0;
1575 }
1576 
1577 //*****************************************************************************
1578 //
1593 //*****************************************************************************
1594 uint32_t
1595 PWMIntStatus(uint32_t ui32Base, bool bMasked)
1596 {
1597  //
1598  // Check the arguments.
1599  //
1600  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1601 
1602  //
1603  // Read and return either the module's raw or enabled interrupt status.
1604  //
1605  if(bMasked == true)
1606  {
1607  return(HWREG(ui32Base + PWM_O_ISC));
1608  }
1609  else
1610  {
1611  return(HWREG(ui32Base + PWM_O_RIS));
1612  }
1613 }
1614 
1615 //*****************************************************************************
1616 //
1643 //
1644 //*****************************************************************************
1645 void
1646 PWMFaultIntClearExt(uint32_t ui32Base, uint32_t ui32FaultInts)
1647 {
1648  //
1649  // Check the arguments.
1650  //
1651  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1652  ASSERT((ui32FaultInts & ~(PWM_INT_FAULT0 | PWM_INT_FAULT1 |
1653  PWM_INT_FAULT2 | PWM_INT_FAULT3)) == 0);
1654 
1655  //
1656  // Clear the supplied fault bits.
1657  //
1658  HWREG(ui32Base + PWM_O_ISC) = ui32FaultInts;
1659 }
1660 
1661 //*****************************************************************************
1662 //
1688 //
1689 //*****************************************************************************
1690 void
1691 PWMGenFaultConfigure(uint32_t ui32Base, uint32_t ui32Gen,
1692  uint32_t ui32MinFaultPeriod,
1693  uint32_t ui32FaultSenses)
1694 {
1695  //
1696  // Check the arguments.
1697  //
1698  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1699  ASSERT(_PWMGenValid(ui32Gen));
1700  ASSERT(ui32MinFaultPeriod < PWM_X_MINFLTPER_M);
1701  ASSERT((ui32FaultSenses & ~(PWM_FAULT0_SENSE_HIGH | PWM_FAULT0_SENSE_LOW |
1705  PWM_FAULT3_SENSE_LOW)) == 0);
1706 
1707  //
1708  // Write the minimum fault period.
1709  //
1710  HWREG(PWM_GEN_BADDR(ui32Base, ui32Gen) + PWM_O_X_MINFLTPER) =
1711  ui32MinFaultPeriod;
1712 
1713  //
1714  // Write the fault senses.
1715  //
1716  HWREG(PWM_GEN_EXT_BADDR(ui32Base, ui32Gen) + PWM_O_X_FLTSEN) =
1717  ui32FaultSenses;
1718 }
1719 
1720 //*****************************************************************************
1721 //
1756 //
1757 //*****************************************************************************
1758 void
1759 PWMGenFaultTriggerSet(uint32_t ui32Base, uint32_t ui32Gen,
1760  uint32_t ui32Group, uint32_t ui32FaultTriggers)
1761 {
1762  //
1763  // Check for valid parameters.
1764  //
1765  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1766  ASSERT(_PWMGenValid(ui32Gen));
1767  ASSERT((ui32Group == PWM_FAULT_GROUP_0) ||
1768  (ui32Group == PWM_FAULT_GROUP_1));
1769  ASSERT((ui32Group == PWM_FAULT_GROUP_0) &&
1770  ((ui32FaultTriggers & ~(PWM_FAULT_FAULT0 | PWM_FAULT_FAULT1 |
1772  0));
1773  ASSERT((ui32Group == PWM_FAULT_GROUP_1) &&
1774  ((ui32FaultTriggers & ~(PWM_FAULT_DCMP0 | PWM_FAULT_DCMP1 |
1777  PWM_FAULT_DCMP6 | PWM_FAULT_DCMP7)) == 0));
1778 
1779  //
1780  // Write the fault triggers to the appropriate register.
1781  //
1782  if(ui32Group == PWM_FAULT_GROUP_0)
1783  {
1784  HWREG(PWM_GEN_BADDR(ui32Base, ui32Gen) + PWM_O_X_FLTSRC0) =
1785  ui32FaultTriggers;
1786  }
1787  else
1788  {
1789  HWREG(PWM_GEN_BADDR(ui32Base, ui32Gen) + PWM_O_X_FLTSRC1) =
1790  ui32FaultTriggers;
1791  }
1792 }
1793 
1794 //*****************************************************************************
1795 //
1819 //
1820 //*****************************************************************************
1821 uint32_t
1822 PWMGenFaultTriggerGet(uint32_t ui32Base, uint32_t ui32Gen,
1823  uint32_t ui32Group)
1824 {
1825  //
1826  // Check for valid parameters.
1827  //
1828  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1829  ASSERT(_PWMGenValid(ui32Gen));
1830  ASSERT((ui32Group == PWM_FAULT_GROUP_0) ||
1831  (ui32Group == PWM_FAULT_GROUP_1));
1832 
1833  //
1834  // Return the current fault triggers.
1835  //
1836  if(ui32Group == PWM_FAULT_GROUP_0)
1837  {
1838  return(HWREG(PWM_GEN_BADDR(ui32Base, ui32Gen) + PWM_O_X_FLTSRC0));
1839  }
1840  else
1841  {
1842  return(HWREG(PWM_GEN_BADDR(ui32Base, ui32Gen) + PWM_O_X_FLTSRC1));
1843  }
1844 }
1845 
1846 //*****************************************************************************
1847 //
1878 //
1879 //*****************************************************************************
1880 uint32_t
1881 PWMGenFaultStatus(uint32_t ui32Base, uint32_t ui32Gen,
1882  uint32_t ui32Group)
1883 {
1884  //
1885  // Check for valid parameters.
1886  //
1887  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1888  ASSERT(_PWMGenValid(ui32Gen));
1889  ASSERT((ui32Group == PWM_FAULT_GROUP_0) ||
1890  (ui32Group == PWM_FAULT_GROUP_1));
1891 
1892  //
1893  // Return the current fault status.
1894  //
1895  if(ui32Group == PWM_FAULT_GROUP_0)
1896  {
1897  return(HWREG(PWM_GEN_EXT_BADDR(ui32Base, ui32Gen) + PWM_O_X_FLTSTAT0));
1898  }
1899  else
1900  {
1901  return(HWREG(PWM_GEN_EXT_BADDR(ui32Base, ui32Gen) + PWM_O_X_FLTSTAT1));
1902  }
1903 }
1904 
1905 //*****************************************************************************
1906 //
1927 //
1928 //*****************************************************************************
1929 void
1930 PWMGenFaultClear(uint32_t ui32Base, uint32_t ui32Gen,
1931  uint32_t ui32Group, uint32_t ui32FaultTriggers)
1932 {
1933  //
1934  // Check for valid parameters.
1935  //
1936  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1937  ASSERT(_PWMGenValid(ui32Gen));
1938  ASSERT((ui32Group == PWM_FAULT_GROUP_0) ||
1939  (ui32Group == PWM_FAULT_GROUP_1));
1940  ASSERT((ui32Group == PWM_FAULT_GROUP_0) &&
1941  ((ui32FaultTriggers & ~(PWM_FAULT_FAULT0 | PWM_FAULT_FAULT1 |
1943  0));
1944  ASSERT((ui32Group == PWM_FAULT_GROUP_1) &&
1945  ((ui32FaultTriggers & ~(PWM_FAULT_DCMP0 | PWM_FAULT_DCMP1 |
1948  PWM_FAULT_DCMP6 | PWM_FAULT_DCMP7)) == 0));
1949 
1950  //
1951  // Clear the given faults.
1952  //
1953  if(ui32Group == PWM_FAULT_GROUP_0)
1954  {
1955  HWREG(PWM_GEN_EXT_BADDR(ui32Base, ui32Gen) + PWM_O_X_FLTSTAT0) =
1956  ui32FaultTriggers;
1957  }
1958  else
1959  {
1960  HWREG(PWM_GEN_EXT_BADDR(ui32Base, ui32Gen) + PWM_O_X_FLTSTAT1) =
1961  ui32FaultTriggers;
1962  }
1963 }
1964 
1965 //*****************************************************************************
1987 //
1988 //*****************************************************************************
1989 void
1990 PWMClockSet(uint32_t ui32Base, uint32_t ui32Config)
1991 {
1992  //
1993  // Check the arguments.
1994  //
1995  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
1996  ASSERT((ui32Config == PWM_SYSCLK_DIV_2) ||
1997  (ui32Config == PWM_SYSCLK_DIV_4) ||
1998  (ui32Config == PWM_SYSCLK_DIV_8) ||
1999  (ui32Config == PWM_SYSCLK_DIV_16) ||
2000  (ui32Config == PWM_SYSCLK_DIV_32) ||
2001  (ui32Config == PWM_SYSCLK_DIV_64));
2002 
2003  //
2004  // Set the PWM clock configuration into the PWM clock configuration
2005  // register.
2006  //
2007  HWREG(ui32Base + PWM_O_CC) = ((HWREG(ui32Base + PWM_O_CC) &
2009  ui32Config);
2010 }
2011 
2012 //*****************************************************************************
2013 //
2027 //
2028 //*****************************************************************************
2029 uint32_t
2030 PWMClockGet(uint32_t ui32Base)
2031 {
2032  //
2033  // Check the arguments.
2034  //
2035  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
2036 
2037  //
2038  // Return the current PWM clock configuration. Make sure that
2039  // PWM_SYSCLK_DIV_1 is returned in all cases where the divider is disabled.
2040  //
2041  if(!(HWREG(ui32Base + PWM_O_CC) & PWM_CC_USEPWM))
2042  {
2043  //
2044  // The divider is not active so reflect this in the value we return.
2045  //
2046  return(PWM_SYSCLK_DIV_1);
2047  }
2048  else
2049  {
2050  //
2051  // The divider is active so directly return the masked register value.
2052  //
2053  return(HWREG(ui32Base + PWM_O_CC) & (PWM_CC_USEPWM | PWM_CC_PWMDIV_M));
2054  }
2055 }
2056 
2057 //*****************************************************************************
2058 //
2085 //
2086 //*****************************************************************************
2087 void
2088 PWMOutputUpdateMode(uint32_t ui32Base, uint32_t ui32PWMOutBits,
2089  uint32_t ui32Mode)
2090 {
2091  uint_fast8_t ui8Index;
2092  uint32_t ui32PWMOutputMask;
2093  uint32_t ui32UpdateValueMask;
2094  uint32_t ui32UpdateValue;
2095  uint32_t ui32Temp;
2096 
2097  //
2098  // Check the arguments.
2099  //
2100  ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE));
2101  ASSERT(!(ui32PWMOutBits & ~(PWM_OUT_0_BIT | PWM_OUT_1_BIT | PWM_OUT_2_BIT |
2104  ASSERT((ui32Mode == PWM_OUTPUT_MODE_NO_SYNC) ||
2105  (ui32Mode == PWM_OUTPUT_MODE_SYNC_LOCAL) ||
2106  (ui32Mode == PWM_OUTPUT_MODE_SYNC_GLOBAL));
2107 
2108  //
2109  // Initialize the local variables
2110  //
2111  ui8Index = 0;
2112  ui32PWMOutputMask = 1;
2113  ui32UpdateValue = 0;
2114  ui32UpdateValueMask = 0;
2115 
2116  //
2117  // Loop to find out which PWM outputs are to be modified.
2118  //
2119  while(ui8Index < 8)
2120  {
2121  //
2122  // Check if this PWM output is to be modified.
2123  //
2124  if(ui32PWMOutputMask & ui32PWMOutBits)
2125  {
2126  //
2127  // Set the update mode value for the requested PWM output by
2128  // writing to the appropriate field.
2129  //
2130  ui32UpdateValue |= ui32Mode << (ui8Index * 2);
2131 
2132  //
2133  // Compute the mask for the bits to be updated.
2134  //
2135  ui32UpdateValueMask |= 3 << (ui8Index * 2);
2136  }
2137 
2138  //
2139  // Update the PWM output to be checked and the index.
2140  //
2141  ui32PWMOutputMask = ui32PWMOutputMask << 1;
2142  ui8Index++;
2143  }
2144 
2145  //
2146  // Read the Enable Update register and mask the bits that are to be
2147  // updated.
2148  //
2149  ui32Temp = ~ui32UpdateValueMask & HWREG(ui32Base + PWM_O_ENUPD);
2150 
2151  //
2152  // Write the updated values to Enable Update register.
2153  //
2154  HWREG(ui32Base + PWM_O_ENUPD) = ui32Temp | ui32UpdateValue;
2155 }
2156 
2157 //*****************************************************************************
2158 //
2159 // Close the Doxygen group.
2161 //
2162 //*****************************************************************************
#define PWM_FAULT_DCMP5
Definition: pwm.h:201
#define PWM_O_INVERT
Definition: hw_pwm.h:51
#define PWM1_BASE
Definition: hw_memmap.h:78
#define PWM_X_CTL_LOADUPD
Definition: hw_pwm.h:1603
uint32_t PWMPulseWidthGet(uint32_t ui32Base, uint32_t ui32PWMOut)
Definition: pwm.c:518
#define PWM_GEN_0_BIT
Definition: pwm.h:139
#define PWM_O_X_DBCTL
Definition: hw_pwm.h:1562
#define PWM_TR_CNT_LOAD
Definition: pwm.h:108
#define PWM_X_CTL_FLTSRC
Definition: hw_pwm.h:1580
#define PWM_OUT_4_BIT
Definition: pwm.h:167
#define PWM_OUT_6_BIT
Definition: pwm.h:169
#define PWM_INT_CNT_LOAD
Definition: pwm.h:102
#define PWM_INT_CNT_AU
Definition: pwm.h:103
#define INT_PWM0_FAULT_TM4C123
Definition: hw_ints.h:73
#define PWM_INT_GEN_1
Definition: pwm.h:120
#define PWM_SYSCLK_DIV_2
Definition: pwm.h:226
#define INT_PWM0_2_TM4C129
Definition: hw_ints.h:188
#define PWM_X_CTL_DBCTLUPD_M
Definition: hw_pwm.h:1589
#define PWM_FAULT_DCMP4
Definition: pwm.h:200
#define PWM_GEN_2
Definition: pwm.h:136
#define PWM_GEN_BADDR(_mod_, _gen_)
Definition: pwm.c:64
#define PWM_GEN_0
Definition: pwm.h:134
void PWMGenFaultClear(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Group, uint32_t ui32FaultTriggers)
Definition: pwm.c:1930
void PWMGenIntUnregister(uint32_t ui32Base, uint32_t ui32Gen)
Definition: pwm.c:1138
void PWMDeadBandDisable(uint32_t ui32Base, uint32_t ui32Gen)
Definition: pwm.c:624
#define PWM_INT_FAULT2
Definition: pwm.h:125
#define PWM_X_GENA_ACTCMPAU_ONE
Definition: hw_pwm.h:1722
#define HWREG(x)
Definition: hw_types.h:48
void PWMOutputState(uint32_t ui32Base, uint32_t ui32PWMOutBits, bool bEnable)
Definition: pwm.c:726
#define PWM_OUT_2
Definition: pwm.h:156
void PWMFaultIntClearExt(uint32_t ui32Base, uint32_t ui32FaultInts)
Definition: pwm.c:1646
#define PWM_X_CTL_LATCH
Definition: hw_pwm.h:1578
#define PWM_OUT_1
Definition: pwm.h:155
#define PWM_GEN_EXT_BADDR(_mod_, _gen_)
Definition: pwm.c:66
#define PWM_FAULT_GROUP_1
Definition: pwm.h:194
#define PWM_O_X_MINFLTPER
Definition: hw_pwm.h:1567
#define PWM_X_GENB_ACTLOAD_ONE
Definition: hw_pwm.h:1771
static uint32_t _PWMGenIntNumberGet(uint32_t ui32Base, uint32_t ui32Gen)
Definition: pwm.c:923
#define PWM_FAULT3_SENSE_LOW
Definition: pwm.h:217
void PWMIntEnable(uint32_t ui32Base, uint32_t ui32GenFault)
Definition: pwm.c:1486
void PWMDeadBandEnable(uint32_t ui32Base, uint32_t ui32Gen, uint16_t ui16Rise, uint16_t ui16Fall)
Definition: pwm.c:581
#define PWM_X_CTL_MINFLTPER
Definition: hw_pwm.h:1579
void PWMFaultIntUnregister(uint32_t ui32Base)
Definition: pwm.c:1266
#define PWM_FAULT0_SENSE_HIGH
Definition: pwm.h:210
#define PWM_OUT_0_BIT
Definition: pwm.h:163
#define PWM_O_ISC
Definition: hw_pwm.h:55
#define PWM_SYSCLK_DIV_1
Definition: pwm.h:225
void PWMGenIntRegister(uint32_t ui32Base, uint32_t ui32Gen, void(*pfnIntHandler)(void))
Definition: pwm.c:1088
#define ASSERT(expr)
Definition: debug.h:67
#define PWM_INT_CNT_AD
Definition: pwm.h:104
#define PWM_O_X_INTEN
Definition: hw_pwm.h:1553
#define PWM_O_X_LOAD
Definition: hw_pwm.h:1556
uint32_t PWMGenFaultStatus(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Group)
Definition: pwm.c:1881
#define PWM_OUT_7
Definition: pwm.h:161
#define PWM_O_X_DBFALL
Definition: hw_pwm.h:1564
#define PWM_OUT_3
Definition: pwm.h:157
#define PWM_O_X_FLTSEN
Definition: hw_pwm.h:1841
#define PWM_SYSCLK_DIV_64
Definition: pwm.h:231
#define PWM_INT_FAULT3
Definition: pwm.h:126
#define PWM_O_CTL
Definition: hw_pwm.h:48
#define PWM_TR_CNT_AD
Definition: pwm.h:110
void PWMIntDisable(uint32_t ui32Base, uint32_t ui32GenFault)
Definition: pwm.c:1520
#define INT_PWM0_1_TM4C129
Definition: hw_ints.h:187
#define INT_PWM1_FAULT_TM4C123
Definition: hw_ints.h:168
#define PWM_OUT_2_BIT
Definition: pwm.h:165
uint32_t PWMGenFaultTriggerGet(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Group)
Definition: pwm.c:1822
#define PWM_OUT_BADDR(_mod_, _out_)
Definition: pwm.c:69
void PWMClockSet(uint32_t ui32Base, uint32_t ui32Config)
Definition: pwm.c:1990
#define PWM_SYSCLK_DIV_32
Definition: pwm.h:230
void PWMGenFaultTriggerSet(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Group, uint32_t ui32FaultTriggers)
Definition: pwm.c:1759
void PWMGenFaultConfigure(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32MinFaultPeriod, uint32_t ui32FaultSenses)
Definition: pwm.c:1691
#define PWM_SYSCLK_DIV_8
Definition: pwm.h:228
#define PWM_OUT_1_BIT
Definition: pwm.h:164
uint32_t PWMIntStatus(uint32_t ui32Base, bool bMasked)
Definition: pwm.c:1595
#define PWM_OUT_0
Definition: pwm.h:154
#define PWM_X_CTL_ENABLE
Definition: hw_pwm.h:1606
uint32_t PWMClockGet(uint32_t ui32Base)
Definition: pwm.c:2030
#define PWM_OUT_5
Definition: pwm.h:159
#define PWM_O_X_FLTSRC0
Definition: hw_pwm.h:1565
#define PWM_X_CTL_GENBUPD_M
Definition: hw_pwm.h:1593
#define PWM_ISC_INTFAULT0
Definition: hw_pwm.h:244
#define PWM_X_DBCTL_ENABLE
Definition: hw_pwm.h:1783
#define PWM_INT_GEN_2
Definition: pwm.h:121
#define PWM_SYSCLK_DIV_16
Definition: pwm.h:229
#define PWM_O_FAULTVAL
Definition: hw_pwm.h:57
#define PWM_GEN_3_BIT
Definition: pwm.h:142
#define PWM_FAULT2_SENSE_LOW
Definition: pwm.h:215
#define PWM_INT_FAULT0
Definition: pwm.h:123
#define INT_PWM1_0_TM4C123
Definition: hw_ints.h:164
#define PWM_FAULT_FAULT1
Definition: pwm.h:181
#define PWM_GEN_1_BIT
Definition: pwm.h:140
#define PWM_IS_OUTPUT_ODD(_out_)
Definition: pwm.c:71
#define PWM_X_CTL_DBRISEUPD_M
Definition: hw_pwm.h:1585
#define PWM_OUTPUT_MODE_NO_SYNC
Definition: pwm.h:239
#define PWM_X_CTL_CMPAUPD
Definition: hw_pwm.h:1602
#define PWM_OUTPUT_MODE_SYNC_GLOBAL
Definition: pwm.h:242
#define PWM_O_RIS
Definition: hw_pwm.h:54
#define PWM_INT_CNT_BD
Definition: pwm.h:106
#define PWM_FAULT1_SENSE_LOW
Definition: pwm.h:213
#define PWM_O_X_CMPA
Definition: hw_pwm.h:1558
#define PWM_OUT_6
Definition: pwm.h:160
#define PWM_FAULT_DCMP3
Definition: pwm.h:199
#define PWM_X_CTL_DBFALLUPD_M
Definition: hw_pwm.h:1581
#define PWM_FAULT_DCMP1
Definition: pwm.h:197
#define PWM_X_GENA_ACTCMPAD_ZERO
Definition: hw_pwm.h:1713
#define PWM_O_X_ISC
Definition: hw_pwm.h:1555
#define PWM_INT_CNT_BU
Definition: pwm.h:105
#define PWM_O_ENUPD
Definition: hw_pwm.h:58
void PWMGenPeriodSet(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Period)
Definition: pwm.c:278
void PWMGenIntTrigEnable(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32IntTrig)
Definition: pwm.c:1315
#define PWM_CC_PWMDIV_M
Definition: hw_pwm.h:1539
void PWMOutputInvert(uint32_t ui32Base, uint32_t ui32PWMOutBits, bool bInvert)
Definition: pwm.c:774
#define PWM_O_SYNC
Definition: hw_pwm.h:49
void PWMOutputFault(uint32_t ui32Base, uint32_t ui32PWMOutBits, bool bFaultSuppress)
Definition: pwm.c:883
#define PWM_FAULT_FAULT0
Definition: pwm.h:180
#define PWM_FAULT_DCMP2
Definition: pwm.h:198
#define PWM_O_X_GENB
Definition: hw_pwm.h:1561
#define PWM_O_FAULT
Definition: hw_pwm.h:52
void PWMFaultIntRegister(uint32_t ui32Base, void(*pfnIntHandler)(void))
Definition: pwm.c:1221
#define PWM_OUT_7_BIT
Definition: pwm.h:170
void PWMSyncUpdate(uint32_t ui32Base, uint32_t ui32GenBits)
Definition: pwm.c:656
#define INT_PWM1_3_TM4C123
Definition: hw_ints.h:167
uint32_t PWMGenIntStatus(uint32_t ui32Base, uint32_t ui32Gen, bool bMasked)
Definition: pwm.c:1396
static uint32_t _PWMFaultIntNumberGet(uint32_t ui32Base)
Definition: pwm.c:1179
#define CLASS_IS_TM4C123
Definition: hw_types.h:93
void PWMGenDisable(uint32_t ui32Base, uint32_t ui32Gen)
Definition: pwm.c:412
#define PWM_O_X_CMPB
Definition: hw_pwm.h:1559
#define PWM_O_X_RIS
Definition: hw_pwm.h:1554
#define INT_PWM0_FAULT_TM4C129
Definition: hw_ints.h:185
#define PWM_O_CC
Definition: hw_pwm.h:144
void PWMPulseWidthSet(uint32_t ui32Base, uint32_t ui32PWMOut, uint32_t ui32Width)
Definition: pwm.c:447
#define PWM_INT_FAULT1
Definition: pwm.h:124
#define PWM_OUTPUT_MODE_SYNC_LOCAL
Definition: pwm.h:240
#define PWM_X_GENB_ACTCMPBU_ONE
Definition: hw_pwm.h:1752
#define PWM_O_X_FLTSTAT0
Definition: hw_pwm.h:1842
#define PWM_TR_CNT_BD
Definition: pwm.h:112
#define INT_PWM1_1_TM4C123
Definition: hw_ints.h:165
void IntUnregister(uint32_t ui32Interrupt)
Definition: interrupt.c:381
#define PWM_FAULT_GROUP_0
Definition: pwm.h:178
#define INT_PWM1_2_TM4C123
Definition: hw_ints.h:166
#define PWM_X_MINFLTPER_M
Definition: hw_pwm.h:1833
#define PWM_FAULT2_SENSE_HIGH
Definition: pwm.h:214
#define INT_PWM0_0_TM4C129
Definition: hw_ints.h:186
#define PWM_GEN_1
Definition: pwm.h:135
void PWMSyncTimeBase(uint32_t ui32Base, uint32_t ui32GenBits)
Definition: pwm.c:688
#define PWM_OUT_5_BIT
Definition: pwm.h:168
#define PWM_X_CTL_GENAUPD_M
Definition: hw_pwm.h:1597
#define PWM_OUT_4
Definition: pwm.h:158
#define PWM_O_X_GENA
Definition: hw_pwm.h:1560
#define PWM_OUT_3_BIT
Definition: pwm.h:166
void PWMOutputFaultLevel(uint32_t ui32Base, uint32_t ui32PWMOutBits, bool bDriveHigh)
Definition: pwm.c:830
#define PWM_TR_CNT_ZERO
Definition: pwm.h:107
#define PWM_X_CTL_MODE
Definition: hw_pwm.h:1605
#define INT_PWM0_0_TM4C123
Definition: hw_ints.h:74
#define PWM_X_CTL_CMPBUPD
Definition: hw_pwm.h:1601
#define PWM_X_GENA_ACTLOAD_ONE
Definition: hw_pwm.h:1727
#define PWM_SYSCLK_DIV_4
Definition: pwm.h:227
#define PWM_X_CTL_DEBUG
Definition: hw_pwm.h:1604
void PWMGenIntTrigDisable(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32IntTrig)
Definition: pwm.c:1357
#define PWM_GEN_3
Definition: pwm.h:137
#define PWM_O_X_FLTSRC1
Definition: hw_pwm.h:1566
void PWMGenEnable(uint32_t ui32Base, uint32_t ui32Gen)
Definition: pwm.c:383
#define PWM_INT_GEN_0
Definition: pwm.h:119
#define PWM_FAULT1_SENSE_HIGH
Definition: pwm.h:212
#define INT_PWM0_3_TM4C129
Definition: hw_ints.h:219
#define PWM_FAULT3_SENSE_HIGH
Definition: pwm.h:216
#define PWM_FAULT_FAULT3
Definition: pwm.h:183
void PWMGenConfigure(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Config)
Definition: pwm.c:200
#define PWM_FAULT0_SENSE_LOW
Definition: pwm.h:211
#define PWM0_BASE
Definition: hw_memmap.h:77
#define CLASS_IS_TM4C129
Definition: hw_types.h:99
#define PWM_X_GENB_ACTCMPBD_ZERO
Definition: hw_pwm.h:1743
#define PWM_FAULT_DCMP6
Definition: pwm.h:202
uint32_t PWMGenPeriodGet(uint32_t ui32Base, uint32_t ui32Gen)
Definition: pwm.c:336
#define PWM_GEN_2_BIT
Definition: pwm.h:141
void PWMGenIntClear(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Ints)
Definition: pwm.c:1451
void PWMFaultIntClear(uint32_t ui32Base)
Definition: pwm.c:1564
#define PWM_O_X_DBRISE
Definition: hw_pwm.h:1563
#define PWM_O_INTEN
Definition: hw_pwm.h:53
#define PWM_TR_CNT_AU
Definition: pwm.h:109
#define PWM_O_X_CTL
Definition: hw_pwm.h:1552
#define PWM_INT_CNT_ZERO
Definition: pwm.h:101
#define PWM_O_X_FLTSTAT1
Definition: hw_pwm.h:1843
#define PWM_O_ENABLE
Definition: hw_pwm.h:50
#define PWM_FAULT_DCMP7
Definition: pwm.h:203
void IntDisable(uint32_t ui32Interrupt)
Definition: interrupt.c:684
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
Definition: interrupt.c:309
#define PWM_INT_GEN_3
Definition: pwm.h:122
void IntEnable(uint32_t ui32Interrupt)
Definition: interrupt.c:610
void PWMOutputUpdateMode(uint32_t ui32Base, uint32_t ui32PWMOutBits, uint32_t ui32Mode)
Definition: pwm.c:2088
#define PWM_TR_CNT_BU
Definition: pwm.h:111
#define PWM_FAULT_DCMP0
Definition: pwm.h:196
#define PWM_CC_USEPWM
Definition: hw_pwm.h:1538
#define PWM_FAULT_FAULT2
Definition: pwm.h:182