File indexing completed on 2025-05-11 08:23:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef LPC176X_PWMOUT_DEFS_H
0020 #define LPC176X_PWMOUT_DEFS_H
0021
0022 #include <bsp/lpc176x.h>
0023 #include <bsp/pwmout.h>
0024
0025 #ifdef __cplusplus
0026 extern "C" {
0027 #endif
0028
0029 #define PWM_DEFAULT_PERIOD 20000u
0030 #define PWM_DEFAULT_PULSEWIDTH 0u
0031
0032 #define PWM_PRESCALER_USECOND ( LPC176X_CCLK / 1000000 )
0033 #define PWM_MCR_RESET_ON_MATCH0 ( 1 << 1 )
0034 #define PWM_PCR_ENABLE_PWM( pwmout ) ( 1 << ( 9 + pwmout ) )
0035 #define PWM_TCR_RESET ( 1 << 1 )
0036 #define PWM_TCR_ENABLE ( 1u )
0037 #define PWM_TCR_PWM ( 1 << 3 )
0038 #define PWM_LER_LATCH_MATCH_0 1u
0039 #define PWM_LER_LATCH( match ) ( 1 << ( ( match ) + 1 ) )
0040
0041
0042
0043
0044 typedef struct {
0045 volatile uint32_t IR;
0046 volatile uint32_t TCR;
0047 volatile uint32_t TC;
0048 volatile uint32_t PR;
0049 volatile uint32_t PC;
0050 volatile uint32_t MCR;
0051 volatile uint32_t MR0;
0052 volatile uint32_t MR1;
0053 volatile uint32_t MR2;
0054 volatile uint32_t MR3;
0055 volatile uint32_t CCR;
0056 volatile uint32_t CR0;
0057 volatile uint32_t CR1;
0058 volatile uint32_t CR2;
0059 volatile uint32_t CR3;
0060 volatile uint32_t RESERVED0;
0061 volatile uint32_t MR4;
0062 volatile uint32_t MR5;
0063 volatile uint32_t MR6;
0064 volatile uint32_t PCR;
0065 volatile uint32_t LER;
0066 volatile uint32_t RESERVED1[ 7 ];
0067 volatile uint32_t CTCR;
0068 } lpc176x_pwm_device;
0069
0070
0071
0072
0073
0074 typedef struct {
0075 uint32_t pin_number;
0076 lpc176x_pin_function pin_function;
0077 } lpc176x_pwm_pin;
0078
0079
0080
0081
0082 typedef enum {
0083 PWMO_1,
0084 PWMO_2,
0085 PWMO_3,
0086 PWMO_4,
0087 PWMO_5,
0088 PWMO_6,
0089 PWM_OUTPUT_NUMBER
0090 } lpc176x_pwm_number;
0091
0092
0093
0094
0095 typedef enum {
0096 PWM_FIRST_PIN,
0097 PWM_SECOND_PIN,
0098 PWM_NUMBER_OF_PINS
0099 } lpc176x_pwm_pin_number;
0100
0101 #ifdef __cplusplus
0102 }
0103 #endif
0104
0105 #endif