10 %rename(get_version) maa_get_version();
11 const char * maa_get_version();
16 MAA_GPIO_STRONG = 0, /**< Default. Strong high and low */
17 MAA_GPIO_PULLUP = 1, /**< Resistive High */
18 MAA_GPIO_PULLDOWN = 2, /**< Resistive Low */
19 MAA_GPIO_HIZ = 3 /**< High Z State */
23 MAA_GPIO_OUT = 0, /**< Output. A Mode can also be set */
24 MAA_GPIO_IN = 1 /**< Input. */
27 %nodefault maa_gpio_context;
28 %rename(Gpio) maa_gpio_context;
31 %feature("autodoc") maa_gpio_context "
32 Create a Gpio object and export it. Depending on your board the correct GPIO
33 value will be used. If raw is true then the pin that will be initialised will
34 be the hardcoded pin value in the kernel. Please see your board IO
35 documentation to understand exactly what will happen.
38 * pin: pin number read from the board, i.e IO3 is 3
39 * raw: set to True to use real pin value from the kernel";
42 int pin; /**< the pin number, as known to the os. */
43 FILE *value_fp; /**< the file pointer to the value of the gpio */
47 %extend maa_gpio_context {
48 maa_gpio_context(int pin, int raw=0)
51 return maa_gpio_init_raw(pin);
52 return maa_gpio_init(pin);
56 maa_gpio_close($self);
58 %feature("autodoc") write "
59 Write a value to a GPIO pin
62 * value: value to write to GPIO";
65 return maa_gpio_write($self, value);
67 %feature("autodoc") dir "
68 Set the gpio direction
71 * dir: GPIO direction";
72 int dir(gpio_dir_t dir)
74 return maa_gpio_dir($self, dir);
76 %feature("autodoc") read "
77 Read the value of a GPIO
83 return maa_gpio_read($self);
85 %feature("autodoc") mode "
89 * mode: GPIO mode to set";
90 int mode(gpio_mode_t mode)
92 return maa_gpio_mode($self, mode);
98 %nodefault maa_i2c_context;
99 %rename(I2c) maa_i2c_context;
104 int hz; /**< frequency of communication */
105 int fh; /**< the file handle to the /dev/i2c-* device */
106 int addr; /**< the address of the i2c slave */
107 maa_gpio_context gpio;
111 %nodefault maa_i2c_context;
112 %extend maa_i2c_context {
115 return maa_i2c_init();
121 int frequency(int hz)
123 return maa_i2c_frequency($self, hz);
125 int read(char *data, int length)
127 return maa_i2c_read($self, data, length);
131 return maa_i2c_read_byte($self);
133 int write(char *data, int length)
135 return maa_i2c_write($self, data, length);
139 return maa_i2c_write_byte($self, data);
145 %rename(Pwm) maa_pwm_context;
150 int pin; /**< the pin number, as known to the os. */
151 int chipid; /**< the chip id, which the pwm resides */
152 FILE *duty_fp; /**< File pointer to duty file */
156 %nodefault maa_pwm_context;
157 %extend maa_pwm_context {
158 maa_pwm_context(int pin)
160 return maa_pwm_init(pin);
162 maa_pwm_context(int chipid, int pin)
164 return maa_pwm_init_raw(chipid, pin);
168 maa_pwm_close($self);
170 int write(float percentage)
172 return maa_pwm_write($self, percentage);
176 return maa_pwm_read($self);
178 int period(float seconds)
180 return maa_pwm_period($self, seconds);
182 int period_ms(int ms)
184 return maa_pwm_period_ms($self, ms);
186 int period_us(int us)
188 return maa_pwm_period_us($self, us);
190 int pulsewidth(float seconds)
192 return maa_pwm_pulsewidth($self, seconds);
194 int pulsewidth_ms(int ms)
196 return maa_pwm_pulsewidth($self, ms);
198 int pulsewidth_us(int us)
200 return maa_pwm_pulsewidth($self, us);
202 int enable(int enable)
204 return maa_pwm_enable($self, enable);
210 %rename(Spi) maa_spi_context;
215 int spifd; /**< File descriptor to SPI Device */
219 %nodefault maa_spi_context;
220 %extend maa_spi_context {
223 return maa_spi_init();
229 int mode(unsigned short mode)
231 return maa_spi_mode($self, mode);
233 int frequency(int hz)
235 return maa_spi_frequency($self, hz);
237 unsigned int write(unsigned int data)
239 return maa_spi_write($self, data);
245 %rename(Aio) maa_aio_context;
249 unsigned int channel;
253 %nodefault maa_aio_context;
254 %extend maa_aio_context {
255 maa_aio_context(unsigned int aio_channel)
257 return maa_aio_init(aio_channel);
261 maa_aio_close($self);
265 return maa_aio_read_u16($self);