mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-25 09:02:30 +00:00
raspi: detect raspberry pi model, use 3 mbps for 3A+ and 3B+
This commit is contained in:
parent
99dd78454e
commit
63ff2b1e64
@ -16,6 +16,7 @@ CORE += \
|
|||||||
main.c \
|
main.c \
|
||||||
wav_util.c \
|
wav_util.c \
|
||||||
btstack_stdin_posix.c \
|
btstack_stdin_posix.c \
|
||||||
|
raspi_get_model.c
|
||||||
|
|
||||||
# examples
|
# examples
|
||||||
include ${BTSTACK_ROOT}/example/Makefile.inc
|
include ${BTSTACK_ROOT}/example/Makefile.inc
|
||||||
|
@ -73,6 +73,8 @@
|
|||||||
#include "btstack_chipset_bcm_download_firmware.h"
|
#include "btstack_chipset_bcm_download_firmware.h"
|
||||||
#include "btstack_control_raspi.h"
|
#include "btstack_control_raspi.h"
|
||||||
|
|
||||||
|
#include "raspi_get_model.h"
|
||||||
|
|
||||||
int btstack_main(int argc, const char * argv[]);
|
int btstack_main(int argc, const char * argv[]);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -322,12 +324,16 @@ int main(int argc, const char * argv[]){
|
|||||||
transport_config.flowcontrol = 0;
|
transport_config.flowcontrol = 0;
|
||||||
break;
|
break;
|
||||||
case UART_HARDWARE_FLOW:
|
case UART_HARDWARE_FLOW:
|
||||||
// Raspberry Pi Zero W
|
// Raspberry Pi Zero W gpio 45
|
||||||
// Raspberry Pi 3A+ vgpio 129 but WLAN + BL
|
// Raspberry Pi 3A+ vgpio 129 but WLAN + BL
|
||||||
// Raspberry Pi 3B+ vgpio 129 but WLAN + BL
|
// Raspberry Pi 3B+ vgpio 129 but WLAN + BL
|
||||||
bt_reg_en_pin = 45;
|
transport_config.baudrate_main = 3000000;
|
||||||
transport_config.baudrate_main = 921600;
|
|
||||||
transport_config.flowcontrol = 1;
|
transport_config.flowcontrol = 1;
|
||||||
|
|
||||||
|
// 3 mbps does not work on Zero W (investigation pending)
|
||||||
|
if (raspi_get_model() == MODEL_ZERO_W){
|
||||||
|
transport_config.baudrate_main = 921600;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printf("%s, %u, BT_REG_EN at GPIO %u\n", transport_config.flowcontrol ? "H4":"H5", transport_config.baudrate_main, bt_reg_en_pin);
|
printf("%s, %u, BT_REG_EN at GPIO %u\n", transport_config.flowcontrol ? "H4":"H5", transport_config.baudrate_main, bt_reg_en_pin);
|
||||||
|
59
port/raspi/raspi_get_model.c
Normal file
59
port/raspi/raspi_get_model.c
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "raspi_get_model.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Raspberry Pi model detection based on,
|
||||||
|
* https://elinux.org/RPi_HardwareHistory
|
||||||
|
**/
|
||||||
|
int raspi_get_model()
|
||||||
|
{
|
||||||
|
FILE *f = fopen( "/proc/cpuinfo", "rb" );
|
||||||
|
if( f == NULL )
|
||||||
|
{
|
||||||
|
perror( "can't open cpuinfo!" );
|
||||||
|
return MODEL_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
uint32_t revision = 0;
|
||||||
|
uint32_t model = MODEL_UNKNOWN;
|
||||||
|
char line[100] = { 0 };
|
||||||
|
char *ptr = NULL;
|
||||||
|
for(; ret < 1;)
|
||||||
|
{
|
||||||
|
ptr = fgets( line, 100, f );
|
||||||
|
if( ptr == NULL )
|
||||||
|
break;
|
||||||
|
ret = sscanf( line, "Revision : %x\n", &revision );
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose( f );
|
||||||
|
|
||||||
|
switch( revision )
|
||||||
|
{
|
||||||
|
case 0x9000c1:
|
||||||
|
model = MODEL_ZERO_W;
|
||||||
|
break;
|
||||||
|
case 0xa02082:
|
||||||
|
case 0xa22082:
|
||||||
|
case 0xa32082:
|
||||||
|
model = MODEL_3B;
|
||||||
|
break;
|
||||||
|
case 0xa020d3:
|
||||||
|
model = MODEL_3BPLUS;
|
||||||
|
break;
|
||||||
|
case 0x9020e0:
|
||||||
|
model = MODEL_3APLUS;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
13
port/raspi/raspi_get_model.h
Normal file
13
port/raspi/raspi_get_model.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef _RASPI_GET_MODEL_
|
||||||
|
#define _RASPI_GET_MODEL_
|
||||||
|
|
||||||
|
#define MODEL_UNKNOWN 0
|
||||||
|
#define MODEL_ZERO_W 1
|
||||||
|
#define MODEL_3B 2
|
||||||
|
#define MODEL_3BPLUS 3
|
||||||
|
#define MODEL_3APLUS 4
|
||||||
|
|
||||||
|
int raspi_get_model();
|
||||||
|
|
||||||
|
#endif // _RASPI_GET_MODEL_
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user