int get_rapi_revision(void) { char revision[1024] = {'\0'}; if (get_cpuinfo_revision(revision) == NULL) return -1; if (f_a20) { //bananapi 1 return 2;//bananapi pro 2 } else if (f_s500){ return 3;//S500/RaPi 3 } }
int get_rpi_revision(void) { char revision[1024] = {'\0'}; if (get_cpuinfo_revision(revision) == NULL) return -1; if ((strcmp(revision, "0002") == 0) || (strcmp(revision, "1000002") == 0 ) || (strcmp(revision, "0003") == 0) || (strcmp(revision, "1000003") == 0 )) return 1; else // assume rev 2 (0004 0005 0006 1000004 1000005 1000006) return 2; }
PyMODINIT_FUNC initGPIO(void) #endif { int i; PyObject *module = NULL; char cpuRev[1024] = {'\0'}; #if PY_MAJOR_VERSION > 2 if ((module = PyModule_Create(&lmkgpiomodule)) == NULL) return NULL; #else if ((module = Py_InitModule3("LMK.GPIO", lmk_gpio_methods, moduledocstring)) == NULL) return; #endif if (get_cpuinfo_revision(cpuRev) == NULL) #if PY_MAJOR_VERSION > 2 return NULL; #else return; #endif revision = get_lmk_revision(); debug("BOARD: revision(%d)\n",revision); define_constants(module); for (i=0; i<256; i++) gpio_direction[i] = -1; if (revision == -1) { PyErr_SetString(PyExc_RuntimeError, "This module can only be run on a Raspberry Pi!"); setup_error = 1; #if PY_MAJOR_VERSION > 2 return NULL; #else return; #endif } lmk_revision = Py_BuildValue("i", revision); PyModule_AddObject(module, "LMK_REVISION", lmk_revision); // Add PWM class if (PWM_init_PWMType() == NULL){ #if PY_MAJOR_VERSION > 2 return NULL; #else return; #endif } Py_INCREF(&PWMType); PyModule_AddObject(module, "PWM", (PyObject*)&PWMType); if (!PyEval_ThreadsInitialized()){ PyEval_InitThreads(); } //Initialized only once if (mmap_gpio_mem()) #if PY_MAJOR_VERSION > 2 return NULL; #else return; #endif // register exit functions - last declared is called first if (Py_AtExit(cleanup) != 0) { setup_error = 1; cleanup(); #if PY_MAJOR_VERSION > 2 return NULL; #else return; #endif } if (Py_AtExit(event_cleanup_all) != 0) { setup_error = 1; cleanup(); #if PY_MAJOR_VERSION > 2 return NULL; #else return; #endif } #if PY_MAJOR_VERSION > 2 return module; #else return; #endif }
// Read /proc/cpuinfo once and keep the info at hand for further requests static void cache_rpi_revision(void) { revision_int = get_cpuinfo_revision(revision_hex); }