mirror of https://github.com/joan2937/pigpio
Add code to detect if the system is in fact a raspberry pi.
This commit is contained in:
parent
34b33c3bf3
commit
a0c405ca6f
19
pigpio.c
19
pigpio.c
|
@ -1198,6 +1198,7 @@ typedef struct
|
|||
/* initialise once then preserve */
|
||||
|
||||
static volatile uint32_t piCores = 0;
|
||||
static volatile uint32_t pi_ispi = 0;
|
||||
static volatile uint32_t pi_peri_phys = 0x20000000;
|
||||
static volatile uint32_t pi_dram_bus = 0x40000000;
|
||||
static volatile uint32_t pi_mem_flag = 0x0C;
|
||||
|
@ -7198,6 +7199,17 @@ static int initCheckPermitted(void)
|
|||
{
|
||||
DBG(DBG_STARTUP, "");
|
||||
|
||||
if (!pi_ispi)
|
||||
{
|
||||
DBG(DBG_ALWAYS,
|
||||
"\n" \
|
||||
"+---------------------------------------------------------+\n" \
|
||||
"|Sorry, this system does not appear to be a raspberry pi. |\n" \
|
||||
"|aborting. |\n" \
|
||||
"+---------------------------------------------------------+\n\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((fdMem = open("/dev/mem", O_RDWR | O_SYNC) ) < 0)
|
||||
{
|
||||
DBG(DBG_ALWAYS,
|
||||
|
@ -13327,6 +13339,13 @@ unsigned gpioHardwareRevision(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (!strncasecmp("hardware\t: BCM", buf, 14)) {
|
||||
int bcmno = atoi(buf+14);
|
||||
if ((bcmno == 2708) || (bcmno == 2709) || (bcmno == 2710) || (bcmno == 2835) || (bcmno == 2836) || (bcmno == 2837)) {
|
||||
pi_ispi = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!strncasecmp("revision\t:", buf, 10))
|
||||
{
|
||||
if (sscanf(buf+10, "%x%c", &rev, &term) == 2)
|
||||
|
|
Loading…
Reference in New Issue