]> cloudbase.mooo.com Git - z180-stamp.git/blame - include/common.h
Rename ihex.c to cmd_loadihex.c
[z180-stamp.git] / include / common.h
CommitLineData
35edb766
L
1/*
2 * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
d684c216
L
7#ifndef COMMON_H
8#define COMMON_H
9
10#ifdef __AVR__
11#include <avr/io.h>
889202c4 12#include <avr/pgmspace.h>
8a7decea
L
13#include <util/delay.h>
14
15#define udelay(n) _delay_us(n)
d684c216 16
26331e24
L
17struct bits {
18 uint8_t b0:1;
19 uint8_t b1:1;
20 uint8_t b2:1;
21 uint8_t b3:1;
22 uint8_t b4:1;
23 uint8_t b5:1;
24 uint8_t b6:1;
25 uint8_t b7:1;
26} __attribute__((__packed__));
27
28#define SBIT(port,pin) ((*(volatile struct bits*)&port).b##pin)
29
d684c216
L
30//TODO:
31// Known to work: 4.8.4, 4.9.1
32// Known to fail: 4.8.3, 4.9.0
33#define GCC_BUG_61443 1
34
35#else
36// TODO: stm32
72f58822 37#endif /* __AVR__ */
d684c216
L
38
39#include <stdio.h>
40
41#ifdef __FLASH
42#define FLASH __flash
fc30b18e 43#define MEMX __memx
d684c216
L
44#else
45#define FLASH
fc30b18e 46#define MEMX
26331e24 47#endif
d684c216
L
48
49#define stringify(s) tostring(s)
50#define tostring(s) #s
51
52#define FSTR(X) ((const FLASH char[]) { X } )
53#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
54
55
56#ifdef __AVR__
57#define Stat GPIOR0
58#else
59extern volatile uint_least8_t Stat;
72f58822 60#endif /* __AVR__ */
d684c216 61
35edb766 62#define S_10MS_TO (1<<0)
8a7decea
L
63#define S_MSG_PENDING (1<<1)
64#define S_CON_PENDING (1<<2)
d684c216 65
26331e24 66static inline
d684c216
L
67void my_puts(const char *s)
68{
69 fputs(s, stdout);
d684c216
L
70}
71
26331e24 72static inline
d684c216
L
73void my_puts_P(const char *s)
74{
61b0cfe9 75#ifdef __AVR__
d684c216 76 fputs_P(s, stdout);
72f58822 77#else
72f58822 78 fputs(s, stdout);
72f58822 79#endif /* __AVR__ */
61b0cfe9
L
80}
81
d684c216 82#endif /* COMMON_H */