mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-19 06:40:45 +00:00
add uart for ea4357
This commit is contained in:
parent
f9262007ac
commit
e4570c35f7
@ -28,15 +28,14 @@
|
|||||||
#include "../board.h"
|
#include "../board.h"
|
||||||
#include "pca9532.h"
|
#include "pca9532.h"
|
||||||
|
|
||||||
#define BOARD_UART_PORT LPC_USART0
|
#define UART_DEV LPC_USART0
|
||||||
#define BOARD_UART_PIN_PORT 0x0f
|
#define UART_PORT 0x0f
|
||||||
#define BOARD_UART_PIN_TX 10 // PF.10 : UART0_TXD
|
#define UART_PIN_TX 10 // PF.10 : UART0_TXD
|
||||||
#define BOARD_UART_PIN_RX 11 // PF.11 : UART0_RXD
|
#define UART_PIN_RX 11 // PF.11 : UART0_RXD
|
||||||
|
|
||||||
// P9_1 joystick down
|
// P9_1 joystick down
|
||||||
#define BUTTON_PORT 4
|
#define BUTTON_PORT 4
|
||||||
#define BUTTON_PIN 13
|
#define BUTTON_PIN 13
|
||||||
|
|
||||||
|
|
||||||
//static const struct {
|
//static const struct {
|
||||||
// uint8_t mux_port;
|
// uint8_t mux_port;
|
||||||
@ -68,14 +67,6 @@ static const PINMUX_GRP_T pinmuxing[] =
|
|||||||
{0x9, 1, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLUP)},
|
{0x9, 1, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0 | SCU_MODE_PULLUP)},
|
||||||
|
|
||||||
// USB
|
// USB
|
||||||
|
|
||||||
/* I2S */
|
|
||||||
{0x3, 0, (SCU_PINIO_FAST | SCU_MODE_FUNC2)}, //I2S0_TX_CLK
|
|
||||||
{0xC, 12, (SCU_PINIO_FAST | SCU_MODE_FUNC6)}, //I2S0_TX_SDA
|
|
||||||
{0xC, 13, (SCU_PINIO_FAST | SCU_MODE_FUNC6)}, //I2S0_TX_WS
|
|
||||||
{0x6, 0, (SCU_PINIO_FAST | SCU_MODE_FUNC4)}, //I2S0_RX_SCK
|
|
||||||
{0x6, 1, (SCU_PINIO_FAST | SCU_MODE_FUNC3)}, //I2S0_RX_WS
|
|
||||||
{0x6, 2, (SCU_PINIO_FAST | SCU_MODE_FUNC3)}, //I2S0_RX_SDA
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Pin clock mux values, re-used structure, value in first index is meaningless */
|
/* Pin clock mux values, re-used structure, value in first index is meaningless */
|
||||||
@ -127,19 +118,14 @@ void board_init(void)
|
|||||||
// Button
|
// Button
|
||||||
Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, BUTTON_PORT, BUTTON_PIN);
|
Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, BUTTON_PORT, BUTTON_PIN);
|
||||||
|
|
||||||
#if 0
|
|
||||||
//------------- UART -------------//
|
//------------- UART -------------//
|
||||||
scu_pinmux(BOARD_UART_PIN_PORT, BOARD_UART_PIN_TX, MD_PDN, FUNC1);
|
Chip_SCU_PinMuxSet(UART_PORT, UART_PIN_TX, (SCU_MODE_PULLDOWN | SCU_MODE_FUNC1));
|
||||||
scu_pinmux(BOARD_UART_PIN_PORT, BOARD_UART_PIN_RX, MD_PLN | MD_EZI | MD_ZI, FUNC1);
|
Chip_SCU_PinMuxSet(UART_PORT, UART_PIN_RX, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC1));
|
||||||
|
|
||||||
UART_CFG_Type UARTConfigStruct;
|
Chip_UART_Init(UART_DEV);
|
||||||
UART_ConfigStructInit(&UARTConfigStruct);
|
Chip_UART_SetBaud(UART_DEV, CFG_BOARD_UART_BAUDRATE);
|
||||||
UARTConfigStruct.Baud_rate = CFG_BOARD_UART_BAUDRATE;
|
Chip_UART_ConfigData(UART_DEV, UART_LCR_WLEN8 | UART_LCR_SBS_1BIT | UART_LCR_PARITY_DIS);
|
||||||
UARTConfigStruct.Clock_Speed = 0;
|
Chip_UART_TXEnable(UART_DEV);
|
||||||
|
|
||||||
UART_Init(BOARD_UART_PORT, &UARTConfigStruct);
|
|
||||||
UART_TxCmd(BOARD_UART_PORT, ENABLE); // Enable UART Transmit
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//------------- USB -------------//
|
//------------- USB -------------//
|
||||||
enum {
|
enum {
|
||||||
@ -278,16 +264,21 @@ uint32_t board_button_read(void)
|
|||||||
|
|
||||||
int board_uart_read(uint8_t* buf, int len)
|
int board_uart_read(uint8_t* buf, int len)
|
||||||
{
|
{
|
||||||
//return UART_ReceiveByte(BOARD_UART_PORT);
|
//return UART_ReceiveByte(BOARD_UART_DEV);
|
||||||
(void) buf; (void) len;
|
(void) buf; (void) len;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int board_uart_write(void const * buf, int len)
|
int board_uart_write(void const * buf, int len)
|
||||||
{
|
{
|
||||||
//UART_Send(BOARD_UART_PORT, &c, 1, BLOCKING);
|
uint8_t const* buf8 = (uint8_t const*) buf;
|
||||||
(void) buf; (void) len;
|
for(int i=0; i<len; i++)
|
||||||
return 0;
|
{
|
||||||
|
while ((Chip_UART_ReadLineStatus(UART_DEV) & UART_LSR_THRE) == 0) {}
|
||||||
|
Chip_UART_SendByte(UART_DEV, buf8[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||||
|
@ -223,12 +223,16 @@ void tu_print_mem(void const *buf, uint16_t count, uint8_t indent);
|
|||||||
#define TU_LOG1 tu_printf
|
#define TU_LOG1 tu_printf
|
||||||
#define TU_LOG1_MEM tu_print_mem
|
#define TU_LOG1_MEM tu_print_mem
|
||||||
#define TU_LOG1_LOCATION() tu_printf("%s: %d:\r\n", __PRETTY_FUNCTION__, __LINE__)
|
#define TU_LOG1_LOCATION() tu_printf("%s: %d:\r\n", __PRETTY_FUNCTION__, __LINE__)
|
||||||
|
#define TU_LOG1_INT(x) tu_printf(#x " = %ld\n", (uint32_t) (x) )
|
||||||
|
#define TU_LOG1_HEX(x) tu_printf(#x " = %lX\n", (uint32_t) (x) )
|
||||||
|
|
||||||
// Log with debug level 2
|
// Log with debug level 2
|
||||||
#if CFG_TUSB_DEBUG > 1
|
#if CFG_TUSB_DEBUG > 1
|
||||||
#define TU_LOG2 TU_LOG1
|
#define TU_LOG2 TU_LOG1
|
||||||
#define TU_LOG2_MEM TU_LOG1_MEM
|
#define TU_LOG2_MEM TU_LOG1_MEM
|
||||||
#define TU_LOG2_LOCATION() TU_LOG1_LOCATION()
|
#define TU_LOG2_LOCATION() TU_LOG1_LOCATION()
|
||||||
|
#define TU_LOG2_INT TU_LOG1_INT
|
||||||
|
#define TU_LOG2_HEX TU_LOG1_HEX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user