Skip to content

Commit 992ced3

Browse files
committed
add ATmega16 pinout
1 parent 1299bce commit 992ced3

File tree

2 files changed

+142
-0
lines changed

2 files changed

+142
-0
lines changed

hardware/arduino/cores/arduino/pins_arduino.c

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,135 @@ const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
351351
NOT_ON_TIMER , // PK 6 ** 68 ** A14
352352
NOT_ON_TIMER , // PK 7 ** 69 ** A15
353353
};
354+
#elif defined(__AVR_ATmega16__)
355+
const uint16_t PROGMEM port_to_mode_PGM[] = {
356+
NOT_A_PORT,
357+
(uint16_t) &DDRA,
358+
(uint16_t) &DDRB,
359+
(uint16_t) &DDRC,
360+
(uint16_t) &DDRD,
361+
};
362+
363+
const uint16_t PROGMEM port_to_output_PGM[] = {
364+
NOT_A_PORT,
365+
(uint16_t) &PORTA,
366+
(uint16_t) &PORTB,
367+
(uint16_t) &PORTC,
368+
(uint16_t) &PORTD,
369+
};
370+
371+
const uint16_t PROGMEM port_to_input_PGM[] = {
372+
NOT_A_PORT,
373+
(uint16_t) &PINA,
374+
(uint16_t) &PINB,
375+
(uint16_t) &PINC,
376+
(uint16_t) &PIND,
377+
};
378+
379+
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
380+
PA, /* 0 */
381+
PA,
382+
PA,
383+
PA,
384+
PA,
385+
PA,
386+
PA,
387+
PA,
388+
PB, /* 8 */
389+
PB,
390+
PB,
391+
PB,
392+
PB,
393+
PB,
394+
PB,
395+
PB,
396+
PC, /* 16 */
397+
PC,
398+
PC,
399+
PC,
400+
PC,
401+
PC,
402+
PC,
403+
PC,
404+
PD, /* 24 */
405+
PD,
406+
PD,
407+
PD,
408+
PD,
409+
PD,
410+
PD,
411+
PD,
412+
};
413+
414+
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
415+
_BV(0), /* 0, port A */
416+
_BV(1),
417+
_BV(2),
418+
_BV(3),
419+
_BV(4),
420+
_BV(5),
421+
_BV(6),
422+
_BV(7),
423+
_BV(0), /* 8, port B */
424+
_BV(1),
425+
_BV(2),
426+
_BV(3),
427+
_BV(4),
428+
_BV(5),
429+
_BV(6),
430+
_BV(7),
431+
_BV(0), /* 16, port C */
432+
_BV(1),
433+
_BV(2),
434+
_BV(3),
435+
_BV(4),
436+
_BV(5),
437+
_BV(6),
438+
_BV(7),
439+
_BV(0), /* 24, port D */
440+
_BV(1),
441+
_BV(2),
442+
_BV(3),
443+
_BV(4),
444+
_BV(5),
445+
_BV(6),
446+
_BV(7),
447+
};
448+
449+
const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
450+
NOT_ON_TIMER, /* 0 - port A */
451+
NOT_ON_TIMER,
452+
NOT_ON_TIMER,
453+
NOT_ON_TIMER,
454+
NOT_ON_TIMER,
455+
NOT_ON_TIMER,
456+
NOT_ON_TIMER,
457+
NOT_ON_TIMER,
458+
NOT_ON_TIMER, /* 8 - port B */
459+
NOT_ON_TIMER,
460+
NOT_ON_TIMER,
461+
TIMER0A,
462+
NOT_ON_TIMER,
463+
NOT_ON_TIMER,
464+
NOT_ON_TIMER,
465+
NOT_ON_TIMER,
466+
NOT_ON_TIMER, /* 16 - port C */
467+
NOT_ON_TIMER,
468+
NOT_ON_TIMER,
469+
NOT_ON_TIMER,
470+
NOT_ON_TIMER,
471+
NOT_ON_TIMER,
472+
NOT_ON_TIMER,
473+
NOT_ON_TIMER,
474+
NOT_ON_TIMER, /* 24 - port D */
475+
NOT_ON_TIMER,
476+
NOT_ON_TIMER,
477+
NOT_ON_TIMER,
478+
TIMER1B,
479+
TIMER1A,
480+
NOT_ON_TIMER,
481+
TIMER2,
482+
};
354483
#else
355484
// these arrays map port names (e.g. port B) to the
356485
// appropriate addresses for various functions (e.g. reading

libraries/Firmata/Boards.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,19 @@ writePort(port, value, bitmask): Write an 8 bit port.
151151
#define PIN_TO_SERVO(p) ((p) - 2)
152152
#define ARDUINO_PINOUT_OPTIMIZE 1
153153

154+
#elif defined(__AVR_ATmega16__)
155+
#define TOTAL_ANALOG_PINS 0
156+
#define TOTAL_PINS 32 // 32 digital
157+
#define VERSION_BLINK_PIN 0
158+
#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) <= 31)
159+
#define IS_PIN_ANALOG(p) (0)
160+
#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p)
161+
#define IS_PIN_SERVO(p) (0)
162+
#define IS_PIN_I2C(p) (0)
163+
#define PIN_TO_DIGITAL(p) (p)
164+
#define PIN_TO_ANALOG(p) (p)
165+
#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
166+
154167

155168
// Arduino Mega
156169
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)

0 commit comments

Comments
 (0)