periphery.c 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517
  1. #include "pocketpy.h"
  2. #include <string.h>
  3. #include <stdint.h>
  4. #include "periphery.h"
  5. #define ADD_ENUM(name) py_newint(py_emplacedict(mod, py_name(#name)), name)
  6. static bool gpio_config__new__(int argc, py_Ref argv) {
  7. py_Type cls = py_totype(argv);
  8. py_newobject(py_retval(), cls, 0, sizeof(gpio_config_t));
  9. return true;
  10. }
  11. static bool gpio_config__init__(int argc, py_Ref argv) {
  12. gpio_config_t* self = py_touserdata(argv);
  13. if(argc == 1) {
  14. memset(self, 0, sizeof(gpio_config_t));
  15. } else if(argc == 1 + 8) {
  16. if(!py_checkint(py_arg(1))) return false;
  17. self->direction = (gpio_direction_t)py_toint(py_arg(1));
  18. if(!py_checkint(py_arg(2))) return false;
  19. self->edge = (gpio_edge_t)py_toint(py_arg(2));
  20. if(!py_checkint(py_arg(3))) return false;
  21. self->event_clock = (gpio_event_clock_t)py_toint(py_arg(3));
  22. if(!py_checkint(py_arg(4))) return false;
  23. self->debounce_us = py_toint(py_arg(4));
  24. if(!py_checkint(py_arg(5))) return false;
  25. self->bias = (gpio_bias_t)py_toint(py_arg(5));
  26. if(!py_checkint(py_arg(6))) return false;
  27. self->drive = (gpio_drive_t)py_toint(py_arg(6));
  28. if(!py_checkbool(py_arg(7))) return false;
  29. self->inverted = py_tobool(py_arg(7));
  30. // _7 label is read-only
  31. } else {
  32. return TypeError("expected 1 or 9 arguments");
  33. }
  34. py_newnone(py_retval());
  35. return true;
  36. }
  37. static bool gpio_config__get_direction(int argc, py_Ref argv) {
  38. PY_CHECK_ARGC(1);
  39. gpio_config_t* self = py_touserdata(argv);
  40. py_newint(py_retval(), (py_i64)self->direction);
  41. return true;
  42. }
  43. static bool gpio_config__set_direction(int argc, py_Ref argv) {
  44. PY_CHECK_ARGC(2);
  45. gpio_config_t* self = py_touserdata(argv);
  46. if(!py_checkint(py_arg(1))) return false;
  47. self->direction = (gpio_direction_t)py_toint(py_arg(1));
  48. py_newnone(py_retval());
  49. return true;
  50. }
  51. static bool gpio_config__get_edge(int argc, py_Ref argv) {
  52. PY_CHECK_ARGC(1);
  53. gpio_config_t* self = py_touserdata(argv);
  54. py_newint(py_retval(), (py_i64)self->edge);
  55. return true;
  56. }
  57. static bool gpio_config__set_edge(int argc, py_Ref argv) {
  58. PY_CHECK_ARGC(2);
  59. gpio_config_t* self = py_touserdata(argv);
  60. if(!py_checkint(py_arg(1))) return false;
  61. self->edge = (gpio_edge_t)py_toint(py_arg(1));
  62. py_newnone(py_retval());
  63. return true;
  64. }
  65. static bool gpio_config__get_event_clock(int argc, py_Ref argv) {
  66. PY_CHECK_ARGC(1);
  67. gpio_config_t* self = py_touserdata(argv);
  68. py_newint(py_retval(), (py_i64)self->event_clock);
  69. return true;
  70. }
  71. static bool gpio_config__set_event_clock(int argc, py_Ref argv) {
  72. PY_CHECK_ARGC(2);
  73. gpio_config_t* self = py_touserdata(argv);
  74. if(!py_checkint(py_arg(1))) return false;
  75. self->event_clock = (gpio_event_clock_t)py_toint(py_arg(1));
  76. py_newnone(py_retval());
  77. return true;
  78. }
  79. static bool gpio_config__get_debounce_us(int argc, py_Ref argv) {
  80. PY_CHECK_ARGC(1);
  81. gpio_config_t* self = py_touserdata(argv);
  82. py_newint(py_retval(), self->debounce_us);
  83. return true;
  84. }
  85. static bool gpio_config__set_debounce_us(int argc, py_Ref argv) {
  86. PY_CHECK_ARGC(2);
  87. gpio_config_t* self = py_touserdata(argv);
  88. if(!py_checkint(py_arg(1))) return false;
  89. self->debounce_us = py_toint(py_arg(1));
  90. py_newnone(py_retval());
  91. return true;
  92. }
  93. static bool gpio_config__get_bias(int argc, py_Ref argv) {
  94. PY_CHECK_ARGC(1);
  95. gpio_config_t* self = py_touserdata(argv);
  96. py_newint(py_retval(), (py_i64)self->bias);
  97. return true;
  98. }
  99. static bool gpio_config__set_bias(int argc, py_Ref argv) {
  100. PY_CHECK_ARGC(2);
  101. gpio_config_t* self = py_touserdata(argv);
  102. if(!py_checkint(py_arg(1))) return false;
  103. self->bias = (gpio_bias_t)py_toint(py_arg(1));
  104. py_newnone(py_retval());
  105. return true;
  106. }
  107. static bool gpio_config__get_drive(int argc, py_Ref argv) {
  108. PY_CHECK_ARGC(1);
  109. gpio_config_t* self = py_touserdata(argv);
  110. py_newint(py_retval(), (py_i64)self->drive);
  111. return true;
  112. }
  113. static bool gpio_config__set_drive(int argc, py_Ref argv) {
  114. PY_CHECK_ARGC(2);
  115. gpio_config_t* self = py_touserdata(argv);
  116. if(!py_checkint(py_arg(1))) return false;
  117. self->drive = (gpio_drive_t)py_toint(py_arg(1));
  118. py_newnone(py_retval());
  119. return true;
  120. }
  121. static bool gpio_config__get_inverted(int argc, py_Ref argv) {
  122. PY_CHECK_ARGC(1);
  123. gpio_config_t* self = py_touserdata(argv);
  124. py_newbool(py_retval(), self->inverted);
  125. return true;
  126. }
  127. static bool gpio_config__set_inverted(int argc, py_Ref argv) {
  128. PY_CHECK_ARGC(2);
  129. gpio_config_t* self = py_touserdata(argv);
  130. if(!py_checkbool(py_arg(1))) return false;
  131. self->inverted = py_tobool(py_arg(1));
  132. py_newnone(py_retval());
  133. return true;
  134. }
  135. static bool gpio_config__get_label(int argc, py_Ref argv) {
  136. PY_CHECK_ARGC(1);
  137. gpio_config_t* self = py_touserdata(argv);
  138. py_newstr(py_retval(), self->label);
  139. return true;
  140. }
  141. static py_Type register__gpio_config(py_GlobalRef mod) {
  142. py_Type type = py_newtype("gpio_config", tp_stdc_Memory, mod, NULL);
  143. py_newint(py_emplacedict(py_tpobject(type), py_name("size")), sizeof(gpio_config_t));
  144. py_bindmethod(type, "__new__", gpio_config__new__);
  145. py_bindmethod(type, "__init__", gpio_config__init__);
  146. py_bindproperty(type, "direction", gpio_config__get_direction, gpio_config__set_direction);
  147. py_bindproperty(type, "edge", gpio_config__get_edge, gpio_config__set_edge);
  148. py_bindproperty(type, "event_clock", gpio_config__get_event_clock, gpio_config__set_event_clock);
  149. py_bindproperty(type, "debounce_us", gpio_config__get_debounce_us, gpio_config__set_debounce_us);
  150. py_bindproperty(type, "bias", gpio_config__get_bias, gpio_config__set_bias);
  151. py_bindproperty(type, "drive", gpio_config__get_drive, gpio_config__set_drive);
  152. py_bindproperty(type, "inverted", gpio_config__get_inverted, gpio_config__set_inverted);
  153. py_bindproperty(type, "label", gpio_config__get_label, NULL);
  154. return type;
  155. }
  156. static py_Type tp_user_gpio_config;
  157. static bool spi_msg__new__(int argc, py_Ref argv) {
  158. py_Type cls = py_totype(argv);
  159. py_newobject(py_retval(), cls, 0, sizeof(spi_msg_t));
  160. return true;
  161. }
  162. static bool spi_msg__init__(int argc, py_Ref argv) {
  163. spi_msg_t* self = py_touserdata(argv);
  164. if(argc == 1) {
  165. memset(self, 0, sizeof(spi_msg_t));
  166. } else if(argc == 1 + 6) {
  167. // _0 txbuf is read-only
  168. if(!py_checkint(py_arg(2))) return false;
  169. self->rxbuf = (uint8_t*)py_toint(py_arg(2));
  170. if(!py_checkint(py_arg(3))) return false;
  171. self->len = py_toint(py_arg(3));
  172. if(!py_checkbool(py_arg(4))) return false;
  173. self->deselect = py_tobool(py_arg(4));
  174. if(!py_checkint(py_arg(5))) return false;
  175. self->deselect_delay_us = py_toint(py_arg(5));
  176. if(!py_checkint(py_arg(6))) return false;
  177. self->word_delay_us = py_toint(py_arg(6));
  178. } else {
  179. return TypeError("expected 1 or 7 arguments");
  180. }
  181. py_newnone(py_retval());
  182. return true;
  183. }
  184. static bool spi_msg__get_txbuf(int argc, py_Ref argv) {
  185. PY_CHECK_ARGC(1);
  186. spi_msg_t* self = py_touserdata(argv);
  187. py_newint(py_retval(), (py_i64)self->txbuf);
  188. return true;
  189. }
  190. static bool spi_msg__get_rxbuf(int argc, py_Ref argv) {
  191. PY_CHECK_ARGC(1);
  192. spi_msg_t* self = py_touserdata(argv);
  193. py_newint(py_retval(), (py_i64)self->rxbuf);
  194. return true;
  195. }
  196. static bool spi_msg__set_rxbuf(int argc, py_Ref argv) {
  197. PY_CHECK_ARGC(2);
  198. spi_msg_t* self = py_touserdata(argv);
  199. if(!py_checkint(py_arg(1))) return false;
  200. self->rxbuf = (uint8_t*)py_toint(py_arg(1));
  201. py_newnone(py_retval());
  202. return true;
  203. }
  204. static bool spi_msg__get_len(int argc, py_Ref argv) {
  205. PY_CHECK_ARGC(1);
  206. spi_msg_t* self = py_touserdata(argv);
  207. py_newint(py_retval(), self->len);
  208. return true;
  209. }
  210. static bool spi_msg__set_len(int argc, py_Ref argv) {
  211. PY_CHECK_ARGC(2);
  212. spi_msg_t* self = py_touserdata(argv);
  213. if(!py_checkint(py_arg(1))) return false;
  214. self->len = py_toint(py_arg(1));
  215. py_newnone(py_retval());
  216. return true;
  217. }
  218. static bool spi_msg__get_deselect(int argc, py_Ref argv) {
  219. PY_CHECK_ARGC(1);
  220. spi_msg_t* self = py_touserdata(argv);
  221. py_newbool(py_retval(), self->deselect);
  222. return true;
  223. }
  224. static bool spi_msg__set_deselect(int argc, py_Ref argv) {
  225. PY_CHECK_ARGC(2);
  226. spi_msg_t* self = py_touserdata(argv);
  227. if(!py_checkbool(py_arg(1))) return false;
  228. self->deselect = py_tobool(py_arg(1));
  229. py_newnone(py_retval());
  230. return true;
  231. }
  232. static bool spi_msg__get_deselect_delay_us(int argc, py_Ref argv) {
  233. PY_CHECK_ARGC(1);
  234. spi_msg_t* self = py_touserdata(argv);
  235. py_newint(py_retval(), self->deselect_delay_us);
  236. return true;
  237. }
  238. static bool spi_msg__set_deselect_delay_us(int argc, py_Ref argv) {
  239. PY_CHECK_ARGC(2);
  240. spi_msg_t* self = py_touserdata(argv);
  241. if(!py_checkint(py_arg(1))) return false;
  242. self->deselect_delay_us = py_toint(py_arg(1));
  243. py_newnone(py_retval());
  244. return true;
  245. }
  246. static bool spi_msg__get_word_delay_us(int argc, py_Ref argv) {
  247. PY_CHECK_ARGC(1);
  248. spi_msg_t* self = py_touserdata(argv);
  249. py_newint(py_retval(), self->word_delay_us);
  250. return true;
  251. }
  252. static bool spi_msg__set_word_delay_us(int argc, py_Ref argv) {
  253. PY_CHECK_ARGC(2);
  254. spi_msg_t* self = py_touserdata(argv);
  255. if(!py_checkint(py_arg(1))) return false;
  256. self->word_delay_us = py_toint(py_arg(1));
  257. py_newnone(py_retval());
  258. return true;
  259. }
  260. static py_Type register__spi_msg(py_GlobalRef mod) {
  261. py_Type type = py_newtype("spi_msg", tp_stdc_Memory, mod, NULL);
  262. py_newint(py_emplacedict(py_tpobject(type), py_name("size")), sizeof(spi_msg_t));
  263. py_bindmethod(type, "__new__", spi_msg__new__);
  264. py_bindmethod(type, "__init__", spi_msg__init__);
  265. py_bindproperty(type, "txbuf", spi_msg__get_txbuf, NULL);
  266. py_bindproperty(type, "rxbuf", spi_msg__get_rxbuf, spi_msg__set_rxbuf);
  267. py_bindproperty(type, "len", spi_msg__get_len, spi_msg__set_len);
  268. py_bindproperty(type, "deselect", spi_msg__get_deselect, spi_msg__set_deselect);
  269. py_bindproperty(type, "deselect_delay_us", spi_msg__get_deselect_delay_us, spi_msg__set_deselect_delay_us);
  270. py_bindproperty(type, "word_delay_us", spi_msg__get_word_delay_us, spi_msg__set_word_delay_us);
  271. return type;
  272. }
  273. static py_Type tp_user_spi_msg;
  274. static bool periphery_version__new__(int argc, py_Ref argv) {
  275. py_Type cls = py_totype(argv);
  276. py_newobject(py_retval(), cls, 0, sizeof(periphery_version_t));
  277. return true;
  278. }
  279. static bool periphery_version__init__(int argc, py_Ref argv) {
  280. periphery_version_t* self = py_touserdata(argv);
  281. if(argc == 1) {
  282. memset(self, 0, sizeof(periphery_version_t));
  283. } else if(argc == 1 + 4) {
  284. if(!py_checkint(py_arg(1))) return false;
  285. self->major = py_toint(py_arg(1));
  286. if(!py_checkint(py_arg(2))) return false;
  287. self->minor = py_toint(py_arg(2));
  288. if(!py_checkint(py_arg(3))) return false;
  289. self->patch = py_toint(py_arg(3));
  290. // _3 commit_id is read-only
  291. } else {
  292. return TypeError("expected 1 or 5 arguments");
  293. }
  294. py_newnone(py_retval());
  295. return true;
  296. }
  297. static bool periphery_version__get_major(int argc, py_Ref argv) {
  298. PY_CHECK_ARGC(1);
  299. periphery_version_t* self = py_touserdata(argv);
  300. py_newint(py_retval(), self->major);
  301. return true;
  302. }
  303. static bool periphery_version__set_major(int argc, py_Ref argv) {
  304. PY_CHECK_ARGC(2);
  305. periphery_version_t* self = py_touserdata(argv);
  306. if(!py_checkint(py_arg(1))) return false;
  307. self->major = py_toint(py_arg(1));
  308. py_newnone(py_retval());
  309. return true;
  310. }
  311. static bool periphery_version__get_minor(int argc, py_Ref argv) {
  312. PY_CHECK_ARGC(1);
  313. periphery_version_t* self = py_touserdata(argv);
  314. py_newint(py_retval(), self->minor);
  315. return true;
  316. }
  317. static bool periphery_version__set_minor(int argc, py_Ref argv) {
  318. PY_CHECK_ARGC(2);
  319. periphery_version_t* self = py_touserdata(argv);
  320. if(!py_checkint(py_arg(1))) return false;
  321. self->minor = py_toint(py_arg(1));
  322. py_newnone(py_retval());
  323. return true;
  324. }
  325. static bool periphery_version__get_patch(int argc, py_Ref argv) {
  326. PY_CHECK_ARGC(1);
  327. periphery_version_t* self = py_touserdata(argv);
  328. py_newint(py_retval(), self->patch);
  329. return true;
  330. }
  331. static bool periphery_version__set_patch(int argc, py_Ref argv) {
  332. PY_CHECK_ARGC(2);
  333. periphery_version_t* self = py_touserdata(argv);
  334. if(!py_checkint(py_arg(1))) return false;
  335. self->patch = py_toint(py_arg(1));
  336. py_newnone(py_retval());
  337. return true;
  338. }
  339. static bool periphery_version__get_commit_id(int argc, py_Ref argv) {
  340. PY_CHECK_ARGC(1);
  341. periphery_version_t* self = py_touserdata(argv);
  342. py_newstr(py_retval(), self->commit_id);
  343. return true;
  344. }
  345. static py_Type register__periphery_version(py_GlobalRef mod) {
  346. py_Type type = py_newtype("periphery_version", tp_stdc_Memory, mod, NULL);
  347. py_newint(py_emplacedict(py_tpobject(type), py_name("size")), sizeof(periphery_version_t));
  348. py_bindmethod(type, "__new__", periphery_version__new__);
  349. py_bindmethod(type, "__init__", periphery_version__init__);
  350. py_bindproperty(type, "major", periphery_version__get_major, periphery_version__set_major);
  351. py_bindproperty(type, "minor", periphery_version__get_minor, periphery_version__set_minor);
  352. py_bindproperty(type, "patch", periphery_version__get_patch, periphery_version__set_patch);
  353. py_bindproperty(type, "commit_id", periphery_version__get_commit_id, NULL);
  354. return type;
  355. }
  356. static py_Type tp_user_periphery_version;
  357. /* functions */
  358. static bool cfunc__gpio_new(int argc, py_Ref argv) {
  359. PY_CHECK_ARGC(0);
  360. gpio_t* res = gpio_new();
  361. py_newint(py_retval(), (py_i64)res);
  362. return true;
  363. }
  364. static bool cfunc__gpio_open(int argc, py_Ref argv) {
  365. PY_CHECK_ARGC(4);
  366. gpio_t* _0;
  367. if(!py_checkint(py_arg(0))) return false;
  368. _0 = (gpio_t*)py_toint(py_arg(0));
  369. const char* _1;
  370. if(!py_checkstr(py_arg(1))) return false;
  371. _1 = py_tostr(py_arg(1));
  372. unsigned _2;
  373. if(!py_checkint(py_arg(2))) return false;
  374. _2 = py_toint(py_arg(2));
  375. gpio_direction_t _3;
  376. if(!py_checkint(py_arg(3))) return false;
  377. _3 = (gpio_direction_t)py_toint(py_arg(3));
  378. int res = gpio_open(_0, _1, _2, _3);
  379. py_newint(py_retval(), res);
  380. return true;
  381. }
  382. static bool cfunc__gpio_open_name(int argc, py_Ref argv) {
  383. PY_CHECK_ARGC(4);
  384. gpio_t* _0;
  385. if(!py_checkint(py_arg(0))) return false;
  386. _0 = (gpio_t*)py_toint(py_arg(0));
  387. const char* _1;
  388. if(!py_checkstr(py_arg(1))) return false;
  389. _1 = py_tostr(py_arg(1));
  390. const char* _2;
  391. if(!py_checkstr(py_arg(2))) return false;
  392. _2 = py_tostr(py_arg(2));
  393. gpio_direction_t _3;
  394. if(!py_checkint(py_arg(3))) return false;
  395. _3 = (gpio_direction_t)py_toint(py_arg(3));
  396. int res = gpio_open_name(_0, _1, _2, _3);
  397. py_newint(py_retval(), res);
  398. return true;
  399. }
  400. static bool cfunc__gpio_open_advanced(int argc, py_Ref argv) {
  401. PY_CHECK_ARGC(4);
  402. gpio_t* _0;
  403. if(!py_checkint(py_arg(0))) return false;
  404. _0 = (gpio_t*)py_toint(py_arg(0));
  405. const char* _1;
  406. if(!py_checkstr(py_arg(1))) return false;
  407. _1 = py_tostr(py_arg(1));
  408. unsigned _2;
  409. if(!py_checkint(py_arg(2))) return false;
  410. _2 = py_toint(py_arg(2));
  411. const gpio_config_t* _3;
  412. if(!py_checkint(py_arg(3))) return false;
  413. _3 = (const gpio_config_t*)py_toint(py_arg(3));
  414. int res = gpio_open_advanced(_0, _1, _2, _3);
  415. py_newint(py_retval(), res);
  416. return true;
  417. }
  418. static bool cfunc__gpio_open_name_advanced(int argc, py_Ref argv) {
  419. PY_CHECK_ARGC(4);
  420. gpio_t* _0;
  421. if(!py_checkint(py_arg(0))) return false;
  422. _0 = (gpio_t*)py_toint(py_arg(0));
  423. const char* _1;
  424. if(!py_checkstr(py_arg(1))) return false;
  425. _1 = py_tostr(py_arg(1));
  426. const char* _2;
  427. if(!py_checkstr(py_arg(2))) return false;
  428. _2 = py_tostr(py_arg(2));
  429. const gpio_config_t* _3;
  430. if(!py_checkint(py_arg(3))) return false;
  431. _3 = (const gpio_config_t*)py_toint(py_arg(3));
  432. int res = gpio_open_name_advanced(_0, _1, _2, _3);
  433. py_newint(py_retval(), res);
  434. return true;
  435. }
  436. static bool cfunc__gpio_open_sysfs(int argc, py_Ref argv) {
  437. PY_CHECK_ARGC(3);
  438. gpio_t* _0;
  439. if(!py_checkint(py_arg(0))) return false;
  440. _0 = (gpio_t*)py_toint(py_arg(0));
  441. unsigned _1;
  442. if(!py_checkint(py_arg(1))) return false;
  443. _1 = py_toint(py_arg(1));
  444. gpio_direction_t _2;
  445. if(!py_checkint(py_arg(2))) return false;
  446. _2 = (gpio_direction_t)py_toint(py_arg(2));
  447. int res = gpio_open_sysfs(_0, _1, _2);
  448. py_newint(py_retval(), res);
  449. return true;
  450. }
  451. static bool cfunc__gpio_read(int argc, py_Ref argv) {
  452. PY_CHECK_ARGC(2);
  453. gpio_t* _0;
  454. if(!py_checkint(py_arg(0))) return false;
  455. _0 = (gpio_t*)py_toint(py_arg(0));
  456. bool* _1;
  457. if(!py_checkint(py_arg(1))) return false;
  458. _1 = (bool*)py_toint(py_arg(1));
  459. int res = gpio_read(_0, _1);
  460. py_newint(py_retval(), res);
  461. return true;
  462. }
  463. static bool cfunc__gpio_write(int argc, py_Ref argv) {
  464. PY_CHECK_ARGC(2);
  465. gpio_t* _0;
  466. if(!py_checkint(py_arg(0))) return false;
  467. _0 = (gpio_t*)py_toint(py_arg(0));
  468. bool _1;
  469. if(!py_checkbool(py_arg(1))) return false;
  470. _1 = py_tobool(py_arg(1));
  471. int res = gpio_write(_0, _1);
  472. py_newint(py_retval(), res);
  473. return true;
  474. }
  475. static bool cfunc__gpio_poll(int argc, py_Ref argv) {
  476. PY_CHECK_ARGC(2);
  477. gpio_t* _0;
  478. if(!py_checkint(py_arg(0))) return false;
  479. _0 = (gpio_t*)py_toint(py_arg(0));
  480. int _1;
  481. if(!py_checkint(py_arg(1))) return false;
  482. _1 = py_toint(py_arg(1));
  483. int res = gpio_poll(_0, _1);
  484. py_newint(py_retval(), res);
  485. return true;
  486. }
  487. static bool cfunc__gpio_close(int argc, py_Ref argv) {
  488. PY_CHECK_ARGC(1);
  489. gpio_t* _0;
  490. if(!py_checkint(py_arg(0))) return false;
  491. _0 = (gpio_t*)py_toint(py_arg(0));
  492. int res = gpio_close(_0);
  493. py_newint(py_retval(), res);
  494. return true;
  495. }
  496. static bool cfunc__gpio_free(int argc, py_Ref argv) {
  497. PY_CHECK_ARGC(1);
  498. gpio_t* _0;
  499. if(!py_checkint(py_arg(0))) return false;
  500. _0 = (gpio_t*)py_toint(py_arg(0));
  501. gpio_free(_0);
  502. py_newnone(py_retval());
  503. return true;
  504. }
  505. static bool cfunc__gpio_read_event(int argc, py_Ref argv) {
  506. PY_CHECK_ARGC(3);
  507. gpio_t* _0;
  508. if(!py_checkint(py_arg(0))) return false;
  509. _0 = (gpio_t*)py_toint(py_arg(0));
  510. gpio_edge_t* _1;
  511. if(!py_checkint(py_arg(1))) return false;
  512. _1 = (gpio_edge_t*)py_toint(py_arg(1));
  513. uint64_t* _2;
  514. if(!py_checkint(py_arg(2))) return false;
  515. _2 = (uint64_t*)py_toint(py_arg(2));
  516. int res = gpio_read_event(_0, _1, _2);
  517. py_newint(py_retval(), res);
  518. return true;
  519. }
  520. static bool cfunc__gpio_poll_multiple(int argc, py_Ref argv) {
  521. PY_CHECK_ARGC(4);
  522. gpio_t** _0;
  523. if(!py_checkint(py_arg(0))) return false;
  524. _0 = (gpio_t**)py_toint(py_arg(0));
  525. size_t _1;
  526. if(!py_checkint(py_arg(1))) return false;
  527. _1 = py_toint(py_arg(1));
  528. int _2;
  529. if(!py_checkint(py_arg(2))) return false;
  530. _2 = py_toint(py_arg(2));
  531. bool* _3;
  532. if(!py_checkint(py_arg(3))) return false;
  533. _3 = (bool*)py_toint(py_arg(3));
  534. int res = gpio_poll_multiple(_0, _1, _2, _3);
  535. py_newint(py_retval(), res);
  536. return true;
  537. }
  538. static bool cfunc__gpio_get_direction(int argc, py_Ref argv) {
  539. PY_CHECK_ARGC(2);
  540. gpio_t* _0;
  541. if(!py_checkint(py_arg(0))) return false;
  542. _0 = (gpio_t*)py_toint(py_arg(0));
  543. gpio_direction_t* _1;
  544. if(!py_checkint(py_arg(1))) return false;
  545. _1 = (gpio_direction_t*)py_toint(py_arg(1));
  546. int res = gpio_get_direction(_0, _1);
  547. py_newint(py_retval(), res);
  548. return true;
  549. }
  550. static bool cfunc__gpio_get_edge(int argc, py_Ref argv) {
  551. PY_CHECK_ARGC(2);
  552. gpio_t* _0;
  553. if(!py_checkint(py_arg(0))) return false;
  554. _0 = (gpio_t*)py_toint(py_arg(0));
  555. gpio_edge_t* _1;
  556. if(!py_checkint(py_arg(1))) return false;
  557. _1 = (gpio_edge_t*)py_toint(py_arg(1));
  558. int res = gpio_get_edge(_0, _1);
  559. py_newint(py_retval(), res);
  560. return true;
  561. }
  562. static bool cfunc__gpio_get_event_clock(int argc, py_Ref argv) {
  563. PY_CHECK_ARGC(2);
  564. gpio_t* _0;
  565. if(!py_checkint(py_arg(0))) return false;
  566. _0 = (gpio_t*)py_toint(py_arg(0));
  567. gpio_event_clock_t* _1;
  568. if(!py_checkint(py_arg(1))) return false;
  569. _1 = (gpio_event_clock_t*)py_toint(py_arg(1));
  570. int res = gpio_get_event_clock(_0, _1);
  571. py_newint(py_retval(), res);
  572. return true;
  573. }
  574. static bool cfunc__gpio_get_debounce_us(int argc, py_Ref argv) {
  575. PY_CHECK_ARGC(2);
  576. gpio_t* _0;
  577. if(!py_checkint(py_arg(0))) return false;
  578. _0 = (gpio_t*)py_toint(py_arg(0));
  579. uint32_t* _1;
  580. if(!py_checkint(py_arg(1))) return false;
  581. _1 = (uint32_t*)py_toint(py_arg(1));
  582. int res = gpio_get_debounce_us(_0, _1);
  583. py_newint(py_retval(), res);
  584. return true;
  585. }
  586. static bool cfunc__gpio_get_bias(int argc, py_Ref argv) {
  587. PY_CHECK_ARGC(2);
  588. gpio_t* _0;
  589. if(!py_checkint(py_arg(0))) return false;
  590. _0 = (gpio_t*)py_toint(py_arg(0));
  591. gpio_bias_t* _1;
  592. if(!py_checkint(py_arg(1))) return false;
  593. _1 = (gpio_bias_t*)py_toint(py_arg(1));
  594. int res = gpio_get_bias(_0, _1);
  595. py_newint(py_retval(), res);
  596. return true;
  597. }
  598. static bool cfunc__gpio_get_drive(int argc, py_Ref argv) {
  599. PY_CHECK_ARGC(2);
  600. gpio_t* _0;
  601. if(!py_checkint(py_arg(0))) return false;
  602. _0 = (gpio_t*)py_toint(py_arg(0));
  603. gpio_drive_t* _1;
  604. if(!py_checkint(py_arg(1))) return false;
  605. _1 = (gpio_drive_t*)py_toint(py_arg(1));
  606. int res = gpio_get_drive(_0, _1);
  607. py_newint(py_retval(), res);
  608. return true;
  609. }
  610. static bool cfunc__gpio_get_inverted(int argc, py_Ref argv) {
  611. PY_CHECK_ARGC(2);
  612. gpio_t* _0;
  613. if(!py_checkint(py_arg(0))) return false;
  614. _0 = (gpio_t*)py_toint(py_arg(0));
  615. bool* _1;
  616. if(!py_checkint(py_arg(1))) return false;
  617. _1 = (bool*)py_toint(py_arg(1));
  618. int res = gpio_get_inverted(_0, _1);
  619. py_newint(py_retval(), res);
  620. return true;
  621. }
  622. static bool cfunc__gpio_set_direction(int argc, py_Ref argv) {
  623. PY_CHECK_ARGC(2);
  624. gpio_t* _0;
  625. if(!py_checkint(py_arg(0))) return false;
  626. _0 = (gpio_t*)py_toint(py_arg(0));
  627. gpio_direction_t _1;
  628. if(!py_checkint(py_arg(1))) return false;
  629. _1 = (gpio_direction_t)py_toint(py_arg(1));
  630. int res = gpio_set_direction(_0, _1);
  631. py_newint(py_retval(), res);
  632. return true;
  633. }
  634. static bool cfunc__gpio_set_edge(int argc, py_Ref argv) {
  635. PY_CHECK_ARGC(2);
  636. gpio_t* _0;
  637. if(!py_checkint(py_arg(0))) return false;
  638. _0 = (gpio_t*)py_toint(py_arg(0));
  639. gpio_edge_t _1;
  640. if(!py_checkint(py_arg(1))) return false;
  641. _1 = (gpio_edge_t)py_toint(py_arg(1));
  642. int res = gpio_set_edge(_0, _1);
  643. py_newint(py_retval(), res);
  644. return true;
  645. }
  646. static bool cfunc__gpio_set_event_clock(int argc, py_Ref argv) {
  647. PY_CHECK_ARGC(2);
  648. gpio_t* _0;
  649. if(!py_checkint(py_arg(0))) return false;
  650. _0 = (gpio_t*)py_toint(py_arg(0));
  651. gpio_event_clock_t _1;
  652. if(!py_checkint(py_arg(1))) return false;
  653. _1 = (gpio_event_clock_t)py_toint(py_arg(1));
  654. int res = gpio_set_event_clock(_0, _1);
  655. py_newint(py_retval(), res);
  656. return true;
  657. }
  658. static bool cfunc__gpio_set_debounce_us(int argc, py_Ref argv) {
  659. PY_CHECK_ARGC(2);
  660. gpio_t* _0;
  661. if(!py_checkint(py_arg(0))) return false;
  662. _0 = (gpio_t*)py_toint(py_arg(0));
  663. uint32_t _1;
  664. if(!py_checkint(py_arg(1))) return false;
  665. _1 = py_toint(py_arg(1));
  666. int res = gpio_set_debounce_us(_0, _1);
  667. py_newint(py_retval(), res);
  668. return true;
  669. }
  670. static bool cfunc__gpio_set_bias(int argc, py_Ref argv) {
  671. PY_CHECK_ARGC(2);
  672. gpio_t* _0;
  673. if(!py_checkint(py_arg(0))) return false;
  674. _0 = (gpio_t*)py_toint(py_arg(0));
  675. gpio_bias_t _1;
  676. if(!py_checkint(py_arg(1))) return false;
  677. _1 = (gpio_bias_t)py_toint(py_arg(1));
  678. int res = gpio_set_bias(_0, _1);
  679. py_newint(py_retval(), res);
  680. return true;
  681. }
  682. static bool cfunc__gpio_set_drive(int argc, py_Ref argv) {
  683. PY_CHECK_ARGC(2);
  684. gpio_t* _0;
  685. if(!py_checkint(py_arg(0))) return false;
  686. _0 = (gpio_t*)py_toint(py_arg(0));
  687. gpio_drive_t _1;
  688. if(!py_checkint(py_arg(1))) return false;
  689. _1 = (gpio_drive_t)py_toint(py_arg(1));
  690. int res = gpio_set_drive(_0, _1);
  691. py_newint(py_retval(), res);
  692. return true;
  693. }
  694. static bool cfunc__gpio_set_inverted(int argc, py_Ref argv) {
  695. PY_CHECK_ARGC(2);
  696. gpio_t* _0;
  697. if(!py_checkint(py_arg(0))) return false;
  698. _0 = (gpio_t*)py_toint(py_arg(0));
  699. bool _1;
  700. if(!py_checkbool(py_arg(1))) return false;
  701. _1 = py_tobool(py_arg(1));
  702. int res = gpio_set_inverted(_0, _1);
  703. py_newint(py_retval(), res);
  704. return true;
  705. }
  706. static bool cfunc__gpio_line(int argc, py_Ref argv) {
  707. PY_CHECK_ARGC(1);
  708. gpio_t* _0;
  709. if(!py_checkint(py_arg(0))) return false;
  710. _0 = (gpio_t*)py_toint(py_arg(0));
  711. unsigned res = gpio_line(_0);
  712. py_newint(py_retval(), res);
  713. return true;
  714. }
  715. static bool cfunc__gpio_fd(int argc, py_Ref argv) {
  716. PY_CHECK_ARGC(1);
  717. gpio_t* _0;
  718. if(!py_checkint(py_arg(0))) return false;
  719. _0 = (gpio_t*)py_toint(py_arg(0));
  720. int res = gpio_fd(_0);
  721. py_newint(py_retval(), res);
  722. return true;
  723. }
  724. static bool cfunc__gpio_name(int argc, py_Ref argv) {
  725. PY_CHECK_ARGC(3);
  726. gpio_t* _0;
  727. if(!py_checkint(py_arg(0))) return false;
  728. _0 = (gpio_t*)py_toint(py_arg(0));
  729. char* _1;
  730. if(!py_checkint(py_arg(1))) return false;
  731. _1 = (char*)py_toint(py_arg(1));
  732. size_t _2;
  733. if(!py_checkint(py_arg(2))) return false;
  734. _2 = py_toint(py_arg(2));
  735. int res = gpio_name(_0, _1, _2);
  736. py_newint(py_retval(), res);
  737. return true;
  738. }
  739. static bool cfunc__gpio_label(int argc, py_Ref argv) {
  740. PY_CHECK_ARGC(3);
  741. gpio_t* _0;
  742. if(!py_checkint(py_arg(0))) return false;
  743. _0 = (gpio_t*)py_toint(py_arg(0));
  744. char* _1;
  745. if(!py_checkint(py_arg(1))) return false;
  746. _1 = (char*)py_toint(py_arg(1));
  747. size_t _2;
  748. if(!py_checkint(py_arg(2))) return false;
  749. _2 = py_toint(py_arg(2));
  750. int res = gpio_label(_0, _1, _2);
  751. py_newint(py_retval(), res);
  752. return true;
  753. }
  754. static bool cfunc__gpio_chip_fd(int argc, py_Ref argv) {
  755. PY_CHECK_ARGC(1);
  756. gpio_t* _0;
  757. if(!py_checkint(py_arg(0))) return false;
  758. _0 = (gpio_t*)py_toint(py_arg(0));
  759. int res = gpio_chip_fd(_0);
  760. py_newint(py_retval(), res);
  761. return true;
  762. }
  763. static bool cfunc__gpio_chip_name(int argc, py_Ref argv) {
  764. PY_CHECK_ARGC(3);
  765. gpio_t* _0;
  766. if(!py_checkint(py_arg(0))) return false;
  767. _0 = (gpio_t*)py_toint(py_arg(0));
  768. char* _1;
  769. if(!py_checkint(py_arg(1))) return false;
  770. _1 = (char*)py_toint(py_arg(1));
  771. size_t _2;
  772. if(!py_checkint(py_arg(2))) return false;
  773. _2 = py_toint(py_arg(2));
  774. int res = gpio_chip_name(_0, _1, _2);
  775. py_newint(py_retval(), res);
  776. return true;
  777. }
  778. static bool cfunc__gpio_chip_label(int argc, py_Ref argv) {
  779. PY_CHECK_ARGC(3);
  780. gpio_t* _0;
  781. if(!py_checkint(py_arg(0))) return false;
  782. _0 = (gpio_t*)py_toint(py_arg(0));
  783. char* _1;
  784. if(!py_checkint(py_arg(1))) return false;
  785. _1 = (char*)py_toint(py_arg(1));
  786. size_t _2;
  787. if(!py_checkint(py_arg(2))) return false;
  788. _2 = py_toint(py_arg(2));
  789. int res = gpio_chip_label(_0, _1, _2);
  790. py_newint(py_retval(), res);
  791. return true;
  792. }
  793. static bool cfunc__gpio_tostring(int argc, py_Ref argv) {
  794. PY_CHECK_ARGC(3);
  795. gpio_t* _0;
  796. if(!py_checkint(py_arg(0))) return false;
  797. _0 = (gpio_t*)py_toint(py_arg(0));
  798. char* _1;
  799. if(!py_checkint(py_arg(1))) return false;
  800. _1 = (char*)py_toint(py_arg(1));
  801. size_t _2;
  802. if(!py_checkint(py_arg(2))) return false;
  803. _2 = py_toint(py_arg(2));
  804. int res = gpio_tostring(_0, _1, _2);
  805. py_newint(py_retval(), res);
  806. return true;
  807. }
  808. static bool cfunc__gpio_errno(int argc, py_Ref argv) {
  809. PY_CHECK_ARGC(1);
  810. gpio_t* _0;
  811. if(!py_checkint(py_arg(0))) return false;
  812. _0 = (gpio_t*)py_toint(py_arg(0));
  813. int res = gpio_errno(_0);
  814. py_newint(py_retval(), res);
  815. return true;
  816. }
  817. static bool cfunc__gpio_errmsg(int argc, py_Ref argv) {
  818. PY_CHECK_ARGC(1);
  819. gpio_t* _0;
  820. if(!py_checkint(py_arg(0))) return false;
  821. _0 = (gpio_t*)py_toint(py_arg(0));
  822. const char* res = gpio_errmsg(_0);
  823. py_newstr(py_retval(), res);
  824. return true;
  825. }
  826. static bool cfunc__led_new(int argc, py_Ref argv) {
  827. PY_CHECK_ARGC(0);
  828. led_t* res = led_new();
  829. py_newint(py_retval(), (py_i64)res);
  830. return true;
  831. }
  832. static bool cfunc__led_open(int argc, py_Ref argv) {
  833. PY_CHECK_ARGC(2);
  834. led_t* _0;
  835. if(!py_checkint(py_arg(0))) return false;
  836. _0 = (led_t*)py_toint(py_arg(0));
  837. const char* _1;
  838. if(!py_checkstr(py_arg(1))) return false;
  839. _1 = py_tostr(py_arg(1));
  840. int res = led_open(_0, _1);
  841. py_newint(py_retval(), res);
  842. return true;
  843. }
  844. static bool cfunc__led_read(int argc, py_Ref argv) {
  845. PY_CHECK_ARGC(2);
  846. led_t* _0;
  847. if(!py_checkint(py_arg(0))) return false;
  848. _0 = (led_t*)py_toint(py_arg(0));
  849. bool* _1;
  850. if(!py_checkint(py_arg(1))) return false;
  851. _1 = (bool*)py_toint(py_arg(1));
  852. int res = led_read(_0, _1);
  853. py_newint(py_retval(), res);
  854. return true;
  855. }
  856. static bool cfunc__led_write(int argc, py_Ref argv) {
  857. PY_CHECK_ARGC(2);
  858. led_t* _0;
  859. if(!py_checkint(py_arg(0))) return false;
  860. _0 = (led_t*)py_toint(py_arg(0));
  861. bool _1;
  862. if(!py_checkbool(py_arg(1))) return false;
  863. _1 = py_tobool(py_arg(1));
  864. int res = led_write(_0, _1);
  865. py_newint(py_retval(), res);
  866. return true;
  867. }
  868. static bool cfunc__led_close(int argc, py_Ref argv) {
  869. PY_CHECK_ARGC(1);
  870. led_t* _0;
  871. if(!py_checkint(py_arg(0))) return false;
  872. _0 = (led_t*)py_toint(py_arg(0));
  873. int res = led_close(_0);
  874. py_newint(py_retval(), res);
  875. return true;
  876. }
  877. static bool cfunc__led_free(int argc, py_Ref argv) {
  878. PY_CHECK_ARGC(1);
  879. led_t* _0;
  880. if(!py_checkint(py_arg(0))) return false;
  881. _0 = (led_t*)py_toint(py_arg(0));
  882. led_free(_0);
  883. py_newnone(py_retval());
  884. return true;
  885. }
  886. static bool cfunc__led_get_brightness(int argc, py_Ref argv) {
  887. PY_CHECK_ARGC(2);
  888. led_t* _0;
  889. if(!py_checkint(py_arg(0))) return false;
  890. _0 = (led_t*)py_toint(py_arg(0));
  891. unsigned* _1;
  892. if(!py_checkint(py_arg(1))) return false;
  893. _1 = (unsigned*)py_toint(py_arg(1));
  894. int res = led_get_brightness(_0, _1);
  895. py_newint(py_retval(), res);
  896. return true;
  897. }
  898. static bool cfunc__led_get_max_brightness(int argc, py_Ref argv) {
  899. PY_CHECK_ARGC(2);
  900. led_t* _0;
  901. if(!py_checkint(py_arg(0))) return false;
  902. _0 = (led_t*)py_toint(py_arg(0));
  903. unsigned* _1;
  904. if(!py_checkint(py_arg(1))) return false;
  905. _1 = (unsigned*)py_toint(py_arg(1));
  906. int res = led_get_max_brightness(_0, _1);
  907. py_newint(py_retval(), res);
  908. return true;
  909. }
  910. static bool cfunc__led_get_trigger(int argc, py_Ref argv) {
  911. PY_CHECK_ARGC(3);
  912. led_t* _0;
  913. if(!py_checkint(py_arg(0))) return false;
  914. _0 = (led_t*)py_toint(py_arg(0));
  915. char* _1;
  916. if(!py_checkint(py_arg(1))) return false;
  917. _1 = (char*)py_toint(py_arg(1));
  918. size_t _2;
  919. if(!py_checkint(py_arg(2))) return false;
  920. _2 = py_toint(py_arg(2));
  921. int res = led_get_trigger(_0, _1, _2);
  922. py_newint(py_retval(), res);
  923. return true;
  924. }
  925. static bool cfunc__led_get_triggers_entry(int argc, py_Ref argv) {
  926. PY_CHECK_ARGC(4);
  927. led_t* _0;
  928. if(!py_checkint(py_arg(0))) return false;
  929. _0 = (led_t*)py_toint(py_arg(0));
  930. unsigned _1;
  931. if(!py_checkint(py_arg(1))) return false;
  932. _1 = py_toint(py_arg(1));
  933. char* _2;
  934. if(!py_checkint(py_arg(2))) return false;
  935. _2 = (char*)py_toint(py_arg(2));
  936. size_t _3;
  937. if(!py_checkint(py_arg(3))) return false;
  938. _3 = py_toint(py_arg(3));
  939. int res = led_get_triggers_entry(_0, _1, _2, _3);
  940. py_newint(py_retval(), res);
  941. return true;
  942. }
  943. static bool cfunc__led_get_triggers_count(int argc, py_Ref argv) {
  944. PY_CHECK_ARGC(2);
  945. led_t* _0;
  946. if(!py_checkint(py_arg(0))) return false;
  947. _0 = (led_t*)py_toint(py_arg(0));
  948. unsigned* _1;
  949. if(!py_checkint(py_arg(1))) return false;
  950. _1 = (unsigned*)py_toint(py_arg(1));
  951. int res = led_get_triggers_count(_0, _1);
  952. py_newint(py_retval(), res);
  953. return true;
  954. }
  955. static bool cfunc__led_set_brightness(int argc, py_Ref argv) {
  956. PY_CHECK_ARGC(2);
  957. led_t* _0;
  958. if(!py_checkint(py_arg(0))) return false;
  959. _0 = (led_t*)py_toint(py_arg(0));
  960. unsigned _1;
  961. if(!py_checkint(py_arg(1))) return false;
  962. _1 = py_toint(py_arg(1));
  963. int res = led_set_brightness(_0, _1);
  964. py_newint(py_retval(), res);
  965. return true;
  966. }
  967. static bool cfunc__led_set_trigger(int argc, py_Ref argv) {
  968. PY_CHECK_ARGC(2);
  969. led_t* _0;
  970. if(!py_checkint(py_arg(0))) return false;
  971. _0 = (led_t*)py_toint(py_arg(0));
  972. const char* _1;
  973. if(!py_checkstr(py_arg(1))) return false;
  974. _1 = py_tostr(py_arg(1));
  975. int res = led_set_trigger(_0, _1);
  976. py_newint(py_retval(), res);
  977. return true;
  978. }
  979. static bool cfunc__led_name(int argc, py_Ref argv) {
  980. PY_CHECK_ARGC(3);
  981. led_t* _0;
  982. if(!py_checkint(py_arg(0))) return false;
  983. _0 = (led_t*)py_toint(py_arg(0));
  984. char* _1;
  985. if(!py_checkint(py_arg(1))) return false;
  986. _1 = (char*)py_toint(py_arg(1));
  987. size_t _2;
  988. if(!py_checkint(py_arg(2))) return false;
  989. _2 = py_toint(py_arg(2));
  990. int res = led_name(_0, _1, _2);
  991. py_newint(py_retval(), res);
  992. return true;
  993. }
  994. static bool cfunc__led_tostring(int argc, py_Ref argv) {
  995. PY_CHECK_ARGC(3);
  996. led_t* _0;
  997. if(!py_checkint(py_arg(0))) return false;
  998. _0 = (led_t*)py_toint(py_arg(0));
  999. char* _1;
  1000. if(!py_checkint(py_arg(1))) return false;
  1001. _1 = (char*)py_toint(py_arg(1));
  1002. size_t _2;
  1003. if(!py_checkint(py_arg(2))) return false;
  1004. _2 = py_toint(py_arg(2));
  1005. int res = led_tostring(_0, _1, _2);
  1006. py_newint(py_retval(), res);
  1007. return true;
  1008. }
  1009. static bool cfunc__led_errno(int argc, py_Ref argv) {
  1010. PY_CHECK_ARGC(1);
  1011. led_t* _0;
  1012. if(!py_checkint(py_arg(0))) return false;
  1013. _0 = (led_t*)py_toint(py_arg(0));
  1014. int res = led_errno(_0);
  1015. py_newint(py_retval(), res);
  1016. return true;
  1017. }
  1018. static bool cfunc__led_errmsg(int argc, py_Ref argv) {
  1019. PY_CHECK_ARGC(1);
  1020. led_t* _0;
  1021. if(!py_checkint(py_arg(0))) return false;
  1022. _0 = (led_t*)py_toint(py_arg(0));
  1023. const char* res = led_errmsg(_0);
  1024. py_newstr(py_retval(), res);
  1025. return true;
  1026. }
  1027. static bool cfunc__mmio_new(int argc, py_Ref argv) {
  1028. PY_CHECK_ARGC(0);
  1029. mmio_t* res = mmio_new();
  1030. py_newint(py_retval(), (py_i64)res);
  1031. return true;
  1032. }
  1033. static bool cfunc__mmio_open(int argc, py_Ref argv) {
  1034. PY_CHECK_ARGC(3);
  1035. mmio_t* _0;
  1036. if(!py_checkint(py_arg(0))) return false;
  1037. _0 = (mmio_t*)py_toint(py_arg(0));
  1038. uintptr_t _1;
  1039. if(!py_checkint(py_arg(1))) return false;
  1040. _1 = py_toint(py_arg(1));
  1041. size_t _2;
  1042. if(!py_checkint(py_arg(2))) return false;
  1043. _2 = py_toint(py_arg(2));
  1044. int res = mmio_open(_0, _1, _2);
  1045. py_newint(py_retval(), res);
  1046. return true;
  1047. }
  1048. static bool cfunc__mmio_open_advanced(int argc, py_Ref argv) {
  1049. PY_CHECK_ARGC(4);
  1050. mmio_t* _0;
  1051. if(!py_checkint(py_arg(0))) return false;
  1052. _0 = (mmio_t*)py_toint(py_arg(0));
  1053. uintptr_t _1;
  1054. if(!py_checkint(py_arg(1))) return false;
  1055. _1 = py_toint(py_arg(1));
  1056. size_t _2;
  1057. if(!py_checkint(py_arg(2))) return false;
  1058. _2 = py_toint(py_arg(2));
  1059. const char* _3;
  1060. if(!py_checkstr(py_arg(3))) return false;
  1061. _3 = py_tostr(py_arg(3));
  1062. int res = mmio_open_advanced(_0, _1, _2, _3);
  1063. py_newint(py_retval(), res);
  1064. return true;
  1065. }
  1066. static bool cfunc__mmio_ptr(int argc, py_Ref argv) {
  1067. PY_CHECK_ARGC(1);
  1068. mmio_t* _0;
  1069. if(!py_checkint(py_arg(0))) return false;
  1070. _0 = (mmio_t*)py_toint(py_arg(0));
  1071. void* res = mmio_ptr(_0);
  1072. py_newint(py_retval(), (py_i64)res);
  1073. return true;
  1074. }
  1075. static bool cfunc__mmio_read64(int argc, py_Ref argv) {
  1076. PY_CHECK_ARGC(3);
  1077. mmio_t* _0;
  1078. if(!py_checkint(py_arg(0))) return false;
  1079. _0 = (mmio_t*)py_toint(py_arg(0));
  1080. uintptr_t _1;
  1081. if(!py_checkint(py_arg(1))) return false;
  1082. _1 = py_toint(py_arg(1));
  1083. uint64_t* _2;
  1084. if(!py_checkint(py_arg(2))) return false;
  1085. _2 = (uint64_t*)py_toint(py_arg(2));
  1086. int res = mmio_read64(_0, _1, _2);
  1087. py_newint(py_retval(), res);
  1088. return true;
  1089. }
  1090. static bool cfunc__mmio_read32(int argc, py_Ref argv) {
  1091. PY_CHECK_ARGC(3);
  1092. mmio_t* _0;
  1093. if(!py_checkint(py_arg(0))) return false;
  1094. _0 = (mmio_t*)py_toint(py_arg(0));
  1095. uintptr_t _1;
  1096. if(!py_checkint(py_arg(1))) return false;
  1097. _1 = py_toint(py_arg(1));
  1098. uint32_t* _2;
  1099. if(!py_checkint(py_arg(2))) return false;
  1100. _2 = (uint32_t*)py_toint(py_arg(2));
  1101. int res = mmio_read32(_0, _1, _2);
  1102. py_newint(py_retval(), res);
  1103. return true;
  1104. }
  1105. static bool cfunc__mmio_read16(int argc, py_Ref argv) {
  1106. PY_CHECK_ARGC(3);
  1107. mmio_t* _0;
  1108. if(!py_checkint(py_arg(0))) return false;
  1109. _0 = (mmio_t*)py_toint(py_arg(0));
  1110. uintptr_t _1;
  1111. if(!py_checkint(py_arg(1))) return false;
  1112. _1 = py_toint(py_arg(1));
  1113. uint16_t* _2;
  1114. if(!py_checkint(py_arg(2))) return false;
  1115. _2 = (uint16_t*)py_toint(py_arg(2));
  1116. int res = mmio_read16(_0, _1, _2);
  1117. py_newint(py_retval(), res);
  1118. return true;
  1119. }
  1120. static bool cfunc__mmio_read8(int argc, py_Ref argv) {
  1121. PY_CHECK_ARGC(3);
  1122. mmio_t* _0;
  1123. if(!py_checkint(py_arg(0))) return false;
  1124. _0 = (mmio_t*)py_toint(py_arg(0));
  1125. uintptr_t _1;
  1126. if(!py_checkint(py_arg(1))) return false;
  1127. _1 = py_toint(py_arg(1));
  1128. uint8_t* _2;
  1129. if(!py_checkint(py_arg(2))) return false;
  1130. _2 = (uint8_t*)py_toint(py_arg(2));
  1131. int res = mmio_read8(_0, _1, _2);
  1132. py_newint(py_retval(), res);
  1133. return true;
  1134. }
  1135. static bool cfunc__mmio_read(int argc, py_Ref argv) {
  1136. PY_CHECK_ARGC(4);
  1137. mmio_t* _0;
  1138. if(!py_checkint(py_arg(0))) return false;
  1139. _0 = (mmio_t*)py_toint(py_arg(0));
  1140. uintptr_t _1;
  1141. if(!py_checkint(py_arg(1))) return false;
  1142. _1 = py_toint(py_arg(1));
  1143. uint8_t* _2;
  1144. if(!py_checkint(py_arg(2))) return false;
  1145. _2 = (uint8_t*)py_toint(py_arg(2));
  1146. size_t _3;
  1147. if(!py_checkint(py_arg(3))) return false;
  1148. _3 = py_toint(py_arg(3));
  1149. int res = mmio_read(_0, _1, _2, _3);
  1150. py_newint(py_retval(), res);
  1151. return true;
  1152. }
  1153. static bool cfunc__mmio_write64(int argc, py_Ref argv) {
  1154. PY_CHECK_ARGC(3);
  1155. mmio_t* _0;
  1156. if(!py_checkint(py_arg(0))) return false;
  1157. _0 = (mmio_t*)py_toint(py_arg(0));
  1158. uintptr_t _1;
  1159. if(!py_checkint(py_arg(1))) return false;
  1160. _1 = py_toint(py_arg(1));
  1161. uint64_t _2;
  1162. if(!py_checkint(py_arg(2))) return false;
  1163. _2 = py_toint(py_arg(2));
  1164. int res = mmio_write64(_0, _1, _2);
  1165. py_newint(py_retval(), res);
  1166. return true;
  1167. }
  1168. static bool cfunc__mmio_write32(int argc, py_Ref argv) {
  1169. PY_CHECK_ARGC(3);
  1170. mmio_t* _0;
  1171. if(!py_checkint(py_arg(0))) return false;
  1172. _0 = (mmio_t*)py_toint(py_arg(0));
  1173. uintptr_t _1;
  1174. if(!py_checkint(py_arg(1))) return false;
  1175. _1 = py_toint(py_arg(1));
  1176. uint32_t _2;
  1177. if(!py_checkint(py_arg(2))) return false;
  1178. _2 = py_toint(py_arg(2));
  1179. int res = mmio_write32(_0, _1, _2);
  1180. py_newint(py_retval(), res);
  1181. return true;
  1182. }
  1183. static bool cfunc__mmio_write16(int argc, py_Ref argv) {
  1184. PY_CHECK_ARGC(3);
  1185. mmio_t* _0;
  1186. if(!py_checkint(py_arg(0))) return false;
  1187. _0 = (mmio_t*)py_toint(py_arg(0));
  1188. uintptr_t _1;
  1189. if(!py_checkint(py_arg(1))) return false;
  1190. _1 = py_toint(py_arg(1));
  1191. uint16_t _2;
  1192. if(!py_checkint(py_arg(2))) return false;
  1193. _2 = py_toint(py_arg(2));
  1194. int res = mmio_write16(_0, _1, _2);
  1195. py_newint(py_retval(), res);
  1196. return true;
  1197. }
  1198. static bool cfunc__mmio_write8(int argc, py_Ref argv) {
  1199. PY_CHECK_ARGC(3);
  1200. mmio_t* _0;
  1201. if(!py_checkint(py_arg(0))) return false;
  1202. _0 = (mmio_t*)py_toint(py_arg(0));
  1203. uintptr_t _1;
  1204. if(!py_checkint(py_arg(1))) return false;
  1205. _1 = py_toint(py_arg(1));
  1206. uint8_t _2;
  1207. if(!py_checkint(py_arg(2))) return false;
  1208. _2 = py_toint(py_arg(2));
  1209. int res = mmio_write8(_0, _1, _2);
  1210. py_newint(py_retval(), res);
  1211. return true;
  1212. }
  1213. static bool cfunc__mmio_write(int argc, py_Ref argv) {
  1214. PY_CHECK_ARGC(4);
  1215. mmio_t* _0;
  1216. if(!py_checkint(py_arg(0))) return false;
  1217. _0 = (mmio_t*)py_toint(py_arg(0));
  1218. uintptr_t _1;
  1219. if(!py_checkint(py_arg(1))) return false;
  1220. _1 = py_toint(py_arg(1));
  1221. const uint8_t* _2;
  1222. if(!py_checkint(py_arg(2))) return false;
  1223. _2 = (const uint8_t*)py_toint(py_arg(2));
  1224. size_t _3;
  1225. if(!py_checkint(py_arg(3))) return false;
  1226. _3 = py_toint(py_arg(3));
  1227. int res = mmio_write(_0, _1, _2, _3);
  1228. py_newint(py_retval(), res);
  1229. return true;
  1230. }
  1231. static bool cfunc__mmio_close(int argc, py_Ref argv) {
  1232. PY_CHECK_ARGC(1);
  1233. mmio_t* _0;
  1234. if(!py_checkint(py_arg(0))) return false;
  1235. _0 = (mmio_t*)py_toint(py_arg(0));
  1236. int res = mmio_close(_0);
  1237. py_newint(py_retval(), res);
  1238. return true;
  1239. }
  1240. static bool cfunc__mmio_free(int argc, py_Ref argv) {
  1241. PY_CHECK_ARGC(1);
  1242. mmio_t* _0;
  1243. if(!py_checkint(py_arg(0))) return false;
  1244. _0 = (mmio_t*)py_toint(py_arg(0));
  1245. mmio_free(_0);
  1246. py_newnone(py_retval());
  1247. return true;
  1248. }
  1249. static bool cfunc__mmio_base(int argc, py_Ref argv) {
  1250. PY_CHECK_ARGC(1);
  1251. mmio_t* _0;
  1252. if(!py_checkint(py_arg(0))) return false;
  1253. _0 = (mmio_t*)py_toint(py_arg(0));
  1254. uintptr_t res = mmio_base(_0);
  1255. py_newint(py_retval(), res);
  1256. return true;
  1257. }
  1258. static bool cfunc__mmio_size(int argc, py_Ref argv) {
  1259. PY_CHECK_ARGC(1);
  1260. mmio_t* _0;
  1261. if(!py_checkint(py_arg(0))) return false;
  1262. _0 = (mmio_t*)py_toint(py_arg(0));
  1263. size_t res = mmio_size(_0);
  1264. py_newint(py_retval(), res);
  1265. return true;
  1266. }
  1267. static bool cfunc__mmio_tostring(int argc, py_Ref argv) {
  1268. PY_CHECK_ARGC(3);
  1269. mmio_t* _0;
  1270. if(!py_checkint(py_arg(0))) return false;
  1271. _0 = (mmio_t*)py_toint(py_arg(0));
  1272. char* _1;
  1273. if(!py_checkint(py_arg(1))) return false;
  1274. _1 = (char*)py_toint(py_arg(1));
  1275. size_t _2;
  1276. if(!py_checkint(py_arg(2))) return false;
  1277. _2 = py_toint(py_arg(2));
  1278. int res = mmio_tostring(_0, _1, _2);
  1279. py_newint(py_retval(), res);
  1280. return true;
  1281. }
  1282. static bool cfunc__mmio_errno(int argc, py_Ref argv) {
  1283. PY_CHECK_ARGC(1);
  1284. mmio_t* _0;
  1285. if(!py_checkint(py_arg(0))) return false;
  1286. _0 = (mmio_t*)py_toint(py_arg(0));
  1287. int res = mmio_errno(_0);
  1288. py_newint(py_retval(), res);
  1289. return true;
  1290. }
  1291. static bool cfunc__mmio_errmsg(int argc, py_Ref argv) {
  1292. PY_CHECK_ARGC(1);
  1293. mmio_t* _0;
  1294. if(!py_checkint(py_arg(0))) return false;
  1295. _0 = (mmio_t*)py_toint(py_arg(0));
  1296. const char* res = mmio_errmsg(_0);
  1297. py_newstr(py_retval(), res);
  1298. return true;
  1299. }
  1300. static bool cfunc__pwm_new(int argc, py_Ref argv) {
  1301. PY_CHECK_ARGC(0);
  1302. pwm_t* res = pwm_new();
  1303. py_newint(py_retval(), (py_i64)res);
  1304. return true;
  1305. }
  1306. static bool cfunc__pwm_open(int argc, py_Ref argv) {
  1307. PY_CHECK_ARGC(3);
  1308. pwm_t* _0;
  1309. if(!py_checkint(py_arg(0))) return false;
  1310. _0 = (pwm_t*)py_toint(py_arg(0));
  1311. unsigned _1;
  1312. if(!py_checkint(py_arg(1))) return false;
  1313. _1 = py_toint(py_arg(1));
  1314. unsigned _2;
  1315. if(!py_checkint(py_arg(2))) return false;
  1316. _2 = py_toint(py_arg(2));
  1317. int res = pwm_open(_0, _1, _2);
  1318. py_newint(py_retval(), res);
  1319. return true;
  1320. }
  1321. static bool cfunc__pwm_enable(int argc, py_Ref argv) {
  1322. PY_CHECK_ARGC(1);
  1323. pwm_t* _0;
  1324. if(!py_checkint(py_arg(0))) return false;
  1325. _0 = (pwm_t*)py_toint(py_arg(0));
  1326. int res = pwm_enable(_0);
  1327. py_newint(py_retval(), res);
  1328. return true;
  1329. }
  1330. static bool cfunc__pwm_disable(int argc, py_Ref argv) {
  1331. PY_CHECK_ARGC(1);
  1332. pwm_t* _0;
  1333. if(!py_checkint(py_arg(0))) return false;
  1334. _0 = (pwm_t*)py_toint(py_arg(0));
  1335. int res = pwm_disable(_0);
  1336. py_newint(py_retval(), res);
  1337. return true;
  1338. }
  1339. static bool cfunc__pwm_close(int argc, py_Ref argv) {
  1340. PY_CHECK_ARGC(1);
  1341. pwm_t* _0;
  1342. if(!py_checkint(py_arg(0))) return false;
  1343. _0 = (pwm_t*)py_toint(py_arg(0));
  1344. int res = pwm_close(_0);
  1345. py_newint(py_retval(), res);
  1346. return true;
  1347. }
  1348. static bool cfunc__pwm_free(int argc, py_Ref argv) {
  1349. PY_CHECK_ARGC(1);
  1350. pwm_t* _0;
  1351. if(!py_checkint(py_arg(0))) return false;
  1352. _0 = (pwm_t*)py_toint(py_arg(0));
  1353. pwm_free(_0);
  1354. py_newnone(py_retval());
  1355. return true;
  1356. }
  1357. static bool cfunc__pwm_get_enabled(int argc, py_Ref argv) {
  1358. PY_CHECK_ARGC(2);
  1359. pwm_t* _0;
  1360. if(!py_checkint(py_arg(0))) return false;
  1361. _0 = (pwm_t*)py_toint(py_arg(0));
  1362. bool* _1;
  1363. if(!py_checkint(py_arg(1))) return false;
  1364. _1 = (bool*)py_toint(py_arg(1));
  1365. int res = pwm_get_enabled(_0, _1);
  1366. py_newint(py_retval(), res);
  1367. return true;
  1368. }
  1369. static bool cfunc__pwm_get_period_ns(int argc, py_Ref argv) {
  1370. PY_CHECK_ARGC(2);
  1371. pwm_t* _0;
  1372. if(!py_checkint(py_arg(0))) return false;
  1373. _0 = (pwm_t*)py_toint(py_arg(0));
  1374. uint64_t* _1;
  1375. if(!py_checkint(py_arg(1))) return false;
  1376. _1 = (uint64_t*)py_toint(py_arg(1));
  1377. int res = pwm_get_period_ns(_0, _1);
  1378. py_newint(py_retval(), res);
  1379. return true;
  1380. }
  1381. static bool cfunc__pwm_get_duty_cycle_ns(int argc, py_Ref argv) {
  1382. PY_CHECK_ARGC(2);
  1383. pwm_t* _0;
  1384. if(!py_checkint(py_arg(0))) return false;
  1385. _0 = (pwm_t*)py_toint(py_arg(0));
  1386. uint64_t* _1;
  1387. if(!py_checkint(py_arg(1))) return false;
  1388. _1 = (uint64_t*)py_toint(py_arg(1));
  1389. int res = pwm_get_duty_cycle_ns(_0, _1);
  1390. py_newint(py_retval(), res);
  1391. return true;
  1392. }
  1393. static bool cfunc__pwm_get_period(int argc, py_Ref argv) {
  1394. PY_CHECK_ARGC(2);
  1395. pwm_t* _0;
  1396. if(!py_checkint(py_arg(0))) return false;
  1397. _0 = (pwm_t*)py_toint(py_arg(0));
  1398. double* _1;
  1399. if(!py_checkint(py_arg(1))) return false;
  1400. _1 = (double*)py_toint(py_arg(1));
  1401. int res = pwm_get_period(_0, _1);
  1402. py_newint(py_retval(), res);
  1403. return true;
  1404. }
  1405. static bool cfunc__pwm_get_duty_cycle(int argc, py_Ref argv) {
  1406. PY_CHECK_ARGC(2);
  1407. pwm_t* _0;
  1408. if(!py_checkint(py_arg(0))) return false;
  1409. _0 = (pwm_t*)py_toint(py_arg(0));
  1410. double* _1;
  1411. if(!py_checkint(py_arg(1))) return false;
  1412. _1 = (double*)py_toint(py_arg(1));
  1413. int res = pwm_get_duty_cycle(_0, _1);
  1414. py_newint(py_retval(), res);
  1415. return true;
  1416. }
  1417. static bool cfunc__pwm_get_frequency(int argc, py_Ref argv) {
  1418. PY_CHECK_ARGC(2);
  1419. pwm_t* _0;
  1420. if(!py_checkint(py_arg(0))) return false;
  1421. _0 = (pwm_t*)py_toint(py_arg(0));
  1422. double* _1;
  1423. if(!py_checkint(py_arg(1))) return false;
  1424. _1 = (double*)py_toint(py_arg(1));
  1425. int res = pwm_get_frequency(_0, _1);
  1426. py_newint(py_retval(), res);
  1427. return true;
  1428. }
  1429. static bool cfunc__pwm_get_polarity(int argc, py_Ref argv) {
  1430. PY_CHECK_ARGC(2);
  1431. pwm_t* _0;
  1432. if(!py_checkint(py_arg(0))) return false;
  1433. _0 = (pwm_t*)py_toint(py_arg(0));
  1434. pwm_polarity_t* _1;
  1435. if(!py_checkint(py_arg(1))) return false;
  1436. _1 = (pwm_polarity_t*)py_toint(py_arg(1));
  1437. int res = pwm_get_polarity(_0, _1);
  1438. py_newint(py_retval(), res);
  1439. return true;
  1440. }
  1441. static bool cfunc__pwm_set_enabled(int argc, py_Ref argv) {
  1442. PY_CHECK_ARGC(2);
  1443. pwm_t* _0;
  1444. if(!py_checkint(py_arg(0))) return false;
  1445. _0 = (pwm_t*)py_toint(py_arg(0));
  1446. bool _1;
  1447. if(!py_checkbool(py_arg(1))) return false;
  1448. _1 = py_tobool(py_arg(1));
  1449. int res = pwm_set_enabled(_0, _1);
  1450. py_newint(py_retval(), res);
  1451. return true;
  1452. }
  1453. static bool cfunc__pwm_set_period_ns(int argc, py_Ref argv) {
  1454. PY_CHECK_ARGC(2);
  1455. pwm_t* _0;
  1456. if(!py_checkint(py_arg(0))) return false;
  1457. _0 = (pwm_t*)py_toint(py_arg(0));
  1458. uint64_t _1;
  1459. if(!py_checkint(py_arg(1))) return false;
  1460. _1 = py_toint(py_arg(1));
  1461. int res = pwm_set_period_ns(_0, _1);
  1462. py_newint(py_retval(), res);
  1463. return true;
  1464. }
  1465. static bool cfunc__pwm_set_duty_cycle_ns(int argc, py_Ref argv) {
  1466. PY_CHECK_ARGC(2);
  1467. pwm_t* _0;
  1468. if(!py_checkint(py_arg(0))) return false;
  1469. _0 = (pwm_t*)py_toint(py_arg(0));
  1470. uint64_t _1;
  1471. if(!py_checkint(py_arg(1))) return false;
  1472. _1 = py_toint(py_arg(1));
  1473. int res = pwm_set_duty_cycle_ns(_0, _1);
  1474. py_newint(py_retval(), res);
  1475. return true;
  1476. }
  1477. static bool cfunc__pwm_set_period(int argc, py_Ref argv) {
  1478. PY_CHECK_ARGC(2);
  1479. pwm_t* _0;
  1480. if(!py_checkint(py_arg(0))) return false;
  1481. _0 = (pwm_t*)py_toint(py_arg(0));
  1482. double _1;
  1483. if(!py_castfloat(py_arg(1), &_1)) return false;
  1484. int res = pwm_set_period(_0, _1);
  1485. py_newint(py_retval(), res);
  1486. return true;
  1487. }
  1488. static bool cfunc__pwm_set_duty_cycle(int argc, py_Ref argv) {
  1489. PY_CHECK_ARGC(2);
  1490. pwm_t* _0;
  1491. if(!py_checkint(py_arg(0))) return false;
  1492. _0 = (pwm_t*)py_toint(py_arg(0));
  1493. double _1;
  1494. if(!py_castfloat(py_arg(1), &_1)) return false;
  1495. int res = pwm_set_duty_cycle(_0, _1);
  1496. py_newint(py_retval(), res);
  1497. return true;
  1498. }
  1499. static bool cfunc__pwm_set_frequency(int argc, py_Ref argv) {
  1500. PY_CHECK_ARGC(2);
  1501. pwm_t* _0;
  1502. if(!py_checkint(py_arg(0))) return false;
  1503. _0 = (pwm_t*)py_toint(py_arg(0));
  1504. double _1;
  1505. if(!py_castfloat(py_arg(1), &_1)) return false;
  1506. int res = pwm_set_frequency(_0, _1);
  1507. py_newint(py_retval(), res);
  1508. return true;
  1509. }
  1510. static bool cfunc__pwm_set_polarity(int argc, py_Ref argv) {
  1511. PY_CHECK_ARGC(2);
  1512. pwm_t* _0;
  1513. if(!py_checkint(py_arg(0))) return false;
  1514. _0 = (pwm_t*)py_toint(py_arg(0));
  1515. pwm_polarity_t _1;
  1516. if(!py_checkint(py_arg(1))) return false;
  1517. _1 = (pwm_polarity_t)py_toint(py_arg(1));
  1518. int res = pwm_set_polarity(_0, _1);
  1519. py_newint(py_retval(), res);
  1520. return true;
  1521. }
  1522. static bool cfunc__pwm_chip(int argc, py_Ref argv) {
  1523. PY_CHECK_ARGC(1);
  1524. pwm_t* _0;
  1525. if(!py_checkint(py_arg(0))) return false;
  1526. _0 = (pwm_t*)py_toint(py_arg(0));
  1527. unsigned res = pwm_chip(_0);
  1528. py_newint(py_retval(), res);
  1529. return true;
  1530. }
  1531. static bool cfunc__pwm_channel(int argc, py_Ref argv) {
  1532. PY_CHECK_ARGC(1);
  1533. pwm_t* _0;
  1534. if(!py_checkint(py_arg(0))) return false;
  1535. _0 = (pwm_t*)py_toint(py_arg(0));
  1536. unsigned res = pwm_channel(_0);
  1537. py_newint(py_retval(), res);
  1538. return true;
  1539. }
  1540. static bool cfunc__pwm_tostring(int argc, py_Ref argv) {
  1541. PY_CHECK_ARGC(3);
  1542. pwm_t* _0;
  1543. if(!py_checkint(py_arg(0))) return false;
  1544. _0 = (pwm_t*)py_toint(py_arg(0));
  1545. char* _1;
  1546. if(!py_checkint(py_arg(1))) return false;
  1547. _1 = (char*)py_toint(py_arg(1));
  1548. size_t _2;
  1549. if(!py_checkint(py_arg(2))) return false;
  1550. _2 = py_toint(py_arg(2));
  1551. int res = pwm_tostring(_0, _1, _2);
  1552. py_newint(py_retval(), res);
  1553. return true;
  1554. }
  1555. static bool cfunc__pwm_errno(int argc, py_Ref argv) {
  1556. PY_CHECK_ARGC(1);
  1557. pwm_t* _0;
  1558. if(!py_checkint(py_arg(0))) return false;
  1559. _0 = (pwm_t*)py_toint(py_arg(0));
  1560. int res = pwm_errno(_0);
  1561. py_newint(py_retval(), res);
  1562. return true;
  1563. }
  1564. static bool cfunc__pwm_errmsg(int argc, py_Ref argv) {
  1565. PY_CHECK_ARGC(1);
  1566. pwm_t* _0;
  1567. if(!py_checkint(py_arg(0))) return false;
  1568. _0 = (pwm_t*)py_toint(py_arg(0));
  1569. const char* res = pwm_errmsg(_0);
  1570. py_newstr(py_retval(), res);
  1571. return true;
  1572. }
  1573. static bool cfunc__serial_new(int argc, py_Ref argv) {
  1574. PY_CHECK_ARGC(0);
  1575. serial_t* res = serial_new();
  1576. py_newint(py_retval(), (py_i64)res);
  1577. return true;
  1578. }
  1579. static bool cfunc__serial_open(int argc, py_Ref argv) {
  1580. PY_CHECK_ARGC(3);
  1581. serial_t* _0;
  1582. if(!py_checkint(py_arg(0))) return false;
  1583. _0 = (serial_t*)py_toint(py_arg(0));
  1584. const char* _1;
  1585. if(!py_checkstr(py_arg(1))) return false;
  1586. _1 = py_tostr(py_arg(1));
  1587. uint32_t _2;
  1588. if(!py_checkint(py_arg(2))) return false;
  1589. _2 = py_toint(py_arg(2));
  1590. int res = serial_open(_0, _1, _2);
  1591. py_newint(py_retval(), res);
  1592. return true;
  1593. }
  1594. static bool cfunc__serial_open_advanced(int argc, py_Ref argv) {
  1595. PY_CHECK_ARGC(8);
  1596. serial_t* _0;
  1597. if(!py_checkint(py_arg(0))) return false;
  1598. _0 = (serial_t*)py_toint(py_arg(0));
  1599. const char* _1;
  1600. if(!py_checkstr(py_arg(1))) return false;
  1601. _1 = py_tostr(py_arg(1));
  1602. uint32_t _2;
  1603. if(!py_checkint(py_arg(2))) return false;
  1604. _2 = py_toint(py_arg(2));
  1605. unsigned _3;
  1606. if(!py_checkint(py_arg(3))) return false;
  1607. _3 = py_toint(py_arg(3));
  1608. serial_parity_t _4;
  1609. if(!py_checkint(py_arg(4))) return false;
  1610. _4 = (serial_parity_t)py_toint(py_arg(4));
  1611. unsigned _5;
  1612. if(!py_checkint(py_arg(5))) return false;
  1613. _5 = py_toint(py_arg(5));
  1614. bool _6;
  1615. if(!py_checkbool(py_arg(6))) return false;
  1616. _6 = py_tobool(py_arg(6));
  1617. bool _7;
  1618. if(!py_checkbool(py_arg(7))) return false;
  1619. _7 = py_tobool(py_arg(7));
  1620. int res = serial_open_advanced(_0, _1, _2, _3, _4, _5, _6, _7);
  1621. py_newint(py_retval(), res);
  1622. return true;
  1623. }
  1624. static bool cfunc__serial_read(int argc, py_Ref argv) {
  1625. PY_CHECK_ARGC(4);
  1626. serial_t* _0;
  1627. if(!py_checkint(py_arg(0))) return false;
  1628. _0 = (serial_t*)py_toint(py_arg(0));
  1629. uint8_t* _1;
  1630. if(!py_checkint(py_arg(1))) return false;
  1631. _1 = (uint8_t*)py_toint(py_arg(1));
  1632. size_t _2;
  1633. if(!py_checkint(py_arg(2))) return false;
  1634. _2 = py_toint(py_arg(2));
  1635. int _3;
  1636. if(!py_checkint(py_arg(3))) return false;
  1637. _3 = py_toint(py_arg(3));
  1638. int res = serial_read(_0, _1, _2, _3);
  1639. py_newint(py_retval(), res);
  1640. return true;
  1641. }
  1642. static bool cfunc__serial_write(int argc, py_Ref argv) {
  1643. PY_CHECK_ARGC(3);
  1644. serial_t* _0;
  1645. if(!py_checkint(py_arg(0))) return false;
  1646. _0 = (serial_t*)py_toint(py_arg(0));
  1647. const uint8_t* _1;
  1648. if(!py_checkint(py_arg(1))) return false;
  1649. _1 = (const uint8_t*)py_toint(py_arg(1));
  1650. size_t _2;
  1651. if(!py_checkint(py_arg(2))) return false;
  1652. _2 = py_toint(py_arg(2));
  1653. int res = serial_write(_0, _1, _2);
  1654. py_newint(py_retval(), res);
  1655. return true;
  1656. }
  1657. static bool cfunc__serial_flush(int argc, py_Ref argv) {
  1658. PY_CHECK_ARGC(1);
  1659. serial_t* _0;
  1660. if(!py_checkint(py_arg(0))) return false;
  1661. _0 = (serial_t*)py_toint(py_arg(0));
  1662. int res = serial_flush(_0);
  1663. py_newint(py_retval(), res);
  1664. return true;
  1665. }
  1666. static bool cfunc__serial_input_waiting(int argc, py_Ref argv) {
  1667. PY_CHECK_ARGC(2);
  1668. serial_t* _0;
  1669. if(!py_checkint(py_arg(0))) return false;
  1670. _0 = (serial_t*)py_toint(py_arg(0));
  1671. unsigned* _1;
  1672. if(!py_checkint(py_arg(1))) return false;
  1673. _1 = (unsigned*)py_toint(py_arg(1));
  1674. int res = serial_input_waiting(_0, _1);
  1675. py_newint(py_retval(), res);
  1676. return true;
  1677. }
  1678. static bool cfunc__serial_output_waiting(int argc, py_Ref argv) {
  1679. PY_CHECK_ARGC(2);
  1680. serial_t* _0;
  1681. if(!py_checkint(py_arg(0))) return false;
  1682. _0 = (serial_t*)py_toint(py_arg(0));
  1683. unsigned* _1;
  1684. if(!py_checkint(py_arg(1))) return false;
  1685. _1 = (unsigned*)py_toint(py_arg(1));
  1686. int res = serial_output_waiting(_0, _1);
  1687. py_newint(py_retval(), res);
  1688. return true;
  1689. }
  1690. static bool cfunc__serial_poll(int argc, py_Ref argv) {
  1691. PY_CHECK_ARGC(2);
  1692. serial_t* _0;
  1693. if(!py_checkint(py_arg(0))) return false;
  1694. _0 = (serial_t*)py_toint(py_arg(0));
  1695. int _1;
  1696. if(!py_checkint(py_arg(1))) return false;
  1697. _1 = py_toint(py_arg(1));
  1698. int res = serial_poll(_0, _1);
  1699. py_newint(py_retval(), res);
  1700. return true;
  1701. }
  1702. static bool cfunc__serial_close(int argc, py_Ref argv) {
  1703. PY_CHECK_ARGC(1);
  1704. serial_t* _0;
  1705. if(!py_checkint(py_arg(0))) return false;
  1706. _0 = (serial_t*)py_toint(py_arg(0));
  1707. int res = serial_close(_0);
  1708. py_newint(py_retval(), res);
  1709. return true;
  1710. }
  1711. static bool cfunc__serial_free(int argc, py_Ref argv) {
  1712. PY_CHECK_ARGC(1);
  1713. serial_t* _0;
  1714. if(!py_checkint(py_arg(0))) return false;
  1715. _0 = (serial_t*)py_toint(py_arg(0));
  1716. serial_free(_0);
  1717. py_newnone(py_retval());
  1718. return true;
  1719. }
  1720. static bool cfunc__serial_get_baudrate(int argc, py_Ref argv) {
  1721. PY_CHECK_ARGC(2);
  1722. serial_t* _0;
  1723. if(!py_checkint(py_arg(0))) return false;
  1724. _0 = (serial_t*)py_toint(py_arg(0));
  1725. uint32_t* _1;
  1726. if(!py_checkint(py_arg(1))) return false;
  1727. _1 = (uint32_t*)py_toint(py_arg(1));
  1728. int res = serial_get_baudrate(_0, _1);
  1729. py_newint(py_retval(), res);
  1730. return true;
  1731. }
  1732. static bool cfunc__serial_get_databits(int argc, py_Ref argv) {
  1733. PY_CHECK_ARGC(2);
  1734. serial_t* _0;
  1735. if(!py_checkint(py_arg(0))) return false;
  1736. _0 = (serial_t*)py_toint(py_arg(0));
  1737. unsigned* _1;
  1738. if(!py_checkint(py_arg(1))) return false;
  1739. _1 = (unsigned*)py_toint(py_arg(1));
  1740. int res = serial_get_databits(_0, _1);
  1741. py_newint(py_retval(), res);
  1742. return true;
  1743. }
  1744. static bool cfunc__serial_get_parity(int argc, py_Ref argv) {
  1745. PY_CHECK_ARGC(2);
  1746. serial_t* _0;
  1747. if(!py_checkint(py_arg(0))) return false;
  1748. _0 = (serial_t*)py_toint(py_arg(0));
  1749. serial_parity_t* _1;
  1750. if(!py_checkint(py_arg(1))) return false;
  1751. _1 = (serial_parity_t*)py_toint(py_arg(1));
  1752. int res = serial_get_parity(_0, _1);
  1753. py_newint(py_retval(), res);
  1754. return true;
  1755. }
  1756. static bool cfunc__serial_get_stopbits(int argc, py_Ref argv) {
  1757. PY_CHECK_ARGC(2);
  1758. serial_t* _0;
  1759. if(!py_checkint(py_arg(0))) return false;
  1760. _0 = (serial_t*)py_toint(py_arg(0));
  1761. unsigned* _1;
  1762. if(!py_checkint(py_arg(1))) return false;
  1763. _1 = (unsigned*)py_toint(py_arg(1));
  1764. int res = serial_get_stopbits(_0, _1);
  1765. py_newint(py_retval(), res);
  1766. return true;
  1767. }
  1768. static bool cfunc__serial_get_xonxoff(int argc, py_Ref argv) {
  1769. PY_CHECK_ARGC(2);
  1770. serial_t* _0;
  1771. if(!py_checkint(py_arg(0))) return false;
  1772. _0 = (serial_t*)py_toint(py_arg(0));
  1773. bool* _1;
  1774. if(!py_checkint(py_arg(1))) return false;
  1775. _1 = (bool*)py_toint(py_arg(1));
  1776. int res = serial_get_xonxoff(_0, _1);
  1777. py_newint(py_retval(), res);
  1778. return true;
  1779. }
  1780. static bool cfunc__serial_get_rtscts(int argc, py_Ref argv) {
  1781. PY_CHECK_ARGC(2);
  1782. serial_t* _0;
  1783. if(!py_checkint(py_arg(0))) return false;
  1784. _0 = (serial_t*)py_toint(py_arg(0));
  1785. bool* _1;
  1786. if(!py_checkint(py_arg(1))) return false;
  1787. _1 = (bool*)py_toint(py_arg(1));
  1788. int res = serial_get_rtscts(_0, _1);
  1789. py_newint(py_retval(), res);
  1790. return true;
  1791. }
  1792. static bool cfunc__serial_get_vmin(int argc, py_Ref argv) {
  1793. PY_CHECK_ARGC(2);
  1794. serial_t* _0;
  1795. if(!py_checkint(py_arg(0))) return false;
  1796. _0 = (serial_t*)py_toint(py_arg(0));
  1797. unsigned* _1;
  1798. if(!py_checkint(py_arg(1))) return false;
  1799. _1 = (unsigned*)py_toint(py_arg(1));
  1800. int res = serial_get_vmin(_0, _1);
  1801. py_newint(py_retval(), res);
  1802. return true;
  1803. }
  1804. static bool cfunc__serial_get_vtime(int argc, py_Ref argv) {
  1805. PY_CHECK_ARGC(2);
  1806. serial_t* _0;
  1807. if(!py_checkint(py_arg(0))) return false;
  1808. _0 = (serial_t*)py_toint(py_arg(0));
  1809. float* _1;
  1810. if(!py_checkint(py_arg(1))) return false;
  1811. _1 = (float*)py_toint(py_arg(1));
  1812. int res = serial_get_vtime(_0, _1);
  1813. py_newint(py_retval(), res);
  1814. return true;
  1815. }
  1816. static bool cfunc__serial_set_baudrate(int argc, py_Ref argv) {
  1817. PY_CHECK_ARGC(2);
  1818. serial_t* _0;
  1819. if(!py_checkint(py_arg(0))) return false;
  1820. _0 = (serial_t*)py_toint(py_arg(0));
  1821. uint32_t _1;
  1822. if(!py_checkint(py_arg(1))) return false;
  1823. _1 = py_toint(py_arg(1));
  1824. int res = serial_set_baudrate(_0, _1);
  1825. py_newint(py_retval(), res);
  1826. return true;
  1827. }
  1828. static bool cfunc__serial_set_databits(int argc, py_Ref argv) {
  1829. PY_CHECK_ARGC(2);
  1830. serial_t* _0;
  1831. if(!py_checkint(py_arg(0))) return false;
  1832. _0 = (serial_t*)py_toint(py_arg(0));
  1833. unsigned _1;
  1834. if(!py_checkint(py_arg(1))) return false;
  1835. _1 = py_toint(py_arg(1));
  1836. int res = serial_set_databits(_0, _1);
  1837. py_newint(py_retval(), res);
  1838. return true;
  1839. }
  1840. static bool cfunc__serial_set_parity(int argc, py_Ref argv) {
  1841. PY_CHECK_ARGC(2);
  1842. serial_t* _0;
  1843. if(!py_checkint(py_arg(0))) return false;
  1844. _0 = (serial_t*)py_toint(py_arg(0));
  1845. serial_parity_t _1;
  1846. if(!py_checkint(py_arg(1))) return false;
  1847. _1 = (serial_parity_t)py_toint(py_arg(1));
  1848. int res = serial_set_parity(_0, _1);
  1849. py_newint(py_retval(), res);
  1850. return true;
  1851. }
  1852. static bool cfunc__serial_set_stopbits(int argc, py_Ref argv) {
  1853. PY_CHECK_ARGC(2);
  1854. serial_t* _0;
  1855. if(!py_checkint(py_arg(0))) return false;
  1856. _0 = (serial_t*)py_toint(py_arg(0));
  1857. unsigned _1;
  1858. if(!py_checkint(py_arg(1))) return false;
  1859. _1 = py_toint(py_arg(1));
  1860. int res = serial_set_stopbits(_0, _1);
  1861. py_newint(py_retval(), res);
  1862. return true;
  1863. }
  1864. static bool cfunc__serial_set_xonxoff(int argc, py_Ref argv) {
  1865. PY_CHECK_ARGC(2);
  1866. serial_t* _0;
  1867. if(!py_checkint(py_arg(0))) return false;
  1868. _0 = (serial_t*)py_toint(py_arg(0));
  1869. bool _1;
  1870. if(!py_checkbool(py_arg(1))) return false;
  1871. _1 = py_tobool(py_arg(1));
  1872. int res = serial_set_xonxoff(_0, _1);
  1873. py_newint(py_retval(), res);
  1874. return true;
  1875. }
  1876. static bool cfunc__serial_set_rtscts(int argc, py_Ref argv) {
  1877. PY_CHECK_ARGC(2);
  1878. serial_t* _0;
  1879. if(!py_checkint(py_arg(0))) return false;
  1880. _0 = (serial_t*)py_toint(py_arg(0));
  1881. bool _1;
  1882. if(!py_checkbool(py_arg(1))) return false;
  1883. _1 = py_tobool(py_arg(1));
  1884. int res = serial_set_rtscts(_0, _1);
  1885. py_newint(py_retval(), res);
  1886. return true;
  1887. }
  1888. static bool cfunc__serial_set_vmin(int argc, py_Ref argv) {
  1889. PY_CHECK_ARGC(2);
  1890. serial_t* _0;
  1891. if(!py_checkint(py_arg(0))) return false;
  1892. _0 = (serial_t*)py_toint(py_arg(0));
  1893. unsigned _1;
  1894. if(!py_checkint(py_arg(1))) return false;
  1895. _1 = py_toint(py_arg(1));
  1896. int res = serial_set_vmin(_0, _1);
  1897. py_newint(py_retval(), res);
  1898. return true;
  1899. }
  1900. static bool cfunc__serial_set_vtime(int argc, py_Ref argv) {
  1901. PY_CHECK_ARGC(2);
  1902. serial_t* _0;
  1903. if(!py_checkint(py_arg(0))) return false;
  1904. _0 = (serial_t*)py_toint(py_arg(0));
  1905. float _1;
  1906. if(!py_castfloat32(py_arg(1), &_1)) return false;
  1907. int res = serial_set_vtime(_0, _1);
  1908. py_newint(py_retval(), res);
  1909. return true;
  1910. }
  1911. static bool cfunc__serial_fd(int argc, py_Ref argv) {
  1912. PY_CHECK_ARGC(1);
  1913. serial_t* _0;
  1914. if(!py_checkint(py_arg(0))) return false;
  1915. _0 = (serial_t*)py_toint(py_arg(0));
  1916. int res = serial_fd(_0);
  1917. py_newint(py_retval(), res);
  1918. return true;
  1919. }
  1920. static bool cfunc__serial_tostring(int argc, py_Ref argv) {
  1921. PY_CHECK_ARGC(3);
  1922. serial_t* _0;
  1923. if(!py_checkint(py_arg(0))) return false;
  1924. _0 = (serial_t*)py_toint(py_arg(0));
  1925. char* _1;
  1926. if(!py_checkint(py_arg(1))) return false;
  1927. _1 = (char*)py_toint(py_arg(1));
  1928. size_t _2;
  1929. if(!py_checkint(py_arg(2))) return false;
  1930. _2 = py_toint(py_arg(2));
  1931. int res = serial_tostring(_0, _1, _2);
  1932. py_newint(py_retval(), res);
  1933. return true;
  1934. }
  1935. static bool cfunc__serial_errno(int argc, py_Ref argv) {
  1936. PY_CHECK_ARGC(1);
  1937. serial_t* _0;
  1938. if(!py_checkint(py_arg(0))) return false;
  1939. _0 = (serial_t*)py_toint(py_arg(0));
  1940. int res = serial_errno(_0);
  1941. py_newint(py_retval(), res);
  1942. return true;
  1943. }
  1944. static bool cfunc__serial_errmsg(int argc, py_Ref argv) {
  1945. PY_CHECK_ARGC(1);
  1946. serial_t* _0;
  1947. if(!py_checkint(py_arg(0))) return false;
  1948. _0 = (serial_t*)py_toint(py_arg(0));
  1949. const char* res = serial_errmsg(_0);
  1950. py_newstr(py_retval(), res);
  1951. return true;
  1952. }
  1953. static bool cfunc__spi_new(int argc, py_Ref argv) {
  1954. PY_CHECK_ARGC(0);
  1955. spi_t* res = spi_new();
  1956. py_newint(py_retval(), (py_i64)res);
  1957. return true;
  1958. }
  1959. static bool cfunc__spi_open(int argc, py_Ref argv) {
  1960. PY_CHECK_ARGC(4);
  1961. spi_t* _0;
  1962. if(!py_checkint(py_arg(0))) return false;
  1963. _0 = (spi_t*)py_toint(py_arg(0));
  1964. const char* _1;
  1965. if(!py_checkstr(py_arg(1))) return false;
  1966. _1 = py_tostr(py_arg(1));
  1967. unsigned _2;
  1968. if(!py_checkint(py_arg(2))) return false;
  1969. _2 = py_toint(py_arg(2));
  1970. uint32_t _3;
  1971. if(!py_checkint(py_arg(3))) return false;
  1972. _3 = py_toint(py_arg(3));
  1973. int res = spi_open(_0, _1, _2, _3);
  1974. py_newint(py_retval(), res);
  1975. return true;
  1976. }
  1977. static bool cfunc__spi_open_advanced(int argc, py_Ref argv) {
  1978. PY_CHECK_ARGC(7);
  1979. spi_t* _0;
  1980. if(!py_checkint(py_arg(0))) return false;
  1981. _0 = (spi_t*)py_toint(py_arg(0));
  1982. const char* _1;
  1983. if(!py_checkstr(py_arg(1))) return false;
  1984. _1 = py_tostr(py_arg(1));
  1985. unsigned _2;
  1986. if(!py_checkint(py_arg(2))) return false;
  1987. _2 = py_toint(py_arg(2));
  1988. uint32_t _3;
  1989. if(!py_checkint(py_arg(3))) return false;
  1990. _3 = py_toint(py_arg(3));
  1991. spi_bit_order_t _4;
  1992. if(!py_checkint(py_arg(4))) return false;
  1993. _4 = (spi_bit_order_t)py_toint(py_arg(4));
  1994. uint8_t _5;
  1995. if(!py_checkint(py_arg(5))) return false;
  1996. _5 = py_toint(py_arg(5));
  1997. uint8_t _6;
  1998. if(!py_checkint(py_arg(6))) return false;
  1999. _6 = py_toint(py_arg(6));
  2000. int res = spi_open_advanced(_0, _1, _2, _3, _4, _5, _6);
  2001. py_newint(py_retval(), res);
  2002. return true;
  2003. }
  2004. static bool cfunc__spi_open_advanced2(int argc, py_Ref argv) {
  2005. PY_CHECK_ARGC(7);
  2006. spi_t* _0;
  2007. if(!py_checkint(py_arg(0))) return false;
  2008. _0 = (spi_t*)py_toint(py_arg(0));
  2009. const char* _1;
  2010. if(!py_checkstr(py_arg(1))) return false;
  2011. _1 = py_tostr(py_arg(1));
  2012. unsigned _2;
  2013. if(!py_checkint(py_arg(2))) return false;
  2014. _2 = py_toint(py_arg(2));
  2015. uint32_t _3;
  2016. if(!py_checkint(py_arg(3))) return false;
  2017. _3 = py_toint(py_arg(3));
  2018. spi_bit_order_t _4;
  2019. if(!py_checkint(py_arg(4))) return false;
  2020. _4 = (spi_bit_order_t)py_toint(py_arg(4));
  2021. uint8_t _5;
  2022. if(!py_checkint(py_arg(5))) return false;
  2023. _5 = py_toint(py_arg(5));
  2024. uint32_t _6;
  2025. if(!py_checkint(py_arg(6))) return false;
  2026. _6 = py_toint(py_arg(6));
  2027. int res = spi_open_advanced2(_0, _1, _2, _3, _4, _5, _6);
  2028. py_newint(py_retval(), res);
  2029. return true;
  2030. }
  2031. static bool cfunc__spi_transfer(int argc, py_Ref argv) {
  2032. PY_CHECK_ARGC(4);
  2033. spi_t* _0;
  2034. if(!py_checkint(py_arg(0))) return false;
  2035. _0 = (spi_t*)py_toint(py_arg(0));
  2036. const uint8_t* _1;
  2037. if(!py_checkint(py_arg(1))) return false;
  2038. _1 = (const uint8_t*)py_toint(py_arg(1));
  2039. uint8_t* _2;
  2040. if(!py_checkint(py_arg(2))) return false;
  2041. _2 = (uint8_t*)py_toint(py_arg(2));
  2042. size_t _3;
  2043. if(!py_checkint(py_arg(3))) return false;
  2044. _3 = py_toint(py_arg(3));
  2045. int res = spi_transfer(_0, _1, _2, _3);
  2046. py_newint(py_retval(), res);
  2047. return true;
  2048. }
  2049. static bool cfunc__spi_transfer_advanced(int argc, py_Ref argv) {
  2050. PY_CHECK_ARGC(3);
  2051. spi_t* _0;
  2052. if(!py_checkint(py_arg(0))) return false;
  2053. _0 = (spi_t*)py_toint(py_arg(0));
  2054. const spi_msg_t* _1;
  2055. if(!py_checkint(py_arg(1))) return false;
  2056. _1 = (const spi_msg_t*)py_toint(py_arg(1));
  2057. size_t _2;
  2058. if(!py_checkint(py_arg(2))) return false;
  2059. _2 = py_toint(py_arg(2));
  2060. int res = spi_transfer_advanced(_0, _1, _2);
  2061. py_newint(py_retval(), res);
  2062. return true;
  2063. }
  2064. static bool cfunc__spi_close(int argc, py_Ref argv) {
  2065. PY_CHECK_ARGC(1);
  2066. spi_t* _0;
  2067. if(!py_checkint(py_arg(0))) return false;
  2068. _0 = (spi_t*)py_toint(py_arg(0));
  2069. int res = spi_close(_0);
  2070. py_newint(py_retval(), res);
  2071. return true;
  2072. }
  2073. static bool cfunc__spi_free(int argc, py_Ref argv) {
  2074. PY_CHECK_ARGC(1);
  2075. spi_t* _0;
  2076. if(!py_checkint(py_arg(0))) return false;
  2077. _0 = (spi_t*)py_toint(py_arg(0));
  2078. spi_free(_0);
  2079. py_newnone(py_retval());
  2080. return true;
  2081. }
  2082. static bool cfunc__spi_get_mode(int argc, py_Ref argv) {
  2083. PY_CHECK_ARGC(2);
  2084. spi_t* _0;
  2085. if(!py_checkint(py_arg(0))) return false;
  2086. _0 = (spi_t*)py_toint(py_arg(0));
  2087. unsigned* _1;
  2088. if(!py_checkint(py_arg(1))) return false;
  2089. _1 = (unsigned*)py_toint(py_arg(1));
  2090. int res = spi_get_mode(_0, _1);
  2091. py_newint(py_retval(), res);
  2092. return true;
  2093. }
  2094. static bool cfunc__spi_get_max_speed(int argc, py_Ref argv) {
  2095. PY_CHECK_ARGC(2);
  2096. spi_t* _0;
  2097. if(!py_checkint(py_arg(0))) return false;
  2098. _0 = (spi_t*)py_toint(py_arg(0));
  2099. uint32_t* _1;
  2100. if(!py_checkint(py_arg(1))) return false;
  2101. _1 = (uint32_t*)py_toint(py_arg(1));
  2102. int res = spi_get_max_speed(_0, _1);
  2103. py_newint(py_retval(), res);
  2104. return true;
  2105. }
  2106. static bool cfunc__spi_get_bit_order(int argc, py_Ref argv) {
  2107. PY_CHECK_ARGC(2);
  2108. spi_t* _0;
  2109. if(!py_checkint(py_arg(0))) return false;
  2110. _0 = (spi_t*)py_toint(py_arg(0));
  2111. spi_bit_order_t* _1;
  2112. if(!py_checkint(py_arg(1))) return false;
  2113. _1 = (spi_bit_order_t*)py_toint(py_arg(1));
  2114. int res = spi_get_bit_order(_0, _1);
  2115. py_newint(py_retval(), res);
  2116. return true;
  2117. }
  2118. static bool cfunc__spi_get_bits_per_word(int argc, py_Ref argv) {
  2119. PY_CHECK_ARGC(2);
  2120. spi_t* _0;
  2121. if(!py_checkint(py_arg(0))) return false;
  2122. _0 = (spi_t*)py_toint(py_arg(0));
  2123. uint8_t* _1;
  2124. if(!py_checkint(py_arg(1))) return false;
  2125. _1 = (uint8_t*)py_toint(py_arg(1));
  2126. int res = spi_get_bits_per_word(_0, _1);
  2127. py_newint(py_retval(), res);
  2128. return true;
  2129. }
  2130. static bool cfunc__spi_get_extra_flags(int argc, py_Ref argv) {
  2131. PY_CHECK_ARGC(2);
  2132. spi_t* _0;
  2133. if(!py_checkint(py_arg(0))) return false;
  2134. _0 = (spi_t*)py_toint(py_arg(0));
  2135. uint8_t* _1;
  2136. if(!py_checkint(py_arg(1))) return false;
  2137. _1 = (uint8_t*)py_toint(py_arg(1));
  2138. int res = spi_get_extra_flags(_0, _1);
  2139. py_newint(py_retval(), res);
  2140. return true;
  2141. }
  2142. static bool cfunc__spi_get_extra_flags32(int argc, py_Ref argv) {
  2143. PY_CHECK_ARGC(2);
  2144. spi_t* _0;
  2145. if(!py_checkint(py_arg(0))) return false;
  2146. _0 = (spi_t*)py_toint(py_arg(0));
  2147. uint32_t* _1;
  2148. if(!py_checkint(py_arg(1))) return false;
  2149. _1 = (uint32_t*)py_toint(py_arg(1));
  2150. int res = spi_get_extra_flags32(_0, _1);
  2151. py_newint(py_retval(), res);
  2152. return true;
  2153. }
  2154. static bool cfunc__spi_set_mode(int argc, py_Ref argv) {
  2155. PY_CHECK_ARGC(2);
  2156. spi_t* _0;
  2157. if(!py_checkint(py_arg(0))) return false;
  2158. _0 = (spi_t*)py_toint(py_arg(0));
  2159. unsigned _1;
  2160. if(!py_checkint(py_arg(1))) return false;
  2161. _1 = py_toint(py_arg(1));
  2162. int res = spi_set_mode(_0, _1);
  2163. py_newint(py_retval(), res);
  2164. return true;
  2165. }
  2166. static bool cfunc__spi_set_max_speed(int argc, py_Ref argv) {
  2167. PY_CHECK_ARGC(2);
  2168. spi_t* _0;
  2169. if(!py_checkint(py_arg(0))) return false;
  2170. _0 = (spi_t*)py_toint(py_arg(0));
  2171. uint32_t _1;
  2172. if(!py_checkint(py_arg(1))) return false;
  2173. _1 = py_toint(py_arg(1));
  2174. int res = spi_set_max_speed(_0, _1);
  2175. py_newint(py_retval(), res);
  2176. return true;
  2177. }
  2178. static bool cfunc__spi_set_bit_order(int argc, py_Ref argv) {
  2179. PY_CHECK_ARGC(2);
  2180. spi_t* _0;
  2181. if(!py_checkint(py_arg(0))) return false;
  2182. _0 = (spi_t*)py_toint(py_arg(0));
  2183. spi_bit_order_t _1;
  2184. if(!py_checkint(py_arg(1))) return false;
  2185. _1 = (spi_bit_order_t)py_toint(py_arg(1));
  2186. int res = spi_set_bit_order(_0, _1);
  2187. py_newint(py_retval(), res);
  2188. return true;
  2189. }
  2190. static bool cfunc__spi_set_bits_per_word(int argc, py_Ref argv) {
  2191. PY_CHECK_ARGC(2);
  2192. spi_t* _0;
  2193. if(!py_checkint(py_arg(0))) return false;
  2194. _0 = (spi_t*)py_toint(py_arg(0));
  2195. uint8_t _1;
  2196. if(!py_checkint(py_arg(1))) return false;
  2197. _1 = py_toint(py_arg(1));
  2198. int res = spi_set_bits_per_word(_0, _1);
  2199. py_newint(py_retval(), res);
  2200. return true;
  2201. }
  2202. static bool cfunc__spi_set_extra_flags(int argc, py_Ref argv) {
  2203. PY_CHECK_ARGC(2);
  2204. spi_t* _0;
  2205. if(!py_checkint(py_arg(0))) return false;
  2206. _0 = (spi_t*)py_toint(py_arg(0));
  2207. uint8_t _1;
  2208. if(!py_checkint(py_arg(1))) return false;
  2209. _1 = py_toint(py_arg(1));
  2210. int res = spi_set_extra_flags(_0, _1);
  2211. py_newint(py_retval(), res);
  2212. return true;
  2213. }
  2214. static bool cfunc__spi_set_extra_flags32(int argc, py_Ref argv) {
  2215. PY_CHECK_ARGC(2);
  2216. spi_t* _0;
  2217. if(!py_checkint(py_arg(0))) return false;
  2218. _0 = (spi_t*)py_toint(py_arg(0));
  2219. uint32_t _1;
  2220. if(!py_checkint(py_arg(1))) return false;
  2221. _1 = py_toint(py_arg(1));
  2222. int res = spi_set_extra_flags32(_0, _1);
  2223. py_newint(py_retval(), res);
  2224. return true;
  2225. }
  2226. static bool cfunc__spi_fd(int argc, py_Ref argv) {
  2227. PY_CHECK_ARGC(1);
  2228. spi_t* _0;
  2229. if(!py_checkint(py_arg(0))) return false;
  2230. _0 = (spi_t*)py_toint(py_arg(0));
  2231. int res = spi_fd(_0);
  2232. py_newint(py_retval(), res);
  2233. return true;
  2234. }
  2235. static bool cfunc__spi_tostring(int argc, py_Ref argv) {
  2236. PY_CHECK_ARGC(3);
  2237. spi_t* _0;
  2238. if(!py_checkint(py_arg(0))) return false;
  2239. _0 = (spi_t*)py_toint(py_arg(0));
  2240. char* _1;
  2241. if(!py_checkint(py_arg(1))) return false;
  2242. _1 = (char*)py_toint(py_arg(1));
  2243. size_t _2;
  2244. if(!py_checkint(py_arg(2))) return false;
  2245. _2 = py_toint(py_arg(2));
  2246. int res = spi_tostring(_0, _1, _2);
  2247. py_newint(py_retval(), res);
  2248. return true;
  2249. }
  2250. static bool cfunc__spi_errno(int argc, py_Ref argv) {
  2251. PY_CHECK_ARGC(1);
  2252. spi_t* _0;
  2253. if(!py_checkint(py_arg(0))) return false;
  2254. _0 = (spi_t*)py_toint(py_arg(0));
  2255. int res = spi_errno(_0);
  2256. py_newint(py_retval(), res);
  2257. return true;
  2258. }
  2259. static bool cfunc__spi_errmsg(int argc, py_Ref argv) {
  2260. PY_CHECK_ARGC(1);
  2261. spi_t* _0;
  2262. if(!py_checkint(py_arg(0))) return false;
  2263. _0 = (spi_t*)py_toint(py_arg(0));
  2264. const char* res = spi_errmsg(_0);
  2265. py_newstr(py_retval(), res);
  2266. return true;
  2267. }
  2268. static bool cfunc__periphery_version(int argc, py_Ref argv) {
  2269. PY_CHECK_ARGC(0);
  2270. const char* res = periphery_version();
  2271. py_newstr(py_retval(), res);
  2272. return true;
  2273. }
  2274. static bool cfunc__periphery_version_info(int argc, py_Ref argv) {
  2275. PY_CHECK_ARGC(0);
  2276. const periphery_version_t* res = periphery_version_info();
  2277. py_newint(py_retval(), (py_i64)res);
  2278. return true;
  2279. }
  2280. void py__add_module_periphery() {
  2281. py_GlobalRef mod = py_newmodule("periphery");
  2282. /* structs */
  2283. tp_user_gpio_config = register__gpio_config(mod);
  2284. tp_user_spi_msg = register__spi_msg(mod);
  2285. tp_user_periphery_version = register__periphery_version(mod);
  2286. /* aliases */
  2287. py_setdict(mod, py_name("gpio_direction_t"), py_tpobject(tp_int));
  2288. py_setdict(mod, py_name("gpio_edge_t"), py_tpobject(tp_int));
  2289. py_setdict(mod, py_name("gpio_event_clock_t"), py_tpobject(tp_int));
  2290. py_setdict(mod, py_name("gpio_bias_t"), py_tpobject(tp_int));
  2291. py_setdict(mod, py_name("gpio_drive_t"), py_tpobject(tp_int));
  2292. py_setdict(mod, py_name("pwm_polarity_t"), py_tpobject(tp_int));
  2293. py_setdict(mod, py_name("serial_parity_t"), py_tpobject(tp_int));
  2294. py_setdict(mod, py_name("spi_bit_order_t"), py_tpobject(tp_int));
  2295. /* functions */
  2296. py_bindfunc(mod, "gpio_new", &cfunc__gpio_new);
  2297. py_bindfunc(mod, "gpio_open", &cfunc__gpio_open);
  2298. py_bindfunc(mod, "gpio_open_name", &cfunc__gpio_open_name);
  2299. py_bindfunc(mod, "gpio_open_advanced", &cfunc__gpio_open_advanced);
  2300. py_bindfunc(mod, "gpio_open_name_advanced", &cfunc__gpio_open_name_advanced);
  2301. py_bindfunc(mod, "gpio_open_sysfs", &cfunc__gpio_open_sysfs);
  2302. py_bindfunc(mod, "gpio_read", &cfunc__gpio_read);
  2303. py_bindfunc(mod, "gpio_write", &cfunc__gpio_write);
  2304. py_bindfunc(mod, "gpio_poll", &cfunc__gpio_poll);
  2305. py_bindfunc(mod, "gpio_close", &cfunc__gpio_close);
  2306. py_bindfunc(mod, "gpio_free", &cfunc__gpio_free);
  2307. py_bindfunc(mod, "gpio_read_event", &cfunc__gpio_read_event);
  2308. py_bindfunc(mod, "gpio_poll_multiple", &cfunc__gpio_poll_multiple);
  2309. py_bindfunc(mod, "gpio_get_direction", &cfunc__gpio_get_direction);
  2310. py_bindfunc(mod, "gpio_get_edge", &cfunc__gpio_get_edge);
  2311. py_bindfunc(mod, "gpio_get_event_clock", &cfunc__gpio_get_event_clock);
  2312. py_bindfunc(mod, "gpio_get_debounce_us", &cfunc__gpio_get_debounce_us);
  2313. py_bindfunc(mod, "gpio_get_bias", &cfunc__gpio_get_bias);
  2314. py_bindfunc(mod, "gpio_get_drive", &cfunc__gpio_get_drive);
  2315. py_bindfunc(mod, "gpio_get_inverted", &cfunc__gpio_get_inverted);
  2316. py_bindfunc(mod, "gpio_set_direction", &cfunc__gpio_set_direction);
  2317. py_bindfunc(mod, "gpio_set_edge", &cfunc__gpio_set_edge);
  2318. py_bindfunc(mod, "gpio_set_event_clock", &cfunc__gpio_set_event_clock);
  2319. py_bindfunc(mod, "gpio_set_debounce_us", &cfunc__gpio_set_debounce_us);
  2320. py_bindfunc(mod, "gpio_set_bias", &cfunc__gpio_set_bias);
  2321. py_bindfunc(mod, "gpio_set_drive", &cfunc__gpio_set_drive);
  2322. py_bindfunc(mod, "gpio_set_inverted", &cfunc__gpio_set_inverted);
  2323. py_bindfunc(mod, "gpio_line", &cfunc__gpio_line);
  2324. py_bindfunc(mod, "gpio_fd", &cfunc__gpio_fd);
  2325. py_bindfunc(mod, "gpio_name", &cfunc__gpio_name);
  2326. py_bindfunc(mod, "gpio_label", &cfunc__gpio_label);
  2327. py_bindfunc(mod, "gpio_chip_fd", &cfunc__gpio_chip_fd);
  2328. py_bindfunc(mod, "gpio_chip_name", &cfunc__gpio_chip_name);
  2329. py_bindfunc(mod, "gpio_chip_label", &cfunc__gpio_chip_label);
  2330. py_bindfunc(mod, "gpio_tostring", &cfunc__gpio_tostring);
  2331. py_bindfunc(mod, "gpio_errno", &cfunc__gpio_errno);
  2332. py_bindfunc(mod, "gpio_errmsg", &cfunc__gpio_errmsg);
  2333. py_bindfunc(mod, "led_new", &cfunc__led_new);
  2334. py_bindfunc(mod, "led_open", &cfunc__led_open);
  2335. py_bindfunc(mod, "led_read", &cfunc__led_read);
  2336. py_bindfunc(mod, "led_write", &cfunc__led_write);
  2337. py_bindfunc(mod, "led_close", &cfunc__led_close);
  2338. py_bindfunc(mod, "led_free", &cfunc__led_free);
  2339. py_bindfunc(mod, "led_get_brightness", &cfunc__led_get_brightness);
  2340. py_bindfunc(mod, "led_get_max_brightness", &cfunc__led_get_max_brightness);
  2341. py_bindfunc(mod, "led_get_trigger", &cfunc__led_get_trigger);
  2342. py_bindfunc(mod, "led_get_triggers_entry", &cfunc__led_get_triggers_entry);
  2343. py_bindfunc(mod, "led_get_triggers_count", &cfunc__led_get_triggers_count);
  2344. py_bindfunc(mod, "led_set_brightness", &cfunc__led_set_brightness);
  2345. py_bindfunc(mod, "led_set_trigger", &cfunc__led_set_trigger);
  2346. py_bindfunc(mod, "led_name", &cfunc__led_name);
  2347. py_bindfunc(mod, "led_tostring", &cfunc__led_tostring);
  2348. py_bindfunc(mod, "led_errno", &cfunc__led_errno);
  2349. py_bindfunc(mod, "led_errmsg", &cfunc__led_errmsg);
  2350. py_bindfunc(mod, "mmio_new", &cfunc__mmio_new);
  2351. py_bindfunc(mod, "mmio_open", &cfunc__mmio_open);
  2352. py_bindfunc(mod, "mmio_open_advanced", &cfunc__mmio_open_advanced);
  2353. py_bindfunc(mod, "mmio_ptr", &cfunc__mmio_ptr);
  2354. py_bindfunc(mod, "mmio_read64", &cfunc__mmio_read64);
  2355. py_bindfunc(mod, "mmio_read32", &cfunc__mmio_read32);
  2356. py_bindfunc(mod, "mmio_read16", &cfunc__mmio_read16);
  2357. py_bindfunc(mod, "mmio_read8", &cfunc__mmio_read8);
  2358. py_bindfunc(mod, "mmio_read", &cfunc__mmio_read);
  2359. py_bindfunc(mod, "mmio_write64", &cfunc__mmio_write64);
  2360. py_bindfunc(mod, "mmio_write32", &cfunc__mmio_write32);
  2361. py_bindfunc(mod, "mmio_write16", &cfunc__mmio_write16);
  2362. py_bindfunc(mod, "mmio_write8", &cfunc__mmio_write8);
  2363. py_bindfunc(mod, "mmio_write", &cfunc__mmio_write);
  2364. py_bindfunc(mod, "mmio_close", &cfunc__mmio_close);
  2365. py_bindfunc(mod, "mmio_free", &cfunc__mmio_free);
  2366. py_bindfunc(mod, "mmio_base", &cfunc__mmio_base);
  2367. py_bindfunc(mod, "mmio_size", &cfunc__mmio_size);
  2368. py_bindfunc(mod, "mmio_tostring", &cfunc__mmio_tostring);
  2369. py_bindfunc(mod, "mmio_errno", &cfunc__mmio_errno);
  2370. py_bindfunc(mod, "mmio_errmsg", &cfunc__mmio_errmsg);
  2371. py_bindfunc(mod, "pwm_new", &cfunc__pwm_new);
  2372. py_bindfunc(mod, "pwm_open", &cfunc__pwm_open);
  2373. py_bindfunc(mod, "pwm_enable", &cfunc__pwm_enable);
  2374. py_bindfunc(mod, "pwm_disable", &cfunc__pwm_disable);
  2375. py_bindfunc(mod, "pwm_close", &cfunc__pwm_close);
  2376. py_bindfunc(mod, "pwm_free", &cfunc__pwm_free);
  2377. py_bindfunc(mod, "pwm_get_enabled", &cfunc__pwm_get_enabled);
  2378. py_bindfunc(mod, "pwm_get_period_ns", &cfunc__pwm_get_period_ns);
  2379. py_bindfunc(mod, "pwm_get_duty_cycle_ns", &cfunc__pwm_get_duty_cycle_ns);
  2380. py_bindfunc(mod, "pwm_get_period", &cfunc__pwm_get_period);
  2381. py_bindfunc(mod, "pwm_get_duty_cycle", &cfunc__pwm_get_duty_cycle);
  2382. py_bindfunc(mod, "pwm_get_frequency", &cfunc__pwm_get_frequency);
  2383. py_bindfunc(mod, "pwm_get_polarity", &cfunc__pwm_get_polarity);
  2384. py_bindfunc(mod, "pwm_set_enabled", &cfunc__pwm_set_enabled);
  2385. py_bindfunc(mod, "pwm_set_period_ns", &cfunc__pwm_set_period_ns);
  2386. py_bindfunc(mod, "pwm_set_duty_cycle_ns", &cfunc__pwm_set_duty_cycle_ns);
  2387. py_bindfunc(mod, "pwm_set_period", &cfunc__pwm_set_period);
  2388. py_bindfunc(mod, "pwm_set_duty_cycle", &cfunc__pwm_set_duty_cycle);
  2389. py_bindfunc(mod, "pwm_set_frequency", &cfunc__pwm_set_frequency);
  2390. py_bindfunc(mod, "pwm_set_polarity", &cfunc__pwm_set_polarity);
  2391. py_bindfunc(mod, "pwm_chip", &cfunc__pwm_chip);
  2392. py_bindfunc(mod, "pwm_channel", &cfunc__pwm_channel);
  2393. py_bindfunc(mod, "pwm_tostring", &cfunc__pwm_tostring);
  2394. py_bindfunc(mod, "pwm_errno", &cfunc__pwm_errno);
  2395. py_bindfunc(mod, "pwm_errmsg", &cfunc__pwm_errmsg);
  2396. py_bindfunc(mod, "serial_new", &cfunc__serial_new);
  2397. py_bindfunc(mod, "serial_open", &cfunc__serial_open);
  2398. py_bindfunc(mod, "serial_open_advanced", &cfunc__serial_open_advanced);
  2399. py_bindfunc(mod, "serial_read", &cfunc__serial_read);
  2400. py_bindfunc(mod, "serial_write", &cfunc__serial_write);
  2401. py_bindfunc(mod, "serial_flush", &cfunc__serial_flush);
  2402. py_bindfunc(mod, "serial_input_waiting", &cfunc__serial_input_waiting);
  2403. py_bindfunc(mod, "serial_output_waiting", &cfunc__serial_output_waiting);
  2404. py_bindfunc(mod, "serial_poll", &cfunc__serial_poll);
  2405. py_bindfunc(mod, "serial_close", &cfunc__serial_close);
  2406. py_bindfunc(mod, "serial_free", &cfunc__serial_free);
  2407. py_bindfunc(mod, "serial_get_baudrate", &cfunc__serial_get_baudrate);
  2408. py_bindfunc(mod, "serial_get_databits", &cfunc__serial_get_databits);
  2409. py_bindfunc(mod, "serial_get_parity", &cfunc__serial_get_parity);
  2410. py_bindfunc(mod, "serial_get_stopbits", &cfunc__serial_get_stopbits);
  2411. py_bindfunc(mod, "serial_get_xonxoff", &cfunc__serial_get_xonxoff);
  2412. py_bindfunc(mod, "serial_get_rtscts", &cfunc__serial_get_rtscts);
  2413. py_bindfunc(mod, "serial_get_vmin", &cfunc__serial_get_vmin);
  2414. py_bindfunc(mod, "serial_get_vtime", &cfunc__serial_get_vtime);
  2415. py_bindfunc(mod, "serial_set_baudrate", &cfunc__serial_set_baudrate);
  2416. py_bindfunc(mod, "serial_set_databits", &cfunc__serial_set_databits);
  2417. py_bindfunc(mod, "serial_set_parity", &cfunc__serial_set_parity);
  2418. py_bindfunc(mod, "serial_set_stopbits", &cfunc__serial_set_stopbits);
  2419. py_bindfunc(mod, "serial_set_xonxoff", &cfunc__serial_set_xonxoff);
  2420. py_bindfunc(mod, "serial_set_rtscts", &cfunc__serial_set_rtscts);
  2421. py_bindfunc(mod, "serial_set_vmin", &cfunc__serial_set_vmin);
  2422. py_bindfunc(mod, "serial_set_vtime", &cfunc__serial_set_vtime);
  2423. py_bindfunc(mod, "serial_fd", &cfunc__serial_fd);
  2424. py_bindfunc(mod, "serial_tostring", &cfunc__serial_tostring);
  2425. py_bindfunc(mod, "serial_errno", &cfunc__serial_errno);
  2426. py_bindfunc(mod, "serial_errmsg", &cfunc__serial_errmsg);
  2427. py_bindfunc(mod, "spi_new", &cfunc__spi_new);
  2428. py_bindfunc(mod, "spi_open", &cfunc__spi_open);
  2429. py_bindfunc(mod, "spi_open_advanced", &cfunc__spi_open_advanced);
  2430. py_bindfunc(mod, "spi_open_advanced2", &cfunc__spi_open_advanced2);
  2431. py_bindfunc(mod, "spi_transfer", &cfunc__spi_transfer);
  2432. py_bindfunc(mod, "spi_transfer_advanced", &cfunc__spi_transfer_advanced);
  2433. py_bindfunc(mod, "spi_close", &cfunc__spi_close);
  2434. py_bindfunc(mod, "spi_free", &cfunc__spi_free);
  2435. py_bindfunc(mod, "spi_get_mode", &cfunc__spi_get_mode);
  2436. py_bindfunc(mod, "spi_get_max_speed", &cfunc__spi_get_max_speed);
  2437. py_bindfunc(mod, "spi_get_bit_order", &cfunc__spi_get_bit_order);
  2438. py_bindfunc(mod, "spi_get_bits_per_word", &cfunc__spi_get_bits_per_word);
  2439. py_bindfunc(mod, "spi_get_extra_flags", &cfunc__spi_get_extra_flags);
  2440. py_bindfunc(mod, "spi_get_extra_flags32", &cfunc__spi_get_extra_flags32);
  2441. py_bindfunc(mod, "spi_set_mode", &cfunc__spi_set_mode);
  2442. py_bindfunc(mod, "spi_set_max_speed", &cfunc__spi_set_max_speed);
  2443. py_bindfunc(mod, "spi_set_bit_order", &cfunc__spi_set_bit_order);
  2444. py_bindfunc(mod, "spi_set_bits_per_word", &cfunc__spi_set_bits_per_word);
  2445. py_bindfunc(mod, "spi_set_extra_flags", &cfunc__spi_set_extra_flags);
  2446. py_bindfunc(mod, "spi_set_extra_flags32", &cfunc__spi_set_extra_flags32);
  2447. py_bindfunc(mod, "spi_fd", &cfunc__spi_fd);
  2448. py_bindfunc(mod, "spi_tostring", &cfunc__spi_tostring);
  2449. py_bindfunc(mod, "spi_errno", &cfunc__spi_errno);
  2450. py_bindfunc(mod, "spi_errmsg", &cfunc__spi_errmsg);
  2451. py_bindfunc(mod, "periphery_version", &cfunc__periphery_version);
  2452. py_bindfunc(mod, "periphery_version_info", &cfunc__periphery_version_info);
  2453. /* enums */
  2454. ADD_ENUM(GPIO_ERROR_ARG);
  2455. ADD_ENUM(GPIO_ERROR_OPEN);
  2456. ADD_ENUM(GPIO_ERROR_NOT_FOUND);
  2457. ADD_ENUM(GPIO_ERROR_QUERY);
  2458. ADD_ENUM(GPIO_ERROR_CONFIGURE);
  2459. ADD_ENUM(GPIO_ERROR_UNSUPPORTED);
  2460. ADD_ENUM(GPIO_ERROR_INVALID_OPERATION);
  2461. ADD_ENUM(GPIO_ERROR_IO);
  2462. ADD_ENUM(GPIO_ERROR_CLOSE);
  2463. ADD_ENUM(GPIO_DIR_IN);
  2464. ADD_ENUM(GPIO_DIR_OUT);
  2465. ADD_ENUM(GPIO_DIR_OUT_LOW);
  2466. ADD_ENUM(GPIO_DIR_OUT_HIGH);
  2467. ADD_ENUM(GPIO_EDGE_NONE);
  2468. ADD_ENUM(GPIO_EDGE_RISING);
  2469. ADD_ENUM(GPIO_EDGE_FALLING);
  2470. ADD_ENUM(GPIO_EDGE_BOTH);
  2471. ADD_ENUM(GPIO_EVENT_CLOCK_REALTIME);
  2472. ADD_ENUM(GPIO_EVENT_CLOCK_MONOTONIC);
  2473. ADD_ENUM(GPIO_EVENT_CLOCK_HTE);
  2474. ADD_ENUM(GPIO_BIAS_DEFAULT);
  2475. ADD_ENUM(GPIO_BIAS_PULL_UP);
  2476. ADD_ENUM(GPIO_BIAS_PULL_DOWN);
  2477. ADD_ENUM(GPIO_BIAS_DISABLE);
  2478. ADD_ENUM(GPIO_DRIVE_DEFAULT);
  2479. ADD_ENUM(GPIO_DRIVE_OPEN_DRAIN);
  2480. ADD_ENUM(GPIO_DRIVE_OPEN_SOURCE);
  2481. ADD_ENUM(LED_ERROR_ARG);
  2482. ADD_ENUM(LED_ERROR_OPEN);
  2483. ADD_ENUM(LED_ERROR_QUERY);
  2484. ADD_ENUM(LED_ERROR_IO);
  2485. ADD_ENUM(LED_ERROR_CLOSE);
  2486. ADD_ENUM(MMIO_ERROR_ARG);
  2487. ADD_ENUM(MMIO_ERROR_OPEN);
  2488. ADD_ENUM(MMIO_ERROR_CLOSE);
  2489. ADD_ENUM(PWM_ERROR_ARG);
  2490. ADD_ENUM(PWM_ERROR_OPEN);
  2491. ADD_ENUM(PWM_ERROR_QUERY);
  2492. ADD_ENUM(PWM_ERROR_CONFIGURE);
  2493. ADD_ENUM(PWM_ERROR_CLOSE);
  2494. ADD_ENUM(PWM_POLARITY_NORMAL);
  2495. ADD_ENUM(PWM_POLARITY_INVERSED);
  2496. ADD_ENUM(SERIAL_ERROR_ARG);
  2497. ADD_ENUM(SERIAL_ERROR_OPEN);
  2498. ADD_ENUM(SERIAL_ERROR_QUERY);
  2499. ADD_ENUM(SERIAL_ERROR_CONFIGURE);
  2500. ADD_ENUM(SERIAL_ERROR_IO);
  2501. ADD_ENUM(SERIAL_ERROR_CLOSE);
  2502. ADD_ENUM(PARITY_NONE);
  2503. ADD_ENUM(PARITY_ODD);
  2504. ADD_ENUM(PARITY_EVEN);
  2505. ADD_ENUM(SPI_ERROR_ARG);
  2506. ADD_ENUM(SPI_ERROR_OPEN);
  2507. ADD_ENUM(SPI_ERROR_QUERY);
  2508. ADD_ENUM(SPI_ERROR_CONFIGURE);
  2509. ADD_ENUM(SPI_ERROR_TRANSFER);
  2510. ADD_ENUM(SPI_ERROR_CLOSE);
  2511. ADD_ENUM(SPI_ERROR_UNSUPPORTED);
  2512. ADD_ENUM(MSB_FIRST);
  2513. ADD_ENUM(LSB_FIRST);
  2514. }