mirror of
https://github.com/whowechina/chu_pico.git
synced 2024-11-28 04:30:49 +01:00
SN display in CLI
This commit is contained in:
parent
de27dbbd09
commit
ff3768244b
@ -7,6 +7,7 @@
|
|||||||
#include "pico/stdio.h"
|
#include "pico/stdio.h"
|
||||||
#include "pico/stdlib.h"
|
#include "pico/stdlib.h"
|
||||||
#include "cli.h"
|
#include "cli.h"
|
||||||
|
#include "save.h"
|
||||||
|
|
||||||
#define MAX_COMMANDS 32
|
#define MAX_COMMANDS 32
|
||||||
#define MAX_PARAMETERS 6
|
#define MAX_PARAMETERS 6
|
||||||
@ -57,6 +58,7 @@ int cli_match_prefix(const char *str[], int num, const char *prefix)
|
|||||||
static void handle_help(int argc, char *argv[])
|
static void handle_help(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
printf("%s", cli_logo);
|
printf("%s", cli_logo);
|
||||||
|
printf("\tSN: %016llx\n\n", board_id_64());
|
||||||
printf("Available commands:\n");
|
printf("Available commands:\n");
|
||||||
for (int i = 0; i < num_commands; i++) {
|
for (int i = 0; i < num_commands; i++) {
|
||||||
printf("%*s: %s\n", max_cmd_len + 2, commands[i], helps[i]);
|
printf("%*s: %s\n", max_cmd_len + 2, commands[i], helps[i]);
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "hardware/flash.h"
|
#include "hardware/flash.h"
|
||||||
#include "pico/multicore.h"
|
#include "pico/multicore.h"
|
||||||
|
#include "pico/unique_id.h"
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
size_t size;
|
size_t size;
|
||||||
@ -109,6 +110,27 @@ static void save_loaded()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static union __attribute__((packed)) {
|
||||||
|
pico_unique_board_id_t id;
|
||||||
|
struct {
|
||||||
|
uint32_t id32h;
|
||||||
|
uint32_t id32l;
|
||||||
|
};
|
||||||
|
uint64_t id64;
|
||||||
|
} board_id;
|
||||||
|
|
||||||
|
uint32_t board_id_32()
|
||||||
|
{
|
||||||
|
pico_get_unique_board_id(&board_id.id);
|
||||||
|
return board_id.id32h ^ board_id.id32l;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t board_id_64()
|
||||||
|
{
|
||||||
|
pico_get_unique_board_id(&board_id.id);
|
||||||
|
return board_id.id64;
|
||||||
|
}
|
||||||
|
|
||||||
void save_init(uint32_t magic, mutex_t *locker)
|
void save_init(uint32_t magic, mutex_t *locker)
|
||||||
{
|
{
|
||||||
my_magic = magic;
|
my_magic = magic;
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
|
|
||||||
#include "pico/multicore.h"
|
#include "pico/multicore.h"
|
||||||
|
|
||||||
|
uint32_t board_id_32();
|
||||||
|
uint64_t board_id_64();
|
||||||
|
|
||||||
/* It's safer to lock other I/O ops during saving, so we need a locker */
|
/* It's safer to lock other I/O ops during saving, so we need a locker */
|
||||||
typedef void (*io_locker_func)(bool pause);
|
typedef void (*io_locker_func)(bool pause);
|
||||||
void save_init(uint32_t magic, mutex_t *lock);
|
void save_init(uint32_t magic, mutex_t *lock);
|
||||||
|
Loading…
Reference in New Issue
Block a user