-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathirsgpio.cpp
More file actions
545 lines (499 loc) · 16 KB
/
irsgpio.cpp
File metadata and controls
545 lines (499 loc) · 16 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
//! \file
//! \ingroup drivers_group
//! \brief Ïîðòû ââîäà-âûâîäà äëÿ ARM
//!
//! Äàòà: 22.11.2010
//! Äàòà ñîçäàíèÿ: 10.11.2010
#include <irspch.h>
#ifdef __BORLANDC__
#pragma hdrstop
#endif // __BORLANDC__
#ifdef IRS_STM32_F2_F4_F7
# include <armcfg.h>
#endif // IRS_STM32_F2_F4_F7
#include <irsgpio.h>
#include <irserror.h>
#include <irsfinal.h>
// class gpio_pin_t:
void irs::gpio_pin_t::set_pin(bool a_pin)
{
pin(a_pin);
}
void irs::gpio_pin_t::pin(bool a_pin)
{
if (a_pin) {
set();
} else {
clear();
}
}
void irs::gpio_pin_t::set_state(io_pin_value_t a_value)
{
if (a_value == io_pin_on) {
set();
} else if (a_value == io_pin_off) {
clear();
}
}
#ifdef __ICCAVR__
//-------------------------- io_pin_t -----------------------------
irs::avr::io_pin_t::io_pin_t(p_avr_port_t ap_port,
p_avr_port_t, p_avr_port_t,
irs_u8 a_bit, dir_t a_dir, bool a_pull_up
):
io_aux_port_t(*ap_port),
m_mask(1 << a_bit)
{
if (a_dir == dir_in)
{
dir() &= (m_mask^0xFF);
if (a_pull_up) out() |= m_mask;
}
if (a_dir == dir_out)
{
dir() |= m_mask;
out() &= (m_mask^0xFF);
}
}
irs::avr::io_pin_t::io_pin_t(avr_port_t &a_port,
irs_u8 a_bit, dir_t a_dir, bool a_pull_up
):
io_aux_port_t(a_port),
m_mask(1 << a_bit)
{
if (a_dir == dir_in)
{
dir() &= (m_mask^0xFF);
if (a_pull_up) out() |= m_mask;
}
if (a_dir == dir_out)
{
dir() |= m_mask;
out() &= (m_mask^0xFF);
}
}
irs::avr::io_pin_t::~io_pin_t()
{
return;
}
bool irs::avr::io_pin_t::pin()
{
return in() & m_mask;
}
void irs::avr::io_pin_t::set()
{
out() |= m_mask;
}
void irs::avr::io_pin_t::clear()
{
out() &= (m_mask^0xFF);
}
void irs::avr::io_pin_t::set_dir(dir_t a_dir)
{
if (a_dir == dir_in) dir() &= (m_mask^0xFF);
if (a_dir == dir_out) dir() |= m_mask;
}
// irs::avr::io_port_t
// Êðàøåíèííèêîâ: Â io_pin_t èñïîëüçóåòñÿ ïàðàìåòð a_pull_up.
// Â io_port_t äëÿ ýòîãî ñëåäóåò èñïîëüçîâàòü ïàðàìåòð a_dir
// ñî çíà÷åíèåì dir_in_pull_up
irs::avr::io_port_t::io_port_t(avr_port_t &a_port, data_t a_mask, dir_t a_dir,
irs_u8 a_shift
):
io_aux_port_t(a_port),
m_mask(a_mask),
m_shift(a_shift)
{
set_dir(a_dir);
}
irs::avr::io_port_t::~io_port_t()
{
}
irs::avr::io_port_t::data_t irs::avr::io_port_t::get()
{
return static_cast<data_t>((in() & m_mask) >> m_shift);
}
void irs::avr::io_port_t::set(data_t a_data)
{
out() &= ~m_mask;
out() |= (a_data << m_shift) & m_mask;
}
// Âûõîä ñáðàñûâàåòñÿ ïðè ñìåíå íàïðàâëåíèÿ ïîðòà
void irs::avr::io_port_t::set_dir(dir_t a_dir)
{
switch (a_dir) {
case dir_in:
case dir_in_pull_up: {
dir() &= ~m_mask;
if (a_dir == dir_in_pull_up) {
out() |= m_mask;
} else {
out() &= ~m_mask;
}
}
case dir_out: {
dir() |= m_mask;
out() &= ~m_mask;
}
default: {
IRS_LIB_ASSERT_MSG("irs::avr::io_port_t: Äëÿ AVR, â ïàðàìåòðå "
"dir_t a_dir, ïîääåðæèâàþòñÿ òîëüêî çíà÷åíèÿ: dir_in, "
"dir_in_pull_up, dir_out. Èñïîëüçîâàí ïàðàìåòð âûõîäÿùèé çà "
"ïðåäåëû ýòîãî ñïèñêà");
}
}
}
//----------------------------- mem_out_pin_t --------------------------------
irs::avr::mem_out_pin_t::mem_out_pin_t(mem_out_register_t *ap_write_register,
irs_u8 a_bit, irs_u8 a_init_value):
mp_write_register(ap_write_register),
m_bit(a_bit)
{
if (m_bit > 7) m_bit = 7;
irs_u8 buf_value = mp_write_register->get_value();
if (a_init_value)
buf_value |= (1 << m_bit);
else
buf_value &= ((1 << m_bit)^0xFF);
mp_write_register->set_value(buf_value);
}
irs::avr::mem_out_pin_t::~mem_out_pin_t()
{
irs_u8 buf_value = mp_write_register->get_value();
buf_value &= ((1 << m_bit)^0xFF);
mp_write_register->set_value(buf_value);
}
bool irs::avr::mem_out_pin_t::pin()
{
irs_u8 buf_value = mp_write_register->get_value();
return buf_value & (1 << m_bit);
}
void irs::avr::mem_out_pin_t::set()
{
irs_u8 buf_value = mp_write_register->get_value();
buf_value |= (1 << m_bit);
mp_write_register->set_value(buf_value);
}
void irs::avr::mem_out_pin_t::clear()
{
irs_u8 buf_value = mp_write_register->get_value();
buf_value &= ((1 << m_bit)^0xFF);
mp_write_register->set_value(buf_value);
}
void irs::avr::mem_out_pin_t::set_dir(dir_t /*a_dir*/)
{
return;
}
//--------------------------- mem_out_register_t -----------------------------
irs::avr::mem_out_register_t::mem_out_register_t(irs_uarc a_address,
irs_u8 a_init_value):
m_value(a_init_value),
mp_register((irs_u8*)a_address)
{
*mp_register = a_init_value;
}
irs::avr::mem_out_register_t::~mem_out_register_t()
{
}
inline irs_u8 irs::avr::mem_out_register_t::get_value()
{
return m_value;
}
inline void irs::avr::mem_out_register_t::set_value(irs_u8 a_value)
{
m_value = a_value;
*mp_register = m_value;
}
#endif //__ICCAVR__
#ifdef __ICCARM__
#ifndef IRS_STM32H7xx
irs::arm::io_pin_t::io_pin_t(arm_port_t &a_port, irs_u8 a_bit, dir_t a_dir,
io_pin_value_t a_value
):
m_port(reinterpret_cast<irs_u32>(&a_port)),
m_bit(a_bit),
m_data_mask(0x04 << m_bit),
m_port_mask(1 << m_bit)
{
init(a_dir, a_value);
}
#ifdef IRS_STM32_F2_F4_F7
irs::arm::io_pin_t::io_pin_t(gpio_channel_t a_channel, dir_t a_dir,
io_pin_value_t a_value
):
m_port(get_port_address(a_channel)),
m_bit(static_cast<irs_u8>(get_pin_index(a_channel))),
m_data_mask(0x04 << m_bit),
m_port_mask(1 << m_bit)
{
init(a_dir, a_value);
}
#endif // IRS_STM32_F2_F4_F7
void irs::arm::io_pin_t::init(dir_t a_dir, io_pin_value_t a_value)
{
port_clock_on(m_port);
#ifdef __LM3SxBxx__
HWREG(m_port + GPIO_LOCK) = GPIO_UNLOCK_VALUE;
HWREG(m_port + GPIO_CR) |= m_port_mask;
#endif // __LM3SxBxx__
#if defined(__LM3SxBxx__) || defined(__LM3Sx9xx__)
HWREG(m_port + GPIO_DEN) |= m_port_mask;
HWREG(m_port + GPIO_AFSEL) &= ~m_port_mask;
HWREG(m_port + GPIO_ODR) &= ~m_port_mask;
if (a_dir == dir_in) {
HWREG(m_port + GPIO_DIR) &= ~m_port_mask;
} else if (a_dir == dir_out) {
HWREG(m_port + GPIO_DIR) |= m_port_mask;
HWREG(m_port + GPIO_DATA + m_data_mask) = 0;
}
#elif defined(__STM32F100RBT__) || defined(IRS_STM32_F2_F4_F7)
set_dir(a_dir);
#else
#error Òèï êîíòðîëëåðà íå îïðåäåë¸í
#endif // mcu type
if (a_dir == dir_out) {
set_state(a_value);
}
}
irs::arm::io_pin_t::~io_pin_t()
{
return;
}
bool irs::arm::io_pin_t::pin()
{
#if defined(__LM3SxBxx__) || defined(__LM3Sx9xx__)
return HWREG(m_port + GPIO_DATA + m_data_mask);
#elif defined(__STM32F100RBT__)
return (HWREG(m_port + IDR) & m_port_mask);
#elif defined(IRS_STM32_F2_F4_F7)
return (HWREG(m_port + GPIO_IDR_S) & m_port_mask);
#else
#error Òèï êîíòðîëëåðà íå îïðåäåë¸í
#endif // mcu type
}
void irs::arm::io_pin_t::set()
{
#if defined(__LM3SxBxx__) || defined(__LM3Sx9xx__)
HWREG(m_port + GPIO_DATA + m_data_mask) = 0xFF;
#elif defined(__STM32F100RBT__)
HWREG(m_port + ODR) |= m_port_mask;
#elif defined(IRS_STM32_F2_F4_F7)
HWREG(m_port + GPIO_ODR_S) |= m_port_mask;
#else
#error Òèï êîíòðîëëåðà íå îïðåäåë¸í
#endif // mcu type
}
void irs::arm::io_pin_t::clear()
{
#if defined(__LM3SxBxx__) || defined(__LM3Sx9xx__)
HWREG(m_port + GPIO_DATA + m_data_mask) = 0;
#elif defined(__STM32F100RBT__)
HWREG(m_port + ODR) &= ~m_port_mask;
#elif defined(IRS_STM32_F2_F4_F7)
HWREG(m_port + GPIO_ODR_S) &= ~m_port_mask;
#else
#error Òèï êîíòðîëëåðà íå îïðåäåë¸í
#endif // mcu type
}
#ifdef IRS_STM32_F2_F4_F7
void set_pin_dir(const irs_u32 a_port, const irs_u8 a_bit,
const irs::io_t::dir_t a_dir)
{
const int gpio_pupdr_bit_count = 2;
const int gpio_moder_bit_count = 2;
const int gpio_otyper_bit_count = 1;
switch (a_dir) {
case irs::io_t::dir_in: {
IRS_SET_BITS(a_port + GPIO_PUPDR_S, gpio_pupdr_bit_count*a_bit,
gpio_pupdr_bit_count, GPIO_PUPDR_FLOAT);
/*HWREG(a_port + GPIO_PUPDR_S) &= ~(3 << 2*a_bit);
HWREG(a_port + GPIO_PUPDR_S) |= GPIO_PUPDR_FLOAT << 2*a_bit;*/
IRS_SET_BITS(a_port + GPIO_MODER_S, gpio_moder_bit_count*a_bit,
gpio_moder_bit_count, GPIO_MODER_INPUT);
//HWREG(a_port + GPIO_MODER_S) &= ~(3 << 2*a_bit);
//HWREG(a_port + GPIO_MODER_S) |= GPIO_MODER_INPUT << 2*a_bit;
IRS_SET_BITS(a_port + GPIO_OTYPER_S, gpio_otyper_bit_count*a_bit,
gpio_otyper_bit_count, GPIO_OTYPER_OUTPUT_PUSH_PULL);
/*HWREG(a_port + GPIO_OTYPER_S) &= ~(3 << 2*a_bit);
HWREG(a_port + GPIO_OTYPER_S) |=
GPIO_OTYPER_OUTPUT_PUSH_PULL << 2*a_bit;*/
} break;
case irs::io_t::dir_in_pull_up: {
IRS_SET_BITS(a_port + GPIO_PUPDR_S, gpio_pupdr_bit_count*a_bit,
gpio_pupdr_bit_count, GPIO_PUPDR_PULL_UP);
//HWREG(a_port + GPIO_PUPDR_S) &= ~(3 << 2*a_bit);
//HWREG(a_port + GPIO_PUPDR_S) |= GPIO_PUPDR_PULL_UP << 2*a_bit;
IRS_SET_BITS(a_port + GPIO_MODER_S, gpio_moder_bit_count*a_bit,
gpio_moder_bit_count, GPIO_MODER_INPUT);
//HWREG(a_port + GPIO_MODER_S) &= ~(3 << 2*a_bit);
//HWREG(a_port + GPIO_MODER_S) |= GPIO_MODER_INPUT << 2*a_bit;
IRS_SET_BITS(a_port + GPIO_OTYPER_S, gpio_otyper_bit_count*a_bit,
gpio_otyper_bit_count, GPIO_OTYPER_OUTPUT_PUSH_PULL);
/*HWREG(a_port + GPIO_OTYPER_S) &= ~(3 << 2*a_bit);
HWREG(a_port + GPIO_OTYPER_S) |=
GPIO_OTYPER_OUTPUT_PUSH_PULL << 2*a_bit;*/
} break;
case irs::io_t::dir_in_pull_down: {
IRS_SET_BITS(a_port + GPIO_PUPDR_S, gpio_pupdr_bit_count*a_bit,
gpio_pupdr_bit_count, GPIO_PUPDR_PULL_DOWN);
//HWREG(a_port + GPIO_PUPDR_S) &= ~(3 << 2*a_bit);
//HWREG(a_port + GPIO_PUPDR_S) |= GPIO_PUPDR_PULL_DOWN << 2*a_bit;
IRS_SET_BITS(a_port + GPIO_MODER_S, gpio_moder_bit_count*a_bit,
gpio_moder_bit_count, GPIO_MODER_INPUT);
//HWREG(a_port + GPIO_MODER_S) &= ~(3 << 2*a_bit);
//HWREG(a_port + GPIO_MODER_S) |= GPIO_MODER_INPUT << 2*a_bit;
IRS_SET_BITS(a_port + GPIO_OTYPER_S, gpio_otyper_bit_count*a_bit,
gpio_otyper_bit_count, GPIO_OTYPER_OUTPUT_PUSH_PULL);
/*HWREG(a_port + GPIO_OTYPER_S) &= ~(3 << 2*a_bit);
HWREG(a_port + GPIO_OTYPER_S) |=
GPIO_OTYPER_OUTPUT_PUSH_PULL << 2*a_bit;*/
} break;
case irs::io_t::dir_out: {
IRS_SET_BITS(a_port + GPIO_PUPDR_S, gpio_pupdr_bit_count*a_bit,
gpio_pupdr_bit_count, GPIO_PUPDR_FLOAT);
//HWREG(a_port + GPIO_PUPDR_S) &= ~(3 << 2*a_bit);
//HWREG(a_port + GPIO_PUPDR_S) |= GPIO_PUPDR_FLOAT << 2*a_bit;
IRS_SET_BITS(a_port + GPIO_MODER_S, gpio_moder_bit_count*a_bit,
gpio_moder_bit_count, GPIO_MODER_OUTPUT);
//HWREG(a_port + GPIO_MODER_S) &= ~(3 << 2*a_bit);
//HWREG(a_port + GPIO_MODER_S) |= GPIO_MODER_OUTPUT << 2*a_bit;
IRS_SET_BITS(a_port + GPIO_OTYPER_S, gpio_otyper_bit_count*a_bit,
gpio_otyper_bit_count, GPIO_OTYPER_OUTPUT_PUSH_PULL);
/*HWREG(a_port + GPIO_OTYPER_S) &= ~(3 << 2*a_bit);
HWREG(a_port + GPIO_OTYPER_S) |=
GPIO_OTYPER_OUTPUT_PUSH_PULL << 2*a_bit;*/
} break;
case irs::io_t::dir_open_drain: {
IRS_SET_BITS(a_port + GPIO_PUPDR_S, gpio_pupdr_bit_count*a_bit,
gpio_pupdr_bit_count, GPIO_PUPDR_FLOAT);
//HWREG(a_port + GPIO_PUPDR_S) &= ~(3 << 2*a_bit);
//HWREG(a_port + GPIO_PUPDR_S) |= GPIO_PUPDR_FLOAT << 2*a_bit;
IRS_SET_BITS(a_port + GPIO_MODER_S, gpio_moder_bit_count*a_bit,
gpio_moder_bit_count, GPIO_MODER_OUTPUT);
//HWREG(a_port + GPIO_MODER_S) &= ~(3 << 2*a_bit);
//HWREG(a_port + GPIO_MODER_S) |= GPIO_MODER_OUTPUT << 2*a_bit;
IRS_SET_BITS(a_port + GPIO_OTYPER_S, gpio_otyper_bit_count*a_bit,
gpio_otyper_bit_count, GPIO_OTYPER_OUTPUT_OPEN_DRAIN);
/*HWREG(a_port + GPIO_OTYPER_S) &= ~(3 << 2*a_bit);
HWREG(a_port + GPIO_OTYPER_S) |=
GPIO_OTYPER_OUTPUT_OPEN_DRAIN << 2*a_bit;*/
} break;
}
}
#endif //IRS_STM32_F2_F4_F7
void irs::arm::io_pin_t::set_dir(dir_t a_dir)
{
#if defined(__LM3SxBxx__) || defined(__LM3Sx9xx__)
if (a_dir == dir_in) {
HWREG(m_port + GPIO_DIR) &= ~m_port_mask;
} else if (a_dir == dir_out) {
HWREG(m_port + GPIO_DIR) |= m_port_mask;
}
#elif defined(__STM32F100RBT__)
irs_u32 cfg_reg_offset = CRL;
irs_u32 cfg_mask_offset = m_bit * GPIO_MASK_SIZE;
if (m_bit > 7) {
cfg_mask_offset = (m_bit - 8) * GPIO_MASK_SIZE;
cfg_reg_offset = CRH;
}
irs_u32 clr_mask = GPIO_FULL_MASK << cfg_mask_offset;
irs_u32 set_mask = 0;
switch (a_dir) {
case dir_in: set_mask = GPIO_FLOAT_IN_MASK; break;
case dir_out: set_mask = GPIO_PUSHPULL_OUT_MASK; break;
case dir_open_drain: set_mask = GPIO_OPEN_DRAIN_OUT_MASK; break;
}
set_mask <<= cfg_mask_offset;
HWREG(m_port + cfg_reg_offset) &= ~clr_mask;
HWREG(m_port + cfg_reg_offset) |= set_mask;
#elif defined(IRS_STM32_F2_F4_F7)
set_pin_dir(m_port, m_bit, a_dir);
#else
#error Òèï êîíòðîëëåðà íå îïðåäåë¸í
#endif // mcu type
}
irs::arm::io_port_t::io_port_t(arm_port_t &a_port, data_t a_mask,
dir_t a_dir, irs_u8 a_shift):
m_port(reinterpret_cast<irs_u32>(&a_port)),
m_mask(a_mask << a_shift),
m_shift(a_shift)
{
port_clock_on(m_port);
#if defined(__LM3SxBxx__) || defined(__LM3Sx9xx__)
volatile dir_t dir = a_dir;//
#elif defined(__STM32F100RBT__) || defined(IRS_STM32_F2_F4_F7)
set_dir(a_dir);
#else
#error Òèï êîíòðîëëåðà íå îïðåäåë¸í
#endif // mcu type
}
irs::arm::io_port_t::~io_port_t()
{
}
irs::arm::io_port_t::data_t irs::arm::io_port_t::get()
{
#if defined(__LM3SxBxx__) || defined(__LM3Sx9xx__)
return 0;
#elif defined(__STM32F100RBT__)
return (HWREG(m_port + IDR) & m_mask) >> m_shift;
#elif defined(IRS_STM32_F2_F4_F7)
return (HWREG(m_port + GPIO_IDR_S) & m_mask) >> m_shift;
#else
#error Òèï êîíòðîëëåðà íå îïðåäåë¸í
#endif // mcu type
}
void irs::arm::io_port_t::set(data_t a_data)
{
#if defined(__LM3SxBxx__) || defined(__LM3Sx9xx__)
volatile data_t data = a_data;//
#elif defined(__STM32F100RBT__)
irs_u32 set_data = (a_data << m_shift) & m_mask;
irs_u32 clr_data = ~(a_data << m_shift) & m_mask;
HWREG(m_port + BSRR) = set_data;
HWREG(m_port + BSRR) = clr_data << GPIO_WIDTH;
#elif defined(IRS_STM32_F2_F4_F7)
irs_u32 set_data = (a_data << m_shift) & m_mask;
irs_u32 clr_data = ~(a_data << m_shift) & m_mask;
HWREG(m_port + GPIO_BSRR_S) = set_data;
HWREG(m_port + GPIO_BSRR_S) = clr_data << GPIO_WIDTH;
#else
#error Òèï êîíòðîëëåðà íå îïðåäåë¸í
#endif // mcu type
}
void irs::arm::io_port_t::set_dir(dir_t a_dir)
{
#if defined(__LM3SxBxx__) || defined(__LM3Sx9xx__)
volatile dir_t dir = a_dir;
#elif defined(__STM32F100RBT__)
for (irs_u8 bit = 0; bit < GPIO_WIDTH; bit++) {
if (m_mask & (1 << bit)) {
irs_u32 cfg_reg_offset = CRL;
irs_u32 cfg_mask_offset = bit * GPIO_MASK_SIZE;
if (bit > 7) {
cfg_mask_offset = (bit - 8) * GPIO_MASK_SIZE;
cfg_reg_offset = CRH;
}
irs_u32 clr_mask = GPIO_FULL_MASK << cfg_mask_offset;
irs_u32 set_mask = 0;
switch (a_dir) {
case dir_in: set_mask = GPIO_FLOAT_IN_MASK; break;
case dir_out: set_mask = GPIO_PUSHPULL_OUT_MASK; break;
case dir_open_drain: set_mask = GPIO_OPEN_DRAIN_OUT_MASK; break;
}
set_mask <<= cfg_mask_offset;
HWREG(m_port + cfg_reg_offset) &= ~clr_mask;
HWREG(m_port + cfg_reg_offset) |= set_mask;
}
}
#elif defined(IRS_STM32_F2_F4_F7)
for (irs_u8 bit = 0; bit < GPIO_WIDTH; bit++) {
if (m_mask & (1 << bit)) {
set_pin_dir(m_port, bit, a_dir);
}
}
#else
#error Òèï êîíòðîëëåðà íå îïðåäåë¸í
#endif // mcu type
}
#endif //IRS_STM32H7xx
#endif //__ICCARM__