|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
ThreadX + NetX Duo TCP echo demo for EK-RA8D2. More...
#include <stdint.h>#include <string.h>#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_eth.h"#include "ra8_isr.h"#include "ra8_time.h"#include "nx_api.h"#include "nx_ether_driver_ra8_eth.h"#include "tx_api.h"Go to the source code of this file.
Functions | |
| static void | demo_panic_halt (void) |
| Halt forever in WFI. | |
| static void | demo_setup_or_halt (void) |
| Bring CGC + the J-Link OB VCOM console + on-board Ethernet up. | |
| static void | demo_print (const char *s) |
| Convenience wrapper to write a NUL-terminated string to SCI8. | |
| static char * | demo_append_byte (char *buf, uint8_t v) |
| Append a single decimal byte to the staging buffer. | |
| static ULONG | demo_pack_ip (const uint8_t *octets) |
| Pack a 4-octet IPv4 array into NetX's host-order ULONG. | |
| static void | demo_pack_mac (ULONG *msw, ULONG *lsw) |
| Pack the local MAC into the msw/lsw fields NetX expects. | |
| static void | demo_log_echo (ULONG n, ULONG peer_ip) |
| Log "echoed N bytes from a.b.c.d" to SCI8. | |
| static UINT | demo_netx_create_ip (void) |
| Creates the NetX packet pool and IP instance with our MAC. | |
| static UINT | demo_netx_bring_up (void) |
| static void | demo_echo_loop (void) |
| Echo loop: accept -> recv -> send -> disconnect -> relisten. | |
| static void | demo_thread_entry (ULONG thread_input) |
| ThreadX worker entry: bring NetX up, then run the echo loop. | |
| void | tx_application_define (void *first_unused_memory) |
| ThreadX system-define hook: build worker thread + NetX core. | |
| void | main (void) |
| Application entry. | |
Variables | |
| static const uint8_t | k_demo_mac [6] = {0x02U, 0x00U, 0x00U, 0x00U, 0x00U, 0x01U} |
| static const uint8_t | k_demo_ip [4] |
| IPv4 address: 192.168.1.42 / 255.255.255.0. | |
| static const uint8_t | k_demo_mask [4] = {k_demo_netmask_b, k_demo_netmask_b, k_demo_netmask_b, 0U} |
| Subnet mask: 255.255.255.0. | |
| static NX_PACKET_POOL | s_packet_pool |
| static NX_IP | s_ip |
| static NX_TCP_SOCKET | s_echo_socket |
| static UCHAR | s_pool_memory [k_demo_pool_bytes] |
| static ULONG | s_ip_stack [k_demo_ip_stack/sizeof(ULONG)] |
| static ULONG | s_arp_cache [k_demo_arp_cache/sizeof(ULONG)] |
| static TX_THREAD | s_demo_thread |
| static UCHAR | s_demo_stack [k_demo_thread_stack] |
ThreadX + NetX Duo TCP echo demo for EK-RA8D2.
Brings the chip up the same way uart_hello does (CGC -> SCI8 @ 115200 8N1) and then hands control to ThreadX. The ThreadX application-define hook configures NetX Duo on top of our hardware Ethernet driver shim (nx_ether_driver_ra8_eth):
The single worker thread loops:
Each accepted byte is logged to SCI8 as "echoed N bytes from a.b.c.d\r\n" so the J-Link OB CDC port gives visible feedback. NetX Duo is now the only TCP/IP stack in the tree – the hand-rolled ra8_net adapter and its companion ethernet_tcp_echo / ethernet_udp_echo / ethernet_http_responder apps were retired in #7.
Definition in file main.c.
| enum demo_config_t : uint32_t |
Compile-time settings for the NetX Duo TCP-echo demo.
Every numeric used during bring-up appears here so the magic- number lint never sees a bare integer. The SCI8 channel matches the on-board J-Link OB CDC bridge pins (PD_02 / PD_03). The pool sizing follows the standard NetX Duo demo recipe (16 packets at 1568 bytes each; pool overhead allowed for) which fits easily in the 2 MiB SRAM budget.
| enum demo_decimal_t : uint8_t |
Constants used by the tiny base-10 byte-to-ASCII helper.
| Enumerator | |
|---|---|
| k_demo_decimal_base | Base used by demo_append_byte. |
| enum demo_ip_octet_t : uint8_t |
| enum demo_ip_shift_t : uint8_t |
| enum demo_ipv4_t : uint16_t |
| enum demo_mac_idx_t : uint8_t |
| enum demo_mac_word_shift_t : uint8_t |
Shifts that pack the 6-byte MAC into msw/lsw ULONG pairs.
|
static |
Append a single decimal byte to the staging buffer.
| [in,out] | buf | Buffer pointer (advanced past the appended digits). |
| [in] | v | Byte value (0..255). |
Definition at line 269 of file main.c.
References k_demo_decimal_base.
Referenced by demo_log_echo().
|
static |
Echo loop: accept -> recv -> send -> disconnect -> relisten.
Definition at line 506 of file main.c.
References demo_log_echo(), demo_print(), k_demo_echo_port, s_echo_socket, and s_ip.
Referenced by demo_thread_entry().
Log "echoed N bytes from a.b.c.d" to SCI8.
| [in] | n | Number of bytes echoed. |
| [in] | peer_ip | Peer's IPv4 address as a host-order ULONG. |
Definition at line 336 of file main.c.
References demo_append_byte(), demo_print(), k_demo_decimal_base, k_demo_ip_shift_a, k_demo_ip_shift_b, k_demo_ip_shift_c, k_demo_ip_shift_d, k_demo_log_buf_bytes, and k_demo_octet_mask.
Referenced by demo_echo_loop().
|
static |
Definition at line 451 of file main.c.
References demo_netx_create_ip(), k_demo_echo_port, k_demo_packet_count, k_demo_recv_window, k_demo_socket_ttl, s_arp_cache, s_echo_socket, s_ip, and s_socket_name.
|
static |
Creates the NetX packet pool and IP instance with our MAC.
| NX_SUCCESS | Pool and IP created; MAC pushed to link driver. |
Definition at line 406 of file main.c.
References demo_pack_ip(), demo_pack_mac(), k_demo_ip, k_demo_ip_thread_pri, k_demo_mac, k_demo_mask, k_demo_packet_size, nx_ether_driver_ra8_eth(), nx_ether_driver_ra8_eth_set_mac(), s_ip, s_ip_name, s_ip_stack, s_packet_pool, s_packet_pool_name, and s_pool_memory.
Referenced by demo_netx_bring_up().
|
static |
Pack a 4-octet IPv4 array into NetX's host-order ULONG.
| [in] | octets | IPv4 address (4 bytes). |
Definition at line 302 of file main.c.
References k_demo_ip_oct_a, k_demo_ip_oct_b, k_demo_ip_oct_c, k_demo_ip_oct_d, k_demo_ip_shift_a, k_demo_ip_shift_b, k_demo_ip_shift_c, and k_demo_ip_shift_d.
Pack the local MAC into the msw/lsw fields NetX expects.
| [out] | msw | Most-significant word (octets 0-1). |
| [out] | lsw | Least-significant word (octets 2-5). |
Definition at line 318 of file main.c.
References k_demo_mac, k_demo_mac_idx_0, k_demo_mac_idx_1, k_demo_mac_idx_2, k_demo_mac_idx_3, k_demo_mac_idx_4, k_demo_mac_idx_5, k_demo_mac_lsw_shift_b2, k_demo_mac_lsw_shift_b3, k_demo_mac_lsw_shift_b4, k_demo_mac_lsw_shift_b5, k_demo_mac_msw_shift_b0, and k_demo_mac_msw_shift_b1.
|
static |
|
static |
Convenience wrapper to write a NUL-terminated string to SCI8.
| [in] | s | NUL-terminated ASCII string. Must not be NULL. |
Definition at line 248 of file main.c.
References ra8_board_uart_console_write(), and strlen().
|
static |
Bring CGC + the J-Link OB VCOM console + on-board Ethernet up.
Definition at line 217 of file main.c.
References demo_panic_halt(), k_demo_baud, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_ethernet_init(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), and ra8_time_init().
|
static |
ThreadX worker entry: bring NetX up, then run the echo loop.
| [in] | thread_input | Unused. |
Definition at line 551 of file main.c.
References demo_echo_loop(), demo_netx_bring_up(), and demo_print().
| void main | ( | void | ) |
Application entry.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART + RMII pins, then enters ThreadX.
Definition at line 609 of file main.c.
References demo_panic_halt(), demo_print(), demo_setup_or_halt(), and ra8_isr_globals_enable().
| void tx_application_define | ( | void * | first_unused_memory | ) |
ThreadX system-define hook: build worker thread + NetX core.
| [in] | first_unused_memory | Pointer to free RAM provided by the ThreadX port; unused – we statically allocate. |
Definition at line 580 of file main.c.
References demo_thread_entry(), k_demo_app_thread_pri, s_demo_stack, s_demo_thread, s_thread_name, TX_AUTO_START, TX_NO_TIME_SLICE, and tx_thread_create.
|
static |
IPv4 address: 192.168.1.42 / 255.255.255.0.
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 183 of file main.c.
Referenced by demo_echo_loop(), and demo_netx_bring_up().
|
static |
|
static |