You may have seen my post asking about accelerating the ADC using DMA. Damien solved my issue by changing the firmware so that sampling can be done much faster now. Nevertheless I would like to try to implement ADC sampling using DMA by changing the firmware.
Unfortunately I haven't been able to add any functions that are accecible from python. I changed the stmhal/adc.c, I forked the function read_timed and added the new function to the mapping:
Code: Select all
STATIC const mp_map_elem_t adc_locals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_read), (mp_obj_t)&adc_read_obj},
{ MP_OBJ_NEW_QSTR(MP_QSTR_read_timed), (mp_obj_t)&adc_read_timed_obj},
{ MP_OBJ_NEW_QSTR(MP_QSTR_read_timed_dma), (mp_obj_t)&adc_read_timed_dma_obj}
};
Code: Select all
CC adc.c
In file included from ../py/mpstate.h:34:0,
from ../py/runtime.h:29,
from adc.c:32:
adc.c:347:23: error: 'MP_QSTR_read_timed_dma' undeclared here (not in a function)
{ MP_OBJ_NEW_QSTR(MP_QSTR_read_timed_dma), (mp_obj_t)&adc_read_timed_dma_obj}
^
../py/obj.h:90:56: note: in definition of macro 'MP_OBJ_NEW_QSTR'
#define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2))
The only post about this I could find is: http://forum.micropython.org/viewtopic.php?t=303
.... but I think this is not my case because I am trying to add a function that is specific for the pyboard.
How did you (developers) add functions? Is there any tutorial about this?
Thank you very much!
Felix