grblHAL core  20250412
expanders_init.h
Go to the documentation of this file.
1 /*
2  expanders_init.h - An embedded CNC Controller with rs274/ngc (g-code) support
3 
4  Calls the init function of enabled expanders, this file is typically included early in driver.h
5  io_expanders_init() should be called at the end of the drivers driver_init() implementation,
6  just before the driver claims ports.
7 
8  These are NOT referenced in the core grbl code
9 
10  Part of grblHAL
11 
12  Copyright (c) 2025 Terje Io
13 
14  grblHAL is free software: you can redistribute it and/or modify
15  it under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  grblHAL is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  GNU General Public License for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with grblHAL. If not, see <http://www.gnu.org/licenses/>.
26 */
27 
28 #pragma once
29 
30 extern void board_ports_init (void); // default is a weak function
31 
32 // I2C expanders
33 
34 #if PCA9654E_ENABLE || MCP3221_ENABLE || MCP4725_ENABLE
35 
36 #if defined(I2C_ENABLE) && !I2C_ENABLE
37 #undef I2C_ENABLE
38 #endif
39 
40 #ifndef I2C_ENABLE
41 #define I2C_ENABLE 1
42 #endif
43 
44 #if MCP3221_ENABLE
45 extern void mcp3221_init (void);
46 #endif
47 
48 #if MCP4725_ENABLE
49 extern void mcp4725_init (void);
50 #endif
51 
52 #if PCA9654E_ENABLE
53 extern void pca9654e_init(void);
54 #endif
55 
56 // Third party I2C expander plugins goes after this line
57 
58 #endif // I2C expanders
59 
60 // SPI expanders
61 
62 //
63 
64 // ModBus expanders
65 
66 //
67 
68 // CANBus expanders
69 
70 //
71 
72 // Other expanders
73 
74 //
75 
76 static inline void io_expanders_init (void)
77 {
78  board_ports_init(); // can be implemented by board specific code
79 
80 #if MCP3221_ENABLE
81  mcp3221_init();
82 #endif
83 
84 #if MCP4725_ENABLE
85  mcp4725_init();
86 #endif
87 
88 #if PCA9654E_ENABLE
89  pca9654e_init();
90 #endif
91 }
void board_ports_init(void)
Definition: grbllib.c:103