Lesen Sie den Artikel ...
Pinedio Stack BL604 ist das neueste Mikrocontroller-Board von Pine64, das auf dem BL604 RISC-V + WiFi + Bluetooth Le Soc von Bouffalo Lab basiert.
(Jetzt jeden Tag verfügbar!)
Pinedio Stack ist gepackt .
ST7789 Farb LCD -Anzeige
(240 x 240 Pixel)
CST816S Touch Panel
(Auf i2c verbunden)
Semtech SX1262 LORA -Transceiver
(Arbeitet mit Lorawan)
AT6558 GPS / GNSS -Empfänger
SGM40561 Power Management Unit
Herzfrequenzsensor, Beschleunigungsmesser, Kompass, Vibrator
SPI Flash, JTAG -Debugging -Port, Druckknopf
2,4 GHz WiFi, Bluetooth LE
(Danke an BL604)
Das macht es zu einem unglaublichen Gerät für IoT -Bildung !
Quellcode für Apache Nuttx RTOS auf Pinedio Stack ist hier ...
lupyuen/Inkubator-nuttx (Pinedio Branch)
Lupyuen/Inkubator-Nuttx-Apps (Pinedio Branch)
NUTTX -Build -Konfiguration für Pinedio Stack BL604 ...
Zum Herunterladen, Konfigurieren und Erstellen von NUTTX für Pinedio Stack BL604 ...
mkdir nuttx
cd nuttx
git clone --recursive --branch pinedio https://github.com/lupyuen/incubator-nuttx nuttx
git clone --recursive --branch pinedio https://github.com/lupyuen/incubator-nuttx-apps apps
cd nuttx
./tools/configure.sh bl602evb:pinedio
make(Siehe das Build -Protokoll)
Folgen Sie den Updates auf Twitter
Akordiert zum Pinedio Stack Schema ...
Pinedio Stack Schema (2021-09-15)
Pinedio Stack Baseboardschema (2021-09-27)
Der SPI -Bus wird geteilt von ...
ST7789 Display Controller
Semtech SX1262 LORA -Transceiver
SPI Blitz
Hier sind die BL604 -GPIO -Nummern für den gemeinsam genutzten SPI -Bus ...
| Funktion | GPIO |
|---|---|
| Spi mosi | 13 |
| SPI Miso | 0 |
| Spi sck | 11 |
| Spi cs (nicht genutzt) | 8 |
(Quelle)
Um das Übersprechen zu verhindern, wählen wir jedes SPI -Gerät aus, indem wir den Chip -Select Pin von hoch nach niedrig umdrehen ...
| SPI -Gerät | Geräte -ID | Swap Miso/Mosi | Chip auswählen |
|---|---|---|---|
| ST7789 Display | 0x40000 | NEIN | 20 |
| SX1262 Transceiver | 1 | Ja | 15 |
| SPI Blitz | 2 | Ja | 14 |
| (Standardgerät) | -1 | Ja | 8 (nicht genutzt) |
(Quelle)
NUTTX Auto-Signs 0x40000 als SPI-Geräte-ID für ST7789-Anzeige. (Siehe das)
Wir haben die anderen SPI -Geräte -IDs selbst zugewiesen.
Die Geräte -ID -1 ist als Falle gemeint, um alle SPI -Geräte zu fangen, die nicht mit den Geräte -IDs übereinstimmen. Dies funktioniert auch für einfache SPI -Setups, bei denen die Geräte -ID nicht benötigt wird.
Gemäß BL602 Referenzhandbuch (Tabelle 3.1 "Pin Beschreibung", Seite 26) ...
Gpio 13 ist mosi
Gpio 0 ist Miso
Aber aufgrund einer BL602 -SPI -Quirk müssen wir Miso und Mosi tauschen, um dieses Verhalten zu erhalten. Deshalb ist die Spalte "Swap Miso / Mosi" für SX1262 -Transceiver und SPI -Flash mit "Ja" gekennzeichnet.
ST7789 Display Controller ist unterschiedlich verkabelt ...
ST7789 empfängt SPI -Daten zu gpio 0
ST7789 Daten / Befehlspin ist mit GPIO 13 verbunden
(Hoch für ST7789 -Daten, niedrig für ST7789 -Befehle)
Die Richtung der SPI -Daten wird für ST7789 umgedreht. Aus diesem Grund ist die Spalte "Swap Miso / Mosi" für ST7789 -Display -Controller mit "Nein" gekennzeichnet.
Wir stellen die oben genannte SPI -Gerätetabelle in NUTTX als flaches Int -Array dar ...
| SPI -Gerät | Geräte -ID | Swap Miso/Mosi | Chip auswählen |
|---|---|---|---|
| ST7789 Display | 0x40000 | 0 | 20 |
| SX1262 Transceiver | 1 | 1 | 15 |
| SPI Blitz | 2 | 1 | 14 |
| (Standardgerät) | -1 | 1 | 8 |
(Quelle)
Hier ist der Quellcode ...
#ifdef CONFIG_BL602_SPI0
/* SPI Device Table: SPI Device ID, Swap MISO/MOSI, Chip Select */
static const int32_t bl602_spi_device_table [] =
{
#ifdef BOARD_LCD_DEVID /* ST7789 Display */
BOARD_LCD_DEVID , BOARD_LCD_SWAP , BOARD_LCD_CS ,
#endif /* BOARD_LCD_DEVID */
#ifdef BOARD_SX1262_DEVID /* LoRa SX1262 */
BOARD_SX1262_DEVID , BOARD_SX1262_SWAP , BOARD_SX1262_CS ,
#endif /* BOARD_SX1262_DEVID */
#ifdef BOARD_FLASH_DEVID /* SPI Flash */
BOARD_FLASH_DEVID , BOARD_FLASH_SWAP , BOARD_FLASH_CS ,
#endif /* BOARD_FLASH_DEVID */
/* Must end with Default SPI Device */
-1 , 1 , BOARD_SPI_CS , /* Swap MISO/MOSI */
};
#endif /* CONFIG_BL602_SPI0 */(Quelle)
Die Spalten der SPI -Gerätetabelle ...
/* Columns in the SPI Device Table */
#define DEVID_COL 0 /* SPI Device ID */
#define SWAP_COL 1 /* 1 if MISO/MOSI should be swapped, else 0 */
#define CS_COL 2 /* SPI Chip Select Pin */
#define NUM_COLS 3 /* Number of columns in SPI Device Table */(Quelle)
Hier sind die Funktionen für den Zugriff auf die SPI -Gerätetabelle ...
BL602_spi_get_device: Suchen Sie ein Gerät in der SPI -Gerätetabelle nach
BL602_SPI_DESELECT_DEVICES: Wählen Sie alle Geräte in der SPI -Gerätetabelle aus
BL602_SPI_VALIDATE_DEVICES: Validieren Sie die Geräte in der Tabelle SPI -Geräte
Die obige SPI -Gerätetabelle bezieht sich auf die folgenden PIN -Definitionen ...
/* SPI for PineDio Stack: Chip Select (unused), MOSI, MISO, SCK */
#define BOARD_SPI_CS (GPIO_INPUT | GPIO_PULLUP | GPIO_FUNC_SPI | GPIO_PIN8) /* Unused */
#define BOARD_SPI_MOSI (GPIO_INPUT | GPIO_PULLUP | GPIO_FUNC_SPI | GPIO_PIN13)
#define BOARD_SPI_MISO (GPIO_INPUT | GPIO_PULLUP | GPIO_FUNC_SPI | GPIO_PIN0)
#define BOARD_SPI_CLK (GPIO_INPUT | GPIO_PULLUP | GPIO_FUNC_SPI | GPIO_PIN11)
#ifdef CONFIG_LCD_ST7789
/* ST7789 for PineDio Stack: Chip Select, Reset and Backlight */
#define BOARD_LCD_DEVID SPIDEV_DISPLAY(0) /* SPI Device ID: 0x40000 */
#define BOARD_LCD_SWAP 0 /* Don't swap MISO/MOSI */
#define BOARD_LCD_BL_INVERT /* Backlight is active when Low */
#define BOARD_LCD_CS (GPIO_OUTPUT | GPIO_PULLUP | GPIO_FUNC_SWGPIO | GPIO_PIN20)
#define BOARD_LCD_RST (GPIO_OUTPUT | GPIO_PULLUP | GPIO_FUNC_SWGPIO | GPIO_PIN3)
#define BOARD_LCD_BL (GPIO_OUTPUT | GPIO_PULLUP | GPIO_FUNC_SWGPIO | GPIO_PIN21)
#endif /* CONFIG_LCD_ST7789 */
/* SX1262 for PineDio Stack: Chip Select */
#define BOARD_SX1262_DEVID 1 /* SPI Device ID */
#define BOARD_SX1262_SWAP 1 /* Swap MISO/MOSI */
#define BOARD_SX1262_CS (GPIO_OUTPUT | GPIO_PULLUP | GPIO_FUNC_SWGPIO | GPIO_PIN15)
/* SPI Flash for PineDio Stack: Chip Select */
#define BOARD_FLASH_DEVID 2 /* SPI Device ID */
#define BOARD_FLASH_SWAP 1 /* Swap MISO/MOSI */
#define BOARD_FLASH_CS (GPIO_OUTPUT | GPIO_PULLUP | GPIO_FUNC_SWGPIO | GPIO_PIN14)(Quelle)
BL602 NUTTX -SPI -Treiber schaut in die SPI -Geräte -Tabelle nach 1 auf 1️⃣ Swap Miso und Mosi -Stifte 2 Seiten 2 und die Chip -Auswahlstifte um. So wählen wir jedes SPI -Gerät aus und deaktivieren wir ...
// Enable/disable the SPI chip select
static void bl602_spi_select ( struct spi_dev_s * dev , uint32_t devid ,
bool selected )
{
const int32_t * spidev ;
spiinfo ( "devid: %lu, CS: %sn" , devid , selected ? "select" : "free" );
/* get device from SPI Device Table */
spidev = bl602_spi_get_device ( devid );
DEBUGASSERT ( spidev != NULL );
/* swap MISO and MOSI if needed */
if ( selected )
{
bl602_swap_spi_0_mosi_with_miso ( spidev [ SWAP_COL ]);
}
/* set Chip Select */
bl602_gpiowrite ( spidev [ CS_COL ], ! selected );
#ifdef CONFIG_SPI_CMDDATA
/* revert MISO and MOSI from GPIO Pins to SPI Pins */
if (! selected )
{
bl602_configgpio ( BOARD_SPI_MISO );
bl602_configgpio ( BOARD_SPI_MOSI );
}
#endif
}(Quelle)
bl602_spi_select wird nach dem Sperren des SPI -Busses aufgerufen.
NUTTX RTOS verwendet Miso als ST7789 -Daten / Befehls -Pin ... aber ST7789 ist "rückwärts" auf Pinedio Stack BL604 verkabelt! Wir verwenden MOSI stattdessen als ST7789 -Daten / Befehls -PIN.
So drehen wir den ST7789 -Daten- / Befehls -Pin ab, abhängig von Miso / Mosi -Tausch ...
#ifdef CONFIG_SPI_CMDDATA
static int bl602_spi_cmddata ( struct spi_dev_s * dev ,
uint32_t devid , bool cmd )
{
spiinfo ( "devid: %" PRIu32 " CMD: %sn" , devid , cmd ? "command" :
"data" );
if ( devid == SPIDEV_DISPLAY ( 0 ))
{
const int32_t * spidev ;
gpio_pinset_t dc ;
gpio_pinset_t gpio ;
int ret ;
/* get device from SPI Device Table */
spidev = bl602_spi_get_device ( devid );
DEBUGASSERT ( spidev != NULL );
/* if MISO/MOSI are swapped, DC is MISO, else MOSI */
dc = spidev [ SWAP_COL ] ? BOARD_SPI_MISO : BOARD_SPI_MOSI ;
/* reconfigure DC from SPI Pin to GPIO Pin */
gpio = ( dc & GPIO_PIN_MASK )
| GPIO_OUTPUT | GPIO_PULLUP | GPIO_FUNC_SWGPIO ;
ret = bl602_configgpio ( gpio );
if ( ret < 0 )
{
spierr ( "Failed to configure MISO as GPIOn" );
DEBUGPANIC ();
return ret ;
}
/* set DC to high (data) or low (command) */
bl602_gpiowrite ( gpio , ! cmd );
return OK ;
}
spierr ( "SPI cmddata not supportedn" );
DEBUGPANIC ();
return - ENODEV ;
}
#endif(Quelle)
Bei NUTTX Startup deaktivieren wir alle SPI -Geräte ... indem wir ihre Chip -Select -Stifte hoch drehen ...
static void bl602_spi_init ( struct spi_dev_s * dev )
{
struct bl602_spi_priv_s * priv = ( struct bl602_spi_priv_s * ) dev ;
const struct bl602_spi_config_s * config = priv -> config ;
/* Initialize the SPI semaphore that enforces mutually exclusive access */
nxsem_init ( & priv -> exclsem , 0 , 1 );
bl602_configgpio ( BOARD_SPI_CS );
bl602_configgpio ( BOARD_SPI_MOSI );
bl602_configgpio ( BOARD_SPI_MISO );
bl602_configgpio ( BOARD_SPI_CLK );
/* set master mode */
bl602_set_spi_0_act_mode_sel ( 1 );
/* swap MOSI with MISO to be consistent with BL602 Reference Manual */
bl602_swap_spi_0_mosi_with_miso ( 1 );
/* spi cfg reg:
* cr_spi_deg_en 1
* cr_spi_m_cont_en 0
* cr_spi_byte_inv 0
* cr_spi_bit_inv 0
*/
modifyreg32 ( BL602_SPI_CFG , SPI_CFG_CR_M_CONT_EN
| SPI_CFG_CR_BYTE_INV | SPI_CFG_CR_BIT_INV ,
SPI_CFG_CR_DEG_EN );
/* disable rx ignore */
modifyreg32 ( BL602_SPI_CFG , SPI_CFG_CR_RXD_IGNR_EN , 0 );
bl602_spi_setfrequency ( dev , config -> clk_freq );
bl602_spi_setbits ( dev , 8 );
bl602_spi_setmode ( dev , config -> mode );
/* spi fifo clear */
modifyreg32 ( BL602_SPI_FIFO_CFG_0 , SPI_FIFO_CFG_0_RX_CLR
| SPI_FIFO_CFG_0_TX_CLR , 0 );
/* deselect all spi devices */
bl602_spi_deselect_devices ();
}(Quelle)
Wird ST7789 mit Lora SX1262 auf Pinedio Stack BL604 gut gespielt? Yep sx1262 funktioniert im gemeinsamen SPI -Bus in Ordnung!
Pinedio Stack Stiefel und rendert einen rosa Bildschirm ...
gpio_pin_register: Registering /dev/gpio0
gpio_pin_register: Registering /dev/gpio1
gpint_enable: Disable the interrupt
gpio_pin_register: Registering /dev/gpio2
bl602_gpio_set_intmod: ****gpio_pin=115, int_ctlmod=1, int_trgmod=0
spi_test_driver_register: devpath=/dev/spitest0, spidev=0
st7789_sleep: sleep: 0
st7789_sendcmd: cmd: 0x11
st7789_sendcmd: OK
st7789_bpp: bpp: 16
st7789_sendcmd: cmd: 0x3a
st7789_sendcmd: OK
st7789_setorientation:
st7789_sendcmd: cmd: 0x36
st7789_sendcmd: OK
st7789_display: on: 1
st7789_sendcmd: cmd: 0x29
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x21
st7789_sendcmd: OK
st7789_fill: color: 0xaaaa
st7789_sendcmd: cmd: 0x2b
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2a
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2c
st7789_sendcmd: OK
board_lcd_getdev: SPI port 0 bound to LCD 0
st7789_getplaneinfo: planeno: 0 bpp: 16
Wir führen die spi_test2 -App aus, um SX1262 zu testen ...
NuttShell (NSH) NuttX-10.2.0-RC0
nsh>
nsh> ?
help usage: help [-v] [<cmd>]
? cat help ls uname
Builtin Apps:
tinycbor_test spi_test nsh
lorawan_test timer sensortest
sx1262_test bl602_adc_test ikea_air_quality_sensor
bas spi_test2 gpio
sh getprime
lvgldemo hello
nsh> spi_test2
spi_test_driver_open:
gpout_write: Writing 0
spi_test_driver_write: buflen=2
spi_test_driver_configspi:
spi_test_driver_read: buflen=256
gpout_write: Writing 1
Get Status: received
a2 22
SX1262 Status is 2
gpout_write: Writing 0
spi_test_driver_write: buflen=5
spi_test_driver_configspi:
spi_test_driver_read: buflen=256
gpout_write: Writing 1
Read Register 8: received
a2 a2 a2 a2 80
SX1262 Register 8 is 0x80
SX1262 gibt Registerwert 0x80 zurück, was korrekt ist!
Dann führen wir die LVGL -Demo -App aus ...
spi_test_driver_close:
nsh> lvgldemo
fbdev_init: Failed to open /dev/fb0: 2
st7789_getvideoinfo: fmt: 11 xres: 240 yres: 240 nplanes: 1
lcddev_init: VideoInfo:
fmt: 11
xres: 240
yres: 240
nplanes: 1
lcddev_init: PlaneInfo (plane 0):
bpp: 16
st7789_putarea: row_start: 0 row_end: 19 col_start: 0 col_end: 239
st7789_sendcmd: cmd: 0x2b
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2a
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2c
st7789_sendcmd: OK
st7789_putarea: row_start: 20 row_end: 39 col_start: 0 col_end: 239
st7789_sendcmd: cmd: 0x2b
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2a
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2c
st7789_sendcmd: OK
st7789_putarea: row_start: 40 row_end:59 col_start: 0 col_end: 239
st7789_sendcmd: cmd: 0x2b
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2a
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2c
st7789_sendcmd: OK
st7789_putarea: row_start: 60 row_end: 79 col_start: 0 col_end: 239
st7789_sendcmd: cmd: 0x2b
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2a
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2c
st7789_sendcmd: OK
st7789_putarea: row_start: 80 row_end: 99 col_start: 0 col_end: 239
st7789_sendcmd: cmd: 0x2b
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2a
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2c
st7789_sendcmd: OK
st7789_putarea: row_start: 100 row_end: 119 col_start: 0 col_end: 239
st7789_sendcmd: cmd: 0x2b
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2a
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2c
st7789_sendcmd: OK
st7789_putarea: row_start: 120 row_end: 139 col_start: 0 col_end: 239
st7789_sendcmd: cmd: 0x2b
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2a
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2c
st7789_sendcmd: OK
st7789_putarea: row_start: 140 row_end: 159 col_start: 0 col_end: 239
st7789_sendcmd: cmd: 0x2b
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2a
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2c
st7789_sendcmd: OK
st7789_putarea: row_start: 160 row_end: 179 col_start: 0 col_end: 239
st7789_sendcmd: cmd: 0x2b
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2a
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2c
st7789_sendcmd: OK
st7789_putarea: row_start: 180 row_end: 199 col_start: 0 col_end: 239
st7789_sendcmd: cmd: 0x2b
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2a
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2c
st7789_sendcmd: OK
st7789_putarea: row_start: 200 row_end: 219 col_start: 0 col_end: 239
st7789_sendcmd: cmd: 0x2b
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2a
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2c
st7789_sendcmd: OK
st7789_putarea: row_start: 220 row_end: 239 col_start: 0 col_end: 239
st7789_sendcmd: cmd: 0x2b
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2a
st7789_sendcmd: OK
st7789_sendcmd: cmd: 0x2c
st7789_sendcmd: OK
monitor_cb: 57600 px refreshed in 1110 ms
Das macht den LVGL -Demo -Bildschirm auf ST7789 richtig!
Es gibt eine potenzielle Rennbedingung, wenn wir den SX1262 -Fahrer gleichzeitig mit dem ST7789 -Treiber verwenden ...
ioctl() des LORA -Getriebe
(Siehe das)
SX1262 Treiber ruft SPI -Test -Treiber /dev/spitest0 auf, das ( SPI_LOCK ) sperrt und den SPI -Bus (mit SPI -Geräte -ID 0) auswählt ( SPI_SELECT )
(Siehe das)
Beachten Sie, dass die Anrufe an ioctl() und SPI_LOCK / SPI_SELECT nicht atomic sind
Wenn der ST7789 -Treiber zwischen den Aufrufen zu ioctl() und SPI_LOCK / SPI_SELECT aktiv ist
Dies kann Müll auf SX1262 übertragen
Um dieses Problem zu lösen, registrieren wir einen neuen SPI -Test -Treiber /dev/spitest1 mit SPI -Geräte -ID 1.
Der LORA -Fahrer greift dann auf /dev/spitest1 auf, was den SPI -Bus (mit SPI -Geräte -ID 1) SPI_LOCK und SPI_SELECT .
Da die SPI -Geräte -ID 1 ist, wird SPI_SELECT den SX1262 -Chip -Select auf niedrig umdrehen.
BL602 / BL604 Gespräche mit ST7789 Display im SPI -Modus 1 oder 3 ... hängt davon ab, ob Miso / MOSI getauscht werden
#ifdef CONFIG_BL602_SPI0
#include "../boards/risc-v/bl602/bl602evb/include/board.h"
#endif /* CONFIG_BL602_SPI0 */
#ifdef CONFIG_LCD_ST7789
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Verify that all configuration requirements have been met */
#ifdef CONFIG_BL602_SPI0
# if defined( BOARD_LCD_SWAP ) && BOARD_LCD_SWAP == 0 /* If MISO/MOSI not swapped... */
# warning Using SPI Mode 1 for ST7789 on BL602 (MISO/MOSI not swapped)
# define CONFIG_LCD_ST7789_SPIMODE SPIDEV_MODE1 /* SPI Mode 1: Workaround for BL602 */
# else
# warning Using SPI Mode 3 for ST7789 on BL602 (MISO/MOSI swapped)
# define CONFIG_LCD_ST7789_SPIMODE SPIDEV_MODE3 /* SPI Mode 3: Workaround for BL602 */
# endif /* BOARD_LCD_SWAP */
#else
# ifndef CONFIG_LCD_ST7789_SPIMODE
# define CONFIG_LCD_ST7789_SPIMODE SPIDEV_MODE0
# endif /* CONFIG_LCD_ST7789_SPIMODE */
#endif /* CONFIG_BL602_SPI0 */(Quelle)
ST7789 -Display läuft bei SPI -Frequenz 4 MHz in Ordnung. Vielleicht können wir höher gehen?
CONFIG_LCD_ST7789_FREQUENCY=4000000
(Quelle)
Die LVGL -Test -App ist hier ...
Um die App auszuführen, geben Sie diese an der NUTTX -Shell ein ...
lvgltestHier ist der Code, der den Bildschirm macht ...
// Create the LVGL Widgets that will be rendered on the display
static void create_widgets ( void )
{
// Get the Active Screen
lv_obj_t * screen = lv_scr_act ();
// Create a Label Widget
lv_obj_t * label = lv_label_create ( screen , NULL );
// Wrap long lines in the label text
lv_label_set_long_mode ( label , LV_LABEL_LONG_BREAK );
// Interpret color codes in the label text
lv_label_set_recolor ( label , true);
// Center align the label text
lv_label_set_align ( label , LV_LABEL_ALIGN_CENTER );
// Set the label text and colors
lv_label_set_text (
label ,
"#ff0000 HELLO# " // Red Text
"#00ff00 PINEDIO# " // Green Text
"#0000ff STACK!# " // Blue Text
);
// Set the label width
lv_obj_set_width ( label , 200 );
// Align the label to the center of the screen, shift 30 pixels up
lv_obj_align ( label , NULL , LV_ALIGN_CENTER , 0 , -30 );
#ifdef CONFIG_USE_LV_CANVAS // LVGL Canvas Demo
// Create the Canvas
lv_obj_t * canvas = lv_canvas_create ( screen , NULL );
// Set the Canvas Buffer (Warning: Might take a lot of RAM!)
static lv_color_t cbuf [ LV_CANVAS_BUF_SIZE_TRUE_COLOR ( CANVAS_WIDTH , CANVAS_HEIGHT )];
lv_canvas_set_buffer ( canvas , cbuf , CANVAS_WIDTH , CANVAS_HEIGHT , LV_IMG_CF_TRUE_COLOR );
// Align the canvas to the center of the screen, shift 50 pixels down
lv_obj_align ( canvas , NULL , LV_ALIGN_CENTER , 0 , 50 );
// Fill the canvas with white
lv_canvas_fill_bg ( canvas , LV_COLOR_WHITE , LV_OPA_TRANSP );
// Create a Rounded Rectangle
lv_draw_rect_dsc_t rect_dsc ;
lv_draw_rect_dsc_init ( & rect_dsc );
rect_dsc . radius = 10 ; // Corner Radius
rect_dsc . bg_opa = LV_OPA_COVER ; // Opacity: Opaque
rect_dsc . bg_grad_dir = LV_GRAD_DIR_HOR ; // Gradient Direction: Horizontal
rect_dsc . bg_color = LV_COLOR_BLUE ; // From Blue
rect_dsc . bg_grad_color = LV_COLOR_GREEN ; // To Green
rect_dsc . border_width = 2 ; // Border Width
rect_dsc . border_opa = LV_OPA_90 ; // Border Opacity: 90%
rect_dsc . border_color = LV_COLOR_SILVER ; // Border Color
rect_dsc . shadow_width = 5 ; // Shadow Width
rect_dsc . shadow_ofs_x = 5 ; // Shadow Offset X
rect_dsc . shadow_ofs_y = 5 ; // Shadow Offset Y
// Draw the Rounded Rectangle to the canvas
lv_canvas_draw_rect ( canvas , 0 , 0 , 95 , 95 , & rect_dsc );
#endif // CONFIG_USE_LV_CANVAS
#ifdef CONFIG_EXAMPLES_LVGLTEST_MESSAGEBOX // LVGL Message Box Demo
// Create a Message Box Widget
lv_obj_t * msgbox = lv_msgbox_create ( screen , NULL );
// Set the Message Box Text
lv_msgbox_set_text ( msgbox , "Hello PineDio Stack!" );
// Define the Message Box Buttons
static const char * btns [] = { "Cancel" , "OK" , "" };
// Add the buttons to the Message Box
lv_msgbox_add_btns ( msgbox , btns );
#endif // CONFIG_EXAMPLES_LVGLTEST_MESSAGEBOX
}(Quelle)
Um unseren eigenen Text und Grafiken zu rendern, bearbeiten Sie diese Quelldatei und ändern Sie den obigen Code ...
apps/examples/lvgltest/lvgltest.c
Um die App auszuführen, geben Sie diese an der NUTTX -Shell ein ...
lvgldemo Um die Nachricht in der LVGL -Demo -App zu ändern, bearbeiten Sie apps/examples/lvgldemo/lv_demos/src/lv_demo_widgets/lv_demo_widgets.c ...
static void controls_create ( lv_obj_t * parent )
{
lv_page_set_scrl_layout ( parent , LV_LAYOUT_PRETTY_TOP );
lv_disp_size_t disp_size = lv_disp_get_size_category ( NULL );
lv_coord_t grid_w = lv_page_get_width_grid ( parent , disp_size <= LV_DISP_SIZE_SMALL ? 1 : 2 , 1 );
#if LV_DEMO_WIDGETS_SLIDESHOW == 0
static const char * btns [] = { "PineDio" , "Stack" , "" };
lv_obj_t * m = lv_msgbox_create ( lv_scr_act (), NULL );
lv_msgbox_add_btns ( m , btns );
lv_obj_t * btnm = lv_msgbox_get_btnmatrix ( m );
lv_btnmatrix_set_btn_ctrl ( btnm , 1 , LV_BTNMATRIX_CTRL_CHECK_STATE );
#endif Um Lora auf Pinedio Stack zu testen, bearbeiten Sie sx1262_test_main.c unter ...
apps/examples/sx1262_test/sx1262_test_main.c
Und aktualisieren Sie die LORA -Parameter ...
Lorawan arbeitet in einem gemeinsamen SPI -Bus yay in Ordnung! Pinedio Stack stellt eine Verbindung zum Lorawan Gateway (Chirpstack) her und sendet Datenpakete.
(Interner Temperatursensor auf ADC funktioniert auch in Ordnung)
Denken Sie daran, alle Info -Protokollierung zu deaktivieren, da dies die Lorawan -Timer betrifft.
So setzen wir die Lorawan -Parameter ...
"Geräte EUI, EUI und App -Schlüssel beizutreten"
"Lorawan Frequenz"
NuttShell (NSH) NuttX-10.2.0-RC0
nsh> lorawan_test
init_entropy_pool
offset = 2228
temperature = 31.600670 Celsius
offset = 2228
temperature = 31.084742 Celsius
offset = 2228
temperature = 32.890495 Celsius
offset = 2228
temperature = 33.535404 Celsius
###### ===================================== ######
Application name : lorawan_test
Application version: 1.2.0
GitHub base version: 5.0.0
###### ===================================== ######
init_event_queue
TimerInit: 0x4201c750
callout_handler: lock
TimerInit: 0x4201c76c
TimerInit: 0x4201c788
TimerInit: 0x4201c804
TimerInit: 0x4201c8b8
TimerInit: 0x4201c8d4
TimerInit: 0x4201c8f0
TimerInit: 0x4201c90c
TODO: RtcGetCalendarTime
TODO: SX126xReset
init_gpio
DIO1 pintype before=5
init_gpio: change DIO1 to Trigger GPIO Interrupt on Rising Edge
gpio_ioctl: Requested pintype 8, but actual pintype 5
DIO1 pintype after=5
Starting process_dio1
process_dio1 started
process_dio1: event=0x4201b878
init_spi
SX126xSetTxParams: power=22, rampTime=7
SX126xSetPaConfig: paDutyCycle=4, hpMax=7, deviceSel=0, paLut=1
TimerInit: 0x4201b850
TimerInit: 0x4201b7bc
RadioSetModem
RadioSetModem
RadioSetPublicNetwork: public syncword=3444
RadioSleep
DIO1 add event
TODO: EepromMcuReadBuffer
TODO: EepromMcuReadBuffer
TODO: EepromMcuReadBuffer
TODO: EepromMcuReadBuffer
TODO: EepromMcuReadBuffer
TODO: EepromMcuReadBuffer
TODO: EepromMcuReadBuffer
TODO: EepromMcuReadBuffer
RadioSetModem
RadioSetPublicNetwork: public syncword=3444
DevEui : 4B-C1-5E-E7-37-7B-B1-5B
JoinEui : 00-00-00-00-00-00-00-00
Pin : 00-00-00-00
TimerInit: 0x4201c3a8
TimerInit: 0x4201c3c4
TimerInit: 0x4201c288
TODO: RtcGetCalendarTime
TODO: RtcBkupRead
TODO: RtcBkupRead
RadioSetChannel: freq=923200000
RadioSetTxConfig: modem=1, power=13, fdev=0, bandwidth=0, datarate=10, coderate= 1, preambleLen=8, fixLen=0, crcOn=1, freqHopOn=0, hopPeriod=0, iqInverted=0, tim eout=4000
RadioSetTxConfig: SpreadingFactor=10, Bandwidth=4, CodingRate=1, LowDatarateOpti mize=0, PreambleLength=8, HeaderType=0, PayloadLength=255, CrcMode=1, InvertIQ=0
RadioStandby
RadioSetModem
SX126xSetTxParams: power=13, rampTime=7
SX126xSetPaConfig: paDutyCycle=4, hpMax=7, deviceSel=0, paLut=1
SecureElementRandomNumber: 0xa8c2a6e7
RadioSend: size=23
00 00 00 00 00 00 00 00 00 5b b1 7b 37 e7 5e c1 4b e7 a6 80 b1 e0 e4
RadioSend: PreambleLength=8, HeaderType=0, PayloadLength=23, CrcMode=1, InvertIQ =0
TimerStop: 0x4201b850
TimerStart2: 0x4201b850, 4000 ms
callout_reset: evq=0x42013250, ev=0x4201b850
###### =========== MLME-Request ============ ######
###### MLME_JOIN ######
###### ===================================== ######
STATUS : OK
StartTxProcess
TimerInit: 0x42015b7c
TimerSetValue: 0x42015b7c, 42249 ms
OnTxTimerEvent: timeout in 42249 ms, event=0
TimerStop: 0x42015b7c
TimerSetValue: 0x42015b7c, 42249 ms
TimerStart: 0x42015b7c
TimerStop: 0x42015b7c
TimerStart2: 0x42015b7c, 42249 ms
callout_reset: evq=0x42013250, ev=0x42015b7c
handle_event_queue
handle_event_queue: ev=0x4201b878
RadioOnDioIrq
RadioIrqProcess
RadioOnDioIrq
RadioIrqProcess
DIO1 add event
handle_event_queue: ev=0x4201b878
RadioOnDioIrq
RadioIrqProcess
IRQ_TX_DONE
TimerStop: 0x4201b850
TODO: RtcGetCalendarTime
TODO: RtcBkupRead
RadioOnDioIrq
RadioIrqProcess
RadioSleep
DIO1 add event
TimerSetValue: 0x4201c76c, 4988 ms
TimerStart: 0x4201c76c
TimerStop: 0x4201c76c
TimerStart2: 0x4201c76c, 4988 ms
callout_reset: evq=0x42013250, ev=0x4201c76c
TimerSetValue: 0x4201c788, 5988 ms
TimerStart: 0x4201c788
TimerStop: 0x4201c788
TimerStart2: 0x4201c788, 5988 ms
callout_reset: evq=0x42013250, ev=0x4201c788
TODO: RtcGetCalendarTime
handle_event_queue: ev=0x4201b878
RadioOnDioIrq
RadioIrqProcess
RadioOnDioIrq
RadioIrqProcess
callout_handler: unlock
callout_handler: evq=0x42013250, ev=0x4201c76c
callout_handler: lock
handle_event_queue: ev=0x4201c76c
TimerStop: 0x4201c76c
RadioStandby
RadioSetChannel: freq=923200000
RadioSetRxConfig
RadioStandby
RadioSetModem
RadioSetRxConfig done
RadioRx
TimerStop: 0x4201b7bc
TimerStart2: 0x4201b7bc, 3000 ms
callout_reset: evq=0x42013250, ev=0x4201b7bc
RadioOnDioIrq
RadioIrqProcess
DIO1 add event
handle_event_queue: ev=0x4201b878
RadioOnDioIrq
RadioIrqProcess
IRQ_PREAMBLE_DETECTED
RadioOnDioIrq
RadioIrqProcess
DIO1 add event
handle_event_queue: ev=0x4201b878
RadioOnDioIrq
RadioIrqProcess
IRQ_HEADER_VALID
RadioOnDioIrq
RadioIrqProcess
DIO1 add event
handle_event_queue: ev=0x4201b878
RadioOnDioIrq
RadioIrqProcess
IRQ_RX_DONE
TimerStop: 0x4201b7bc
RadioOnDioIrq
RadioIrqProcess
RadioSleep
DIO1 add event
TimerStop: 0x4201c788
OnTxData
###### =========== MLME-Confirm ============ ######
STATUS : OK
OnJoinRequest
###### =========== JOINED ============ ######
OTAA
DevAddr : 01097710
DATA RATE : DR_2
TODO: EepromMcuWriteBuffer
TODO: EepromMcuWriteBuffer
TODO: EepromMcuWriteBuffer
TODO: EepromMcuWriteBuffer
TODO: EepromMcuWriteBuffer
TODO: EepromMcuWriteBuffer
UplinkProcess
PrepareTxFrame: Transmit to LoRaWAN: Hi NuttX (9 bytes)
PrepareTxFrame: status=0, maxSize=11, currentSize=11
LmHandlerSend: Data frame
TODO: RtcGetCalendarTime
TODO: RtcBkupRead
RadioSetChannel: freq=923200000
RadioSetTxConfig: modem=1, power=13, fdev=0, bandwidth=0, datarate=9, coderate=1 , preambleLen=8, fixLen=0, crcOn=1, freqHopOn=0, hopPeriod=0, iqInverted=0, time out=4000
RadioSetTxConfig: SpreadingFactor=9, Bandwidth=4, CodingRate=1, LowDatarateOptim ize=0, PreambleLength=8, HeaderType=0, PayloadLength=128, CrcMode=1, InvertIQ=0
RadioStandby
RadioSetModem
SX126xSetTxParams: power=13, rampTime=7
SX126xSetPaConfig: paDutyCycle=4, hpMax=7, deviceSel=0, paLut=1
RadioSend: size=22
40 10 77 09 01 00 01 00 01 a5 12 b3 cc a2 27 27 57 dc c3 a7 eb ae
RadioSend: PreambleLength=8, HeaderType=0, PayloadLength=22, CrcMode=1, InvertIQ =0
TimerStop: 0x4201b850
TimerStart2: 0x4201b850, 4000 ms
callout_reset: evq=0x42013250, ev=0x4201b850
###### =========== MCPS-Request ============ ######
###### MCPS_UNCONFIRMED ######
###### ===================================== ######
STATUS : OK
PrepareTxFrame: Transmit OK
handle_event_queue: ev=0x4201b878
RadioOnDioIrq
RadioIrqProcess
RadioOnDioIrq
RadioIrqProcess
DIO1 add event
handle_event_queue: ev=0x4201b878
RadioOnDioIrq
RadioIrqProcess
IRQ_TX_DONE
TimerStop: 0x4201b850
TODO: RtcGetCalendarTime
TODO: RtcBkupRead
RadioOnDioIrq
RadioIrqProcess
RadioSleep
DIO1 add event
TimerSetValue: 0x4201c76c, 980 ms
TimerStart: 0x4201c76c
TimerStop: 0x4201c76c
TimerStart2: 0x4201c76c, 980 ms
callout_reset: evq=0x42013250, ev=0x4201c76c
TimerSetValue: 0x4201c788, 1988 ms
TimerStart: 0x4201c788
TimerStop: 0x4201c788
TimerStart2: 0x4201c788, 1988 ms
callout_reset: evq=0x42013250, ev=0x4201c788
TODO: RtcGetCalendarTime
handle_event_queue: ev=0x4201b878
RadioOnDioIrq
RadioIrqProcess
RadioOnDioIrq
RadioIrqProcess
callout_handler: unlock
callout_handler: evq=0x42013250, ev=0x4201c76c
callout_handler: lock
handle_event_queue: ev=0x4201c76c
TimerStop: 0x4201c76c
RadioStandby
RadioSetChannel: freq=923200000
RadioSetRxConfig
RadioStandby
RadioSetModem
RadioSetRxConfig done
RadioRx
TimerStop: 0x4201b7bc
TimerStart2: 0x4201b7bc, 3000 ms
callout_reset: evq=0x42013250, ev=0x4201b7bc
RadioOnDioIrq
RadioIrqProcess
DIO1 add event
handle_event_queue: ev=0x4201b878
RadioOnDioIrq
RadioIrqProcess
IRQ_RX_TX_TIMEOUT
TimerStop: 0x4201b7bc
RadioOnDioIrq
RadioIrqProcess
RadioSleep
DIO1 add event
TimerStop: 0x4201c788
TimerStop: 0x4201c750
OnTxData
###### =========== MCPS-Confirm ============ ######
STATUS : OK
###### ===== UPLINK FRAME 1 ===== ######
CLASS : A
TX PORT : 1
TX DATA : UNCONFIRMED
48 69 20 4E 75 74 74 58 00
DATA RATE : DR_3
U/L FREQ : 923200000
TX POWER : 0
CHANNEL MASK: 0003
TODO: EepromMcuWriteBuffer
TODO: EepromMcuWriteBuffer
UplinkProcess
handle_event_queue: ev=0x4201b878
RadioOnDioIrq
RadioIrqProcess
RadioOnDioIrq
RadioIrqProcess
UplinkProcess
callout_handler: unlock
callout_handler: evq=0x42013250, ev=0x42015b7c
callout_handler: lock
handle_event_queue: ev=0x42015b7c
OnTxTimerEvent: timeout in 42249 ms, event=0x42015b7c
TimerStop: 0x42015b7c
TimerSetValue: 0x42015b7c, 42249 ms
TimerStart: 0x42015b7c
TimerStop: 0x42015b7c
TimerStart2: 0x42015b7c, 42249 ms
callout_reset: evq=0x42013250, ev=0x42015b7c
RadioOnDioIrq
RadioIrqProcess
UplinkProcess
PrepareTxFrame: Transmit to LoRaWAN: Hi NuttX (9 bytes)
PrepareTxFrame: status=0, maxSize=53, currentSize=53
LmHandlerSend: Data frame
TODO: RtcGetCalendarTime
TODO: RtcBkupRead
RadioSetChannel: freq=923200000
RadioSetTxConfig: modem=1, power=13, fdev=0, bandwidth=0, datarate=9, coderate=1, preambleLen=8, fixLen=0, crcOn=1, freqHopOn=0, hopPeriod=0, iqInverted=0, timeout=4000
RadioSetTxConfig: SpreadingFactor=9, Bandwidth=4, CodingRate=1, LowDatarateOptimize=0, PreambleLength=8, HeaderType=0, PayloadLength=128, CrcMode=1, InvertIQ=0
RadioStandby
RadioSetModem
SX126xSetTxParams: power=13, rampTime=7
SX126xSetPaConfig: paDutyCycle=4, hpMax=7, deviceSel=0, paLut=1
RadioSend: size=22
40 10 77 09 01 00 02 00 01 ad b9 67 e6 1c 34 05 2d f3 d3 b5 c7 16
RadioSend: PreambleLength=8, HeaderType=0, PayloadLength=22, CrcMode=1, InvertIQ=0
TimerStop: 0x4201b850
TimerStart2: 0x4201b850, 4000 ms
callout_reset: evq=0x42013250, ev=0x4201b850
###### =========== MCPS-Request ============ ######
###### MCPS_UNCONFIRMED ######
###### ===================================== ######
STATUS : OK
PrepareTxFrame: Transmit OK
DIO1 add event
handle_event_queue: ev=0x4201b878
RadioOnDioIrq
RadioIrqProcess
IRQ_TX_DONE
TimerStop: 0x4201b850
TODO: RtcGetCalendarTime
TODO: RtcBkupRead
RadioOnDioIrq
RadioIrqProcess
RadioSleep
DIO1 add event
TimerSetValue: 0x4201c76c, 980 ms
TimerStart: 0x4201c76c
TimerStop: 0x4201c76c
TimerStart2: 0x4201c76c, 980 ms
callout_reset: evq=0x42013250, ev=0x4201c76c
TimerSetValue: 0x4201c788, 1988 ms
TimerStart: 0x4201c788
TimerStop: 0x4201c788
TimerStart2: 0x4201c788, 1988 ms
callout_reset: evq=0x42013250, ev=0x4201c788
TODO: RtcGetCalendarTime
handle_event_queue: ev=0x4201b878
RadioOnDioIrq
RadioIrqProcess
RadioOnDioIrq
RadioIrqProcess
callout_handler: unlock
callout_handler: evq=0x42013250, ev=0x4201c76c
callout_handler: lock
handle_event_queue: ev=0x4201c76c
TimerStop: 0x4201c76c
RadioStandby
RadioSetChannel: freq=923200000
RadioSetRxConfig
RadioStandby
RadioSetModem
RadioSetRxConfig done
RadioRx
TimerStop: 0x4201b7bc
TimerStart2: 0x4201b7bc, 3000 ms
callout_reset: evq=0x42013250, ev=0x4201b7bc
RadioOnDioIrq
RadioIrqProcess
DIO1 add event
handle_event_queue: ev=0x4201b878
RadioOnDioIrq
RadioIrqProcess
IRQ_RX_TX_TIMEOUT
TimerStop: 0x4201b7bc
RadioOnDioIrq
RadioIrqProcess
RadioSleep
DIO1 add event
TimerStop: 0x4201c788
TimerStop: 0x4201c750
OnTxData
###### =========== MCPS-Confirm ============ ######
STATUS : OK
###### ===== UPLINK FRAME 2 ===== ######
CLASS : A
TX PORT : 1
TX DATA : UNCONFIRMED
48 69 20 4E 75 74 74 58 00
DATA RATE : DR_3
U/L FREQ : 923200000
TX POWER : 0
CHANNEL MASK: 0003
TODO: EepromMcuWriteBuffer
TODO: EepromMcuWriteBuffer
UplinkProcess
handle_event_queue: ev=0x4201b878
RadioOnDioIrq
RadioIrqProcess
RadioOnDioIrq
RadioIrqProcess
UplinkProcess
TODO: Siehe Pinedio-Stack-Selfest/Treiber/CST816S.C
TODO: Siehe Pinedio-Stack-Self-Test/PushButton.c
TODO: Siehe Pinedio-Stack-Selbsttest/Accelerometer.c
TODO: Siehe Pinedio-Stack-Selbsttest/Batterie.c
Todo
TODO: Nuttx hat eine GPS -Demo -App ...
Apps/Beispiele/GPS/GPS_MAIN.C
Und ein GPS -Parser ...
Apps/GPSUtils