Skip to content

Commit 7741804

Browse files
authored
Merge pull request #1674 from elovalvo/2.8
Update for new version of Rpi400
2 parents fd7d0ff + 2b1160a commit 7741804

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

src/hal/drivers/cpuinfo.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*
22
Copyright (c) 2012 Ben Croston
33
4-
Revised by Ernesto Lo Valvo (ernesto.lovalvo@unipa.it) (12/01/2021)
4+
Revised by Ernesto Lo Valvo (ernesto.lovalvo@unipa.it) (19/03/2022)
55
Added new version of Raspberry Pi4 and Raspberry Pi 400
66
Revised for version 3B (15/01/2021)
7-
https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
7+
https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-revision-codes
88
99
Permission is hereby granted, free of charge, to any person obtaining a copy of
1010
this software and associated documentation files (the "Software"), to deal in
@@ -32,18 +32,21 @@ char *get_cpuinfo_revision(char *revision)
3232
{
3333
FILE *fp;
3434
char buffer[1024];
35+
char *r;
3536

3637
if ((fp = fopen("/sys/firmware/devicetree/base/model", "r")) == NULL)
37-
return 0;
38+
return NULL;
39+
40+
r = fgets(buffer, sizeof(buffer) , fp);
41+
fclose(fp);
3842

39-
fgets(buffer, sizeof(buffer) , fp);
43+
if (!r) return NULL;
4044

4145
if (strncmp(buffer, "Raspberry",9) != 0)
4246
return NULL;
43-
fclose(fp);
4447

4548
if ((fp = fopen("/proc/cpuinfo", "r")) == NULL)
46-
return 0;
49+
return NULL;
4750

4851
while(!feof(fp)) {
4952
if (fgets(buffer, sizeof(buffer) , fp)){
@@ -97,7 +100,8 @@ int get_rpi_revision(void)
97100
(strcmp(revision, "c03114") == 0) ||
98101
(strcmp(revision, "d03114") == 0))
99102
return 5;
100-
else if (strcmp(revision, "c03130") == 0) /* Raspberry Pi 400 */
103+
else if ((strcmp(revision, "c03130") == 0) || /* Raspberry Pi 400 */
104+
(strcmp(revision, "c03131") == 0))
101105
return 6;
102106
else /* assume rev 7 */
103107
return 7;

src/hal/drivers/hal_pi_gpio.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*
1616
* made work for Raspberry2 9/2015 Michael Haberler
1717
* Last change: Modify for Pi5 10/2019 andypugh
18+
* Last change: Modify for Pi400 3/2022 elovalvo
1819
s********************************************************************/
1920

2021

@@ -236,6 +237,12 @@ int rtapi_app_main(void)
236237
rtapi_print_msg(RTAPI_MSG_INFO, "%d cores rev %d", ncores, rev);
237238

238239
switch (rev) {
240+
case 6:
241+
rtapi_print_msg(RTAPI_MSG_INFO, "RaspberryPi400\n");
242+
pins = rpi2_pins;
243+
gpios = rpi2_gpios;
244+
npins = sizeof(rpi2_pins);
245+
break;
239246
case 5:
240247
rtapi_print_msg(RTAPI_MSG_INFO, "Raspberry4\n");
241248
pins = rpi2_pins;

0 commit comments

Comments
 (0)