Skip to content

Commit

Permalink
Fixing Serial
Browse files Browse the repository at this point in the history
  • Loading branch information
lupyuen committed Nov 10, 2023
1 parent cd8c10c commit 3405a69
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 67 deletions.
124 changes: 124 additions & 0 deletions arch/risc-v/src/jh7110/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

comment "BL602 Configuration Options"

menu "BL602 Peripheral Support"

config BL602_DMA
bool "DMA"
default n
select ARCH_DMA

config BL602_HAVE_UART0
bool "UART0"
select BL602_UART0
select ARCH_HAVE_UART0
select UART0_SERIALDRIVER
select ARCH_HAVE_SERIAL_TERMIOS
select ARCH_HAVE_PWM_MULTICHAN

config BL602_UART0
bool
default n

config BL602_HAVE_UART1
bool "UART1"
select BL602_UART1
select ARCH_HAVE_UART1
select UART1_SERIALDRIVER
select ARCH_HAVE_SERIAL_TERMIOS

config BL602_UART1
bool
default n

config BL602_TIMER0
bool "TIMER0"

config BL602_TIMER1
bool "TIMER1"

config BL602_PWM0
bool "PWM0"

config BL602_I2C0
bool "I2C0"

config BL602_I2C_DMA
bool "I2C DMA support"
default n
depends on BL602_DMA
---help---
Select to enable DMA SPI transfers

config BL602_SPI0
bool "SPI0"

config BL602_SPI_DMA
bool "SPI DMA support"
default n
depends on BL602_DMA
---help---
Select to enable DMA SPI transfers

config BL602_RTC
bool "RTC"

config BL602_RTC_USE_XTAL32K
bool "Select enable RTC XTAL32K clock source, otherwise use internal RC32K"
default n
depends on BL602_RTC

config BL602_SPIFLASH
bool "SPI Flash"
default n
select MTD
select MTD_PARTITION

menu "SPI Flash configuration"
depends on BL602_SPIFLASH

config BL602_MTD_OFFSET
hex "MTD base address in SPI Flash"
default 0x001c5000
---help---
MTD base address in SPI Flash.

config BL602_MTD_SIZE
hex "MTD size in SPI Flash"
default 0x30000
---help---
MTD size in SPI Flash.

endmenu # BL602_SPIFLASH

config BL602_WIRELESS
bool "Wireless & WiFi Support"
depends on SCHED_WORKQUEUE
default n

config BL602_WIRELESS_DEBUG
bool "Wireless Debug Log"
depends on BL602_WIRELESS
default n

config BL602_WIRELESS_CONTRY_CODE
string "WiFi Contry Code"
depends on BL602_WIRELESS
default "CN"

config BL602_NET_MULTI_INTERFACE
bool "STA and AP as independent interfaces"
depends on BL602_WIRELESS
default n

config BL602_BLE_CONTROLLER
bool "ble controller support"
default n
depends on !DISABLE_MQUEUE
depends on SCHED_WORKQUEUE
depends on BL602_WIRELESS
endmenu
72 changes: 5 additions & 67 deletions arch/risc-v/src/jh7110/bl602_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@
* provide some minimal implementation of up_putc.
*/

#ifdef USE_SERIALDRIVER

/* Which UART with be tty0/console and which tty1? The console will always
* be ttyS0. If there is no console then will use the lowest numbered UART.
*/
Expand Down Expand Up @@ -114,8 +112,6 @@
* up_putc().
*/

#ifdef HAVE_UART_DEVICE

/****************************************************************************
* Private Types
****************************************************************************/
Expand Down Expand Up @@ -808,10 +804,8 @@ static bool bl602_txempty(struct uart_dev_s *dev)
* Public Functions
****************************************************************************/

#ifdef USE_EARLYSERIALINIT

/****************************************************************************
* Name: riscv_earlyserialinit
* Name: bl602_earlyserialinit
*
* Description:
* Performs the low level UART initialization early in debug so that the
Expand All @@ -822,7 +816,7 @@ static bool bl602_txempty(struct uart_dev_s *dev)
*
****************************************************************************/

void riscv_earlyserialinit(void)
void bl602_earlyserialinit(void)
{
#ifdef HAVE_SERIAL_CONSOLE
/* Configuration whichever one is the console */
Expand All @@ -831,18 +825,17 @@ void riscv_earlyserialinit(void)
bl602_setup(&CONSOLE_DEV);
#endif
}
#endif

/****************************************************************************
* Name: riscv_serialinit
* Name: bl602_serialinit
*
* Description:
* Register serial console and serial ports. This assumes
* that riscv_earlyserialinit was called previously.
*
****************************************************************************/

void riscv_serialinit(void)
void bl602_serialinit(void)
{
int i;
char devname[16];
Expand Down Expand Up @@ -885,9 +878,9 @@ void riscv_serialinit(void)
*
****************************************************************************/

#ifdef HAVE_SERIAL_CONSOLE
int up_putc(int ch)
{
#ifdef HAVE_SERIAL_CONSOLE
irqstate_t flags = enter_critical_section();

/* Check for LF */
Expand All @@ -901,61 +894,6 @@ int up_putc(int ch)

riscv_lowputc(ch);
leave_critical_section(flags);
#endif
return ch;
}

/****************************************************************************
* Name: riscv_earlyserialinit, riscv_serialinit, and up_putc
*
* Description:
* stubs that may be needed. These stubs would be used if all UARTs are
* disabled. In that case, the logic in common/up_initialize() is not
* smart enough to know that there are not UARTs and will still expect
* these interfaces to be provided.
*
****************************************************************************/

#else /* HAVE_UART_DEVICE */
void riscv_earlyserialinit(void)
{
}

void riscv_serialinit(void)
{
}

int up_putc(int ch)
{
return ch;
}

#endif /* HAVE_UART_DEVICE */
#else /* USE_SERIALDRIVER */

/****************************************************************************
* Name: up_putc
*
* Description:
* Provide priority, low-level access to support OS debug writes
*
****************************************************************************/

int up_putc(int ch)
{
#ifdef HAVE_SERIAL_CONSOLE
/* Check for LF */

if (ch == '\n')
{
/* Add CR */

riscv_lowputc('\r');
}

riscv_lowputc(ch);
#endif
return ch;
}

#endif /* USE_SERIALDRIVER */
10 changes: 10 additions & 0 deletions arch/risc-v/src/jh7110/jh7110_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,13 @@ void jh7110_start(int mhartid)

jh7110_start_s(mhartid);
}

void riscv_earlyserialinit(void)
{
bl602_earlyserialinit();
}

void riscv_serialinit(void)
{
bl602_serialinit();
}
2 changes: 2 additions & 0 deletions boards/risc-v/jh7110/star64/configs/nsh/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#
# CONFIG_DISABLE_OS_API is not set
# CONFIG_NSH_DISABLE_LOSMART is not set
# CONFIG_STANDARD_SERIAL is not set
CONFIG_ARCH="risc-v"
CONFIG_ARCH_ADDRENV=y
CONFIG_ARCH_BOARD="star64"
Expand All @@ -30,6 +31,7 @@ CONFIG_ARCH_TEXT_VBASE=0xC0000000
CONFIG_ARCH_USE_MMU=y
CONFIG_ARCH_USE_MPU=y
CONFIG_ARCH_USE_S_MODE=y
CONFIG_BL602_HAVE_UART0=y
CONFIG_BOARDCTL_ROMDISK=y
CONFIG_BOARD_LATE_INITIALIZE=y
CONFIG_BOARD_LOOPSPERMSEC=116524
Expand Down

0 comments on commit 3405a69

Please sign in to comment.