blob: 1d30f701f3081082326d9d924d0c2c7bf2997b7d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/**
* @file
*
* @ingroup RTEMSBSPsARMLPC176X
*
* @brief PWM-Out controller for the mbed lpc1768 board.
*/
/*
* Copyright (c) 2014 Taller Technologies.
*
* @author Diaz Marcos (marcos.diaz@tallertechnologies.com)
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifndef LPC176X_PWMOUT_DEFS_H
#define LPC176X_PWMOUT_DEFS_H
#include <bsp/lpc176x.h>
#include <bsp/pwmout.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define PWM_DEFAULT_PERIOD 20000u
#define PWM_DEFAULT_PULSEWIDTH 0u
#define PWM_PRESCALER_USECOND ( LPC176X_CCLK / 1000000 )
#define PWM_MCR_RESET_ON_MATCH0 ( 1 << 1 )
#define PWM_PCR_ENABLE_PWM( pwmout ) ( 1 << ( 9 + pwmout ) )
#define PWM_TCR_RESET ( 1 << 1 )
#define PWM_TCR_ENABLE ( 1u )
#define PWM_TCR_PWM ( 1 << 3 )
#define PWM_LER_LATCH_MATCH_0 1u
#define PWM_LER_LATCH( match ) ( 1 << ( ( match ) + 1 ) )
/**
* @brief The low-level PWM output device.
*/
typedef struct {
volatile uint32_t IR;
volatile uint32_t TCR;
volatile uint32_t TC;
volatile uint32_t PR;
volatile uint32_t PC;
volatile uint32_t MCR;
volatile uint32_t MR0;
volatile uint32_t MR1;
volatile uint32_t MR2;
volatile uint32_t MR3;
volatile uint32_t CCR;
volatile uint32_t CR0;
volatile uint32_t CR1;
volatile uint32_t CR2;
volatile uint32_t CR3;
volatile uint32_t RESERVED0;
volatile uint32_t MR4;
volatile uint32_t MR5;
volatile uint32_t MR6;
volatile uint32_t PCR;
volatile uint32_t LER;
volatile uint32_t RESERVED1[ 7 ];
volatile uint32_t CTCR;
} lpc176x_pwm_device;
/**
* @brief Represents one pin and the respective function to be set
* for each PWM output.
*/
typedef struct {
uint32_t pin_number;
lpc176x_pin_function pin_function;
} lpc176x_pwm_pin;
/**
* @brief The PWM outputs of the board.
*/
typedef enum {
PWMO_1,
PWMO_2,
PWMO_3,
PWMO_4,
PWMO_5,
PWMO_6,
PWM_OUTPUT_NUMBER
} lpc176x_pwm_number;
/**
* @brief A pin for each PWM output.
*/
typedef enum {
PWM_FIRST_PIN,
PWM_SECOND_PIN,
PWM_NUMBER_OF_PINS
} lpc176x_pwm_pin_number;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
|