10 %rename(get_version) maa_get_version();
11 const char * maa_get_version();
12 %rename(init) maa_init();
18 MAA_GPIO_STRONG = 0, /**< Default. Strong high and low */
19 MAA_GPIO_PULLUP = 1, /**< Resistive High */
20 MAA_GPIO_PULLDOWN = 2, /**< Resistive Low */
21 MAA_GPIO_HIZ = 3 /**< High Z State */
25 MAA_GPIO_OUT = 0, /**< Output. A Mode can also be set */
26 MAA_GPIO_IN = 1 /**< Input. */
29 %nodefault maa_gpio_context;
30 %rename(Gpio) maa_gpio_context;
33 %feature("autodoc") maa_gpio_context "
34 Create a Gpio object and export it. Depending on your board the correct GPIO
35 value will be used. If raw is true then the pin that will be initialised will
36 be the hardcoded pin value in the kernel. Please see your board IO
37 documentation to understand exactly what will happen.
40 * pin: pin number read from the board, i.e IO3 is 3
41 * raw: set to True to use real pin value from the kernel";
44 int pin; /**< the pin number, as known to the os. */
45 FILE *value_fp; /**< the file pointer to the value of the gpio */
49 %extend maa_gpio_context {
50 maa_gpio_context(int pin, int raw=0)
53 return maa_gpio_init_raw(pin);
54 return maa_gpio_init(pin);
58 maa_gpio_close($self);
60 %feature("autodoc") write "
61 Write a value to a GPIO pin
64 * value: value to write to GPIO";
67 return maa_gpio_write($self, value);
69 %feature("autodoc") dir "
70 Set the gpio direction
73 * dir: GPIO direction";
74 int dir(gpio_dir_t dir)
76 return maa_gpio_dir($self, dir);
78 %feature("autodoc") read "
79 Read the value of a GPIO
85 return maa_gpio_read($self);
87 %feature("autodoc") mode "
91 * mode: GPIO mode to set";
92 int mode(gpio_mode_t mode)
94 return maa_gpio_mode($self, mode);
100 %nodefault maa_i2c_context;
101 %rename(I2c) maa_i2c_context;
106 int hz; /**< frequency of communication */
107 int fh; /**< the file handle to the /dev/i2c-* device */
108 int addr; /**< the address of the i2c slave */
109 maa_gpio_context gpio;
113 %nodefault maa_i2c_context;
114 %extend maa_i2c_context {
117 return maa_i2c_init();
123 int frequency(int hz)
125 return maa_i2c_frequency($self, hz);
127 int read(char *data, int length)
129 return maa_i2c_read($self, data, length);
133 return maa_i2c_read_byte($self);
135 int write(char *data, int length)
137 return maa_i2c_write($self, data, length);
141 return maa_i2c_write_byte($self, data);
147 %rename(Pwm) maa_pwm_context;
152 int pin; /**< the pin number, as known to the os. */
153 int chipid; /**< the chip id, which the pwm resides */
154 FILE *duty_fp; /**< File pointer to duty file */
158 %nodefault maa_pwm_context;
159 %extend maa_pwm_context {
160 maa_pwm_context(int pin)
162 return maa_pwm_init(pin);
164 maa_pwm_context(int chipid, int pin)
166 return maa_pwm_init_raw(chipid, pin);
170 maa_pwm_close($self);
172 int write(float percentage)
174 return maa_pwm_write($self, percentage);
178 return maa_pwm_read($self);
180 int period(float seconds)
182 return maa_pwm_period($self, seconds);
184 int period_ms(int ms)
186 return maa_pwm_period_ms($self, ms);
188 int period_us(int us)
190 return maa_pwm_period_us($self, us);
192 int pulsewidth(float seconds)
194 return maa_pwm_pulsewidth($self, seconds);
196 int pulsewidth_ms(int ms)
198 return maa_pwm_pulsewidth($self, ms);
200 int pulsewidth_us(int us)
202 return maa_pwm_pulsewidth($self, us);
204 int enable(int enable)
206 return maa_pwm_enable($self, enable);
212 %rename(Spi) maa_spi_context;
217 int spifd; /**< File descriptor to SPI Device */
221 %nodefault maa_spi_context;
222 %extend maa_spi_context {
225 return maa_spi_init();
231 int mode(unsigned short mode)
233 return maa_spi_mode($self, mode);
235 int frequency(int hz)
237 return maa_spi_frequency($self, hz);
239 unsigned int write(unsigned int data)
241 return maa_spi_write($self, data);
247 %rename(Aio) maa_aio_context;
251 unsigned int channel;
255 %nodefault maa_aio_context;
256 %extend maa_aio_context {
257 maa_aio_context(unsigned int aio_channel)
259 return maa_aio_init(aio_channel);
263 maa_aio_close($self);
267 return maa_aio_read_u16($self);