[platform][lpc43xx] add register definitions for some core bits
This commit is contained in:
69
platform/lpc43xx/include/platform/lpc43xx-clocks.h
Normal file
69
platform/lpc43xx/include/platform/lpc43xx-clocks.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Brian Swetland
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files
|
||||
* (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define BASE_SAFE_CLK 0x4005005C // only CLK_IRC allowed
|
||||
#define BASE_USB0_CLK 0x40050060 // only CLK_PLL0USB allowed
|
||||
#define BASE_PERIPH_CLK 0x40050064
|
||||
#define BASE_USB1_CLK 0x40050068
|
||||
#define BASE_M4_CLK 0x4005006C
|
||||
#define BASE_SPIFI_CLK 0x40050070
|
||||
#define BASE_SPI_CLK 0x40050074
|
||||
#define BASE_PHY_RX_CLK 0x40050078
|
||||
#define BASE_PHY_TX_CLK 0x4005008C
|
||||
#define BASE_APB1_CLK 0x40050080
|
||||
#define BASE_APB3_CLK 0x40050084
|
||||
#define BASE_LCD_CLK 0x40050088
|
||||
#define BASE_ADCHS_CLK 0x4005008C
|
||||
#define BASE_SDIO_CLK 0x40050090
|
||||
#define BASE_SSP0_CLK 0x40050094
|
||||
#define BASE_SSP1_CLK 0x40050098
|
||||
#define BASE_UART0_CLK 0x4005009C
|
||||
#define BASE_UART1_CLK 0x400500A0
|
||||
#define BASE_UART2_CLK 0x400500A4
|
||||
#define BASE_UART3_CLK 0x400500A8
|
||||
#define BASE_OUT_CLK 0x400500AC
|
||||
#define BASE_AUDIO_CLK 0x400500C0
|
||||
#define BASE_CGU_OUT0_CLK 0x400500C4
|
||||
#define BASE_CGU_OUT1_CLK 0x400500C8
|
||||
|
||||
#define BASE_X_PD (1 << 0) // power-down
|
||||
#define BASE_X_AUTOBLOCK (1 << 11)
|
||||
#define BASE_X_SEL(n) ((n) << 24)
|
||||
|
||||
#define CLK_32K 0x00
|
||||
#define CLK_IRC 0x01 // 12MHz internal RC OSC
|
||||
#define CLK_ENET_RX 0x02
|
||||
#define CLK_ENET_TX 0x03
|
||||
#define CLK_GP_CLKIN 0x04
|
||||
#define CLK_XTAL_OSC 0x06
|
||||
#define CLK_PLL0USB 0x07 // only allowed for BASE_{USB0,USB1,OUT}_CLK
|
||||
#define CLK_PLL0AUDIO 0x08
|
||||
#define CLK_PLL1 0x09
|
||||
#define CLK_IDIVA 0x0C
|
||||
#define CLK_IDIVB 0x0D
|
||||
#define CLK_IDIVC 0x0E
|
||||
#define CLK_IDIVD 0x0F
|
||||
#define CLK_IDIVE 0x10
|
||||
|
||||
60
platform/lpc43xx/include/platform/lpc43xx-gpio.h
Normal file
60
platform/lpc43xx/include/platform/lpc43xx-gpio.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Brian Swetland
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files
|
||||
* (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// pinmux
|
||||
|
||||
#define PIN_CFG(m,n) (0x40086000 + ((m) * 0x80) + ((n) * 4))
|
||||
#define PIN_MODE(n) ((n) & 3)
|
||||
#define PIN_PULLUP (0 << 3) // pull-up, no pull-down
|
||||
#define PIN_REPEATER (1 << 3) // repeater mode
|
||||
#define PIN_PLAIN (2 << 3) // no pull-up, no pull-down
|
||||
#define PIN_PULLDOWN (3 << 3) // pull-down, no pull-up
|
||||
#define PIN_SLOW (0 << 5) // slow slew rate (low noise, medium speed)
|
||||
#define PIN_FAST (1 << 5) // fast slew rate (medium noise, fast speed)
|
||||
#define PIN_INPUT (1 << 6) // enable input buffer, required for inputs
|
||||
#define PIN_FILTER (1 << 7) // enable glitch filter, not for >30MHz signals
|
||||
|
||||
// gpio
|
||||
|
||||
// each GPIO as a single byte or word register
|
||||
// write zero to clear
|
||||
// write non-zero to set
|
||||
// reads as zero if input is low
|
||||
// reads as FF (byte) or FFFFFFFF (word) if input is high
|
||||
#define GPIO_BYTE(m,n) (0x400F4000 + ((m) * 0x20) + (n))
|
||||
#define GPIO_WORD(m,n) (0x400F5000 + ((m) * 0x80) + ((n) * 4))
|
||||
|
||||
// GPIOs grouped by port, with one bit per pin
|
||||
#define GPIO_DIR(m) (0x400F6000 + ((m) * 4)) // 1 = output, 0 = input
|
||||
#define GPIO_MASK(m) (0x400F6080 + ((m) * 4)) // 1s disable MPIN() bits
|
||||
#define GPIO_PIN(m) (0x400F6100 + ((m) * 4)) // r/w value at pins
|
||||
#define GPIO_MPIN(m) (0x400F6180 + ((m) * 4)) // r value at pins & ~MASK
|
||||
// w only MASK bits
|
||||
#define GPIO_SET(m) (0x400F6200 + ((m) * 4)) // write 1s to set
|
||||
#define GPIO_CLR(m) (0x400F6280 + ((m) * 4)) // write 1s to clear
|
||||
#define GPIO_NOT(m) (0x400F6300 + ((m) * 4)) // write 1s to invert
|
||||
|
||||
|
||||
|
||||
113
platform/lpc43xx/include/platform/lpc43xx-uart.h
Normal file
113
platform/lpc43xx/include/platform/lpc43xx-uart.h
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Brian Swetland
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files
|
||||
* (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define UART0_BASE 0x40081000
|
||||
#define UART1_BASE 0x40082000
|
||||
#define UART2_BASE 0x400C1000
|
||||
#define UART3_BASE 0x400C2000
|
||||
|
||||
#define REG_RBR 0x00 // RO Recv Buffer (DLAB==0)
|
||||
#define REG_THR 0x00 // WO Xmit Holding (DLAB==0)
|
||||
#define REG_IER 0x04 // RW Interrupt Enable (DLAB==0)
|
||||
#define REG_DLL 0x00 // RW Divisor Latch LSB (DLAB==1)
|
||||
#define REG_DLM 0x04 // RW Divisor Latch MSB (DLAB==1)
|
||||
#define REG_IIR 0x08 // RO Interrupt ID
|
||||
#define REG_FCR 0x08 // WO Fifo Control
|
||||
#define REG_LCR 0x0C // RW Line Control
|
||||
#define REG_MCR 0x10 // RW Modem Control (UART1 only)
|
||||
#define REG_LSR 0x14 // RO Line Status
|
||||
#define REG_MSR 0x18 // RO Modem Status (UART1 only)
|
||||
#define REG_SCR 0x1C // RW Scratcpad (no hw use)
|
||||
#define REG_ACR 0x20 // RW Auto-baud Control
|
||||
#define REG_ICR 0x24 // RW IrDA Control
|
||||
#define REG_FDR 0x28 // RW Fractional Divider
|
||||
#define REG_OSR 0x2C // RW Oversampling (REG0/2/3 only)
|
||||
|
||||
#define IER_RBRIE (1 << 0) // enable receive data avail
|
||||
#define IER_THREIE (1 << 1) // enable THRE irq
|
||||
#define IER_RXIE (1 << 2) // enable RX Line Status IRQs
|
||||
|
||||
#define IIR_INTSTATUS (1 << 0) // 0=IRQ Pending
|
||||
#define IIR_INTID_MASK (3 << 1)
|
||||
#define IIR_INTID_RLS (3 << 1) // Receive Line Status
|
||||
// Cleared on LSR Read
|
||||
#define IIR_INTID_RDA (2 << 1) // Receive Data Available
|
||||
// Cleared when FIFO < trigger level
|
||||
#define IIR_INTID_CTI (6 << 1) // Character Timeout
|
||||
// data in FIFO, and 3.5-4.5 char times idle
|
||||
#define IIR_INTID_THRE (1 << 1) // Transmit Holding Register Empty
|
||||
#define IIR_INTID_NONE (0 << 1)
|
||||
|
||||
#define FCR_FIFOEN (1 << 0) // enable FIFO
|
||||
#define FCR_RXFIFORES (1 << 1) // RX FIFO reset
|
||||
#define FCR_TXFIFORES (1 << 2) // TX FIFO reset
|
||||
#define FCR_DMAMODE (1 << 3) // select DMA mode
|
||||
#define FCR_RX_TRIG_1 (0 << 6) // RX Trigger at 1 byte
|
||||
#define FCR_RX_TRIG_4 (1 << 6) // RX Trigger at 4 bytes
|
||||
#define FCR_RX_TRIG_8 (2 << 6) // RX Trigger at 8 bytes
|
||||
#define FCR_RX_TRIG_14 (3 << 6) // RX Trigger at 14 bytes
|
||||
|
||||
#define LCR_WLS_5 (0 << 0) // 5bit character
|
||||
#define LCR_WLS_6 (1 << 0) // 6bit character
|
||||
#define LCR_WLS_7 (2 << 0) // 7bit character
|
||||
#define LCR_WLS_8 (3 << 0) // 8bit character
|
||||
#define LCR_SBS_1 (0 << 2) // 1 stop bit
|
||||
#define LCR_SBS_2 (1 << 2) // 2 stop bits
|
||||
#define LCR_PE (1 << 3) // parity enable
|
||||
#define LCR_PS_ODD (0 << 4) // odd parity
|
||||
#define LCR_PS_EVEN (1 << 4) // even parity
|
||||
#define LCR_PS_HIGH (2 << 4) // always-1 parity
|
||||
#define LCR_PS_LOW (3 << 4) // always-0 parity
|
||||
#define LCR_BC (1 << 6) // enable break transmission
|
||||
#define LCR_DLAB (1 << 7) // enable access to divisor latches
|
||||
|
||||
#define LSR_RDR (1 << 0) // receiver data ready
|
||||
#define LSR_OE (1 << 1) // overrun error (fifo was full, character lost)
|
||||
#define LSR_PE (1 << 2) // parity error (top of fifo)
|
||||
#define LSR_FE (1 << 3) // framing error (top of fifo)
|
||||
#define LSR_BI (1 << 4) // break interrupt
|
||||
#define LSR_THRE (1 << 5) // transmit holding register empty
|
||||
#define LSR_TEMT (1 << 6) // transmitter empty
|
||||
#define LSR_RXFE (1 << 7) // error in RX FIFO
|
||||
#define LSR_TXERR (1 << 8) // NACK received in smart card mode
|
||||
|
||||
#define FDR_DIVADDVAL(n) ((n) & 0xF)
|
||||
#define FDR_MULVAL(n) (((n) & 0xF) << 4)
|
||||
|
||||
// baud rate selection:
|
||||
//
|
||||
// PCLK / ( 16 * ( 256 * DLM + DLL ) * ( 1 + ( DivAddVal / MulVal ) )
|
||||
//
|
||||
// 1 <= MulVal <= 15 DivAddVal == 0 -> Disables Frac Divider
|
||||
// 0 <= DivAddVal <= 14
|
||||
// DivAddVal < MulVal
|
||||
|
||||
|
||||
#define OSR_OSFRAC(n) (((n) & 0x3) << 1) // fractional part
|
||||
#define OSR_OSINT(n) (((n) & 0xF) << 4) // integer part - 1
|
||||
|
||||
// oversampling rate = OsInt + 1 + ( 1/8 * OsFrac) (default is 16)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user