MCPcopy Create free account
hub / github.com/andysworkshop/stm32plus / run

Method run

examples/timer_7segment/timer_7segment.cpp:117–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115 public:
116
117 void run() {
118
119 /*
120 * Initialise the GPIO pins. The SEGx pins will drive HIGH to light a
121 * segment and on the other side of the LED DIGx will be set HIGH to
122 * switch on the MOSFET that permits the digit to light up.
123 */
124
125 GpioA<DefaultDigitalOutputFeature<SEGA,SEGB,SEGF,SEGG>> pa;
126 GpioB<DefaultDigitalOutputFeature<DIG1,DIG2,DIG3,SEGC,SEGD,SEGE,SEGP>> pb;
127
128 // set up the state variables
129
130 _segments[0]=pa[SEGA];
131 _segments[1]=pa[SEGB];
132 _segments[2]=pb[SEGC];
133 _segments[3]=pb[SEGD];
134 _segments[4]=pb[SEGE];
135 _segments[5]=pa[SEGF];
136 _segments[6]=pa[SEGG];
137 _segments[7]=pb[SEGP];
138
139 _digits[0]=pb[DIG1];
140 _digits[1]=pb[DIG2];
141 _digits[2]=pb[DIG3];
142
143 /*
144 * Turn all the LEDs off by setting everything to low
145 */
146
147 for(uint8_t i=0;i<sizeof(_segments)/sizeof(_segments[0]);i++)
148 _segments[0].reset();
149
150 for(uint8_t i=0;i<sizeof(_digits)/sizeof(_digits[0]);i++)
151 _digits[0].reset();
152
153 /*
154 * Initialise the state variables
155 */
156
157 _display[0]=_display[1]=_display[2]=0;
158 _currentDigit=0;
159 _currentDigitPtr=_display;
160
161 /*
162 * Initialise timer1 running from the high speed internal APB2 (APB on the F0)
163 * clock with an interrupt feature
164 */
165
166 Timer1<
167 Timer1InternalClockFeature, // the timer clock source is APB2 (APB on the F0)
168 Timer1InterruptFeature // gain access to interrupt functionality
169 > timer;
170
171 /*
172 * Set ourselves up as a subscriber for interrupts raised by the timer class.
173 */
174

Callers 1

mainFunction · 0.45

Calls 8

bindFunction · 0.85
itoaFunction · 0.85
insertSubscriberMethod · 0.80
resetMethod · 0.45
enableInterruptsMethod · 0.45
enablePeripheralMethod · 0.45

Tested by

no test coverage detected