mirror of
https://github.com/isometimes/rpi4-osdev
synced 2024-11-25 03:30:39 +00:00
Added display debug to part7 to help resolve Bluetooth issues
This commit is contained in:
parent
072b5453b4
commit
1d03a2ce3f
1 changed files with 45 additions and 10 deletions
|
@ -1,35 +1,70 @@
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "bt.h"
|
#include "bt.h"
|
||||||
|
#include "fb.h"
|
||||||
|
|
||||||
|
int curx = 0;
|
||||||
|
int cury = 0;
|
||||||
|
|
||||||
|
int strlen(const char *str) {
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
for (s = str; *s; ++s);
|
||||||
|
return (s - str);
|
||||||
|
}
|
||||||
|
|
||||||
|
void debugstr(char *str) {
|
||||||
|
if (curx + (strlen(str) * 8) >= 1920) {
|
||||||
|
curx = 0; cury += 8;
|
||||||
|
}
|
||||||
|
drawString(curx, cury, str, 0x0f, 1);
|
||||||
|
curx += (strlen(str) * 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
void debugcrlf(void) {
|
||||||
|
curx = 0; cury += 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
void debugch(unsigned char b) {
|
||||||
|
unsigned int n;
|
||||||
|
int c;
|
||||||
|
for(c=4;c>=0;c-=4) {
|
||||||
|
n=(b>>c)&0xF;
|
||||||
|
n+=n>9?0x37:0x30;
|
||||||
|
debugstr((char *)&n);
|
||||||
|
}
|
||||||
|
debugstr(" ");
|
||||||
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
fb_init();
|
||||||
uart_init();
|
uart_init();
|
||||||
bt_init();
|
bt_init();
|
||||||
|
|
||||||
uart_writeText("Initialising Bluetooth: ");
|
debugstr("Initialising Bluetooth: ");
|
||||||
uart_writeText(">> reset: ");
|
debugstr(">> reset: ");
|
||||||
bt_reset();
|
bt_reset();
|
||||||
uart_writeText(">> firmware load: ");
|
debugstr(">> firmware load: ");
|
||||||
bt_loadfirmware();
|
bt_loadfirmware();
|
||||||
uart_writeText(">> set baud: ");
|
debugstr(">> set baud: ");
|
||||||
bt_setbaud();
|
bt_setbaud();
|
||||||
uart_writeText(">> set bdaddr: ");
|
debugstr(">> set bdaddr: ");
|
||||||
bt_setbdaddr();
|
bt_setbdaddr();
|
||||||
|
|
||||||
// Print the BD_ADDR
|
// Print the BD_ADDR
|
||||||
unsigned char local_addr[6];
|
unsigned char local_addr[6];
|
||||||
bt_getbdaddr(local_addr);
|
bt_getbdaddr(local_addr);
|
||||||
for (int c=5;c>=0;c--) uart_byte(local_addr[c]);
|
for (int c=5;c>=0;c--) debugch(local_addr[c]);
|
||||||
uart_writeText("\n");
|
debugcrlf();
|
||||||
|
|
||||||
// Start advertising
|
// Start advertising
|
||||||
uart_writeText("Setting event mask... ");
|
debugstr("Setting event mask... ");
|
||||||
setLEeventmask(0xff);
|
setLEeventmask(0xff);
|
||||||
uart_writeText("Starting advertsing... ");
|
debugstr("Starting advertsing... ");
|
||||||
startActiveAdvertising();
|
startActiveAdvertising();
|
||||||
|
|
||||||
// Enter an infinite loop
|
// Enter an infinite loop
|
||||||
uart_writeText("Going loopy...");
|
debugstr("Going loopy...");
|
||||||
while (1) {
|
while (1) {
|
||||||
uart_update();
|
uart_update();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue