1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 
5 #include "py/builtin.h"
6 #include "py/mperrno.h"
7 #include "py/obj.h"
8 #include "py/runtime.h"
9 #include "ulog/ulog.h"
10 
11 extern const mp_obj_type_t driver_adc_type;
12 extern const mp_obj_type_t driver_pwm_type;
13 extern const mp_obj_type_t driver_gpio_type;
14 extern const mp_obj_type_t driver_i2c_type;
15 extern const mp_obj_type_t driver_spi_type;
16 extern const mp_obj_type_t driver_uart_type;
17 extern const mp_obj_type_t driver_rtc_type;
18 extern const mp_obj_type_t driver_timer_type;
19 extern const mp_obj_type_t driver_can_type;
20 // extern const mp_obj_type_t driver_dac_type;
21 extern const mp_obj_type_t driver_ir_type;
22 extern const mp_obj_type_t driver_wdt_type;
23 // advanced
24 extern const mp_obj_type_t driver_keypad_type;
25 extern const mp_obj_type_t driver_location_type;
26 extern const mp_obj_type_t driver_und_type;
27 // utils
28 extern const mp_obj_type_t driver_crypto_type;
29 // this is the actual C-structure for our new object
30 
31 STATIC const mp_rom_map_elem_t driver_locals_dict_table[] = {
32     { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_driver) },
33     { MP_OBJ_NEW_QSTR(MP_QSTR_ADC), MP_ROM_PTR(&driver_adc_type) },
34     { MP_OBJ_NEW_QSTR(MP_QSTR_PWM), MP_ROM_PTR(&driver_pwm_type) },
35     { MP_OBJ_NEW_QSTR(MP_QSTR_GPIO), MP_ROM_PTR(&driver_gpio_type) },
36     { MP_OBJ_NEW_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&driver_i2c_type) },
37     { MP_OBJ_NEW_QSTR(MP_QSTR_UART), MP_ROM_PTR(&driver_uart_type) },
38     { MP_OBJ_NEW_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&driver_spi_type) },
39     { MP_OBJ_NEW_QSTR(MP_QSTR_RTC), MP_ROM_PTR(&driver_rtc_type) },
40     { MP_OBJ_NEW_QSTR(MP_QSTR_TIMER), MP_ROM_PTR(&driver_timer_type) },
41     { MP_OBJ_NEW_QSTR(MP_QSTR_CAN), MP_ROM_PTR(&driver_can_type) },
42     //{MP_OBJ_NEW_QSTR(MP_QSTR_DAC), MP_ROM_PTR(&driver_dac_type)},
43     { MP_OBJ_NEW_QSTR(MP_QSTR_IR), MP_ROM_PTR(&driver_ir_type) },
44     { MP_OBJ_NEW_QSTR(MP_QSTR_WDT), MP_ROM_PTR(&driver_wdt_type) },
45     { MP_OBJ_NEW_QSTR(MP_QSTR_KeyPad), MP_ROM_PTR(&driver_keypad_type) },
46     { MP_OBJ_NEW_QSTR(MP_QSTR_Location), MP_ROM_PTR(&driver_location_type) },
47     { MP_OBJ_NEW_QSTR(MP_QSTR_UND), MP_ROM_PTR(&driver_und_type) },
48     { MP_OBJ_NEW_QSTR(MP_QSTR_Crypto), MP_ROM_PTR(&driver_crypto_type) },
49 };
50 
51 STATIC MP_DEFINE_CONST_DICT(driver_locals_dict, driver_locals_dict_table);
52 
53 const mp_obj_module_t driver_module = {
54     .base = { &mp_type_module },
55     .globals = (mp_obj_dict_t *)&driver_locals_dict,
56 };
57