11 //Adding maa_init() to the module initialisation process
15 %rename(get_version) maa_get_version();
16 const char * maa_get_version();
21 MAA_GPIO_STRONG = 0, /**< Default. Strong high and low */
22 MAA_GPIO_PULLUP = 1, /**< Resistive High */
23 MAA_GPIO_PULLDOWN = 2, /**< Resistive Low */
24 MAA_GPIO_HIZ = 3 /**< High Z State */
28 MAA_GPIO_OUT = 0, /**< Output. A Mode can also be set */
29 MAA_GPIO_IN = 1 /**< Input. */
32 %nodefault maa_gpio_context;
33 %rename(Gpio) maa_gpio_context;
36 %feature("autodoc") maa_gpio_context "
37 Create a Gpio object and export it. Depending on your board the correct GPIO
38 value will be used. If raw is true then the pin that will be initialised will
39 be the hardcoded pin value in the kernel. Please see your board IO
40 documentation to understand exactly what will happen.
43 * pin: pin number read from the board, i.e IO3 is 3
44 * raw: set to True to use real pin value from the kernel";
47 int pin; /**< the pin number, as known to the os. */
48 FILE *value_fp; /**< the file pointer to the value of the gpio */
49 #if defined(SWIGPYTHON)
50 PyObject *isr; /**< the interupt service request */
52 pthread_t thread_id; /**< the isr handler thread id */
53 int isr_value_fp; /**< the isr file pointer on the value */
57 %typemap(check) PyObject *pyfunc {
58 if (!PyCallable_Check($1))
59 SWIG_exception(SWIG_TypeError,"Expected function.");
62 %extend maa_gpio_context {
63 maa_gpio_context(int pin, int raw=0)
66 return maa_gpio_init_raw(pin);
67 return maa_gpio_init(pin);
71 maa_gpio_unexport($self);
73 %feature("autodoc") write "
74 Write a value to a GPIO pin
77 * value: value to write to GPIO";
80 return maa_gpio_write($self, value);
82 %feature("autodoc") dir "
83 Set the gpio direction
86 * dir: GPIO direction";
87 int dir(gpio_dir_t dir)
89 return maa_gpio_dir($self, dir);
91 %feature("autodoc") read "
92 Read the value of a GPIO
98 return maa_gpio_read($self);
100 %feature("autodoc") mode "
104 * mode: GPIO mode to set";
105 int mode(gpio_mode_t mode)
107 return maa_gpio_mode($self, mode);
109 #if defined(SWIGPYTHON)
110 //set python method as the isr function
111 int set_isr(PyObject *pyfunc)
114 // do a nasty cast to get away from the warnings
115 maa_gpio_isr(self, MAA_GPIO_EDGE_BOTH, (void (*) ()) pyfunc);
119 %ignore maa_gpio_isr;
123 maa_gpio_isr_exit(self);
137 %rename(Spi) maa_spi_context;
142 int spifd; /**< File descriptor to SPI Device */
146 %nodefault maa_spi_context;
147 %extend maa_spi_context {
150 return maa_spi_init();
155 int mode(unsigned short mode)
157 return maa_spi_mode($self, mode);
159 int frequency(int hz)
161 return maa_spi_frequency($self, hz);
163 unsigned int write(unsigned int data)
165 return maa_spi_write($self, data);