mirror of https://github.com/ARMmbed/mbed-os.git
commit
2a4bbdfe4f
|
@ -39,7 +39,7 @@ typedef enum {
|
|||
/* Include configuration for specific target */
|
||||
#if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC4088)
|
||||
#include "USBEndpoints_LPC17_LPC23.h"
|
||||
#elif defined(TARGET_LPC11UXX) || defined(TARGET_LPC1347) || defined (TARGET_LPC11U6X)
|
||||
#elif defined(TARGET_LPC11UXX) || defined(TARGET_LPC1347) || defined (TARGET_LPC11U6X) || defined (TARGET_LPC1549)
|
||||
#include "USBEndpoints_LPC11U.h"
|
||||
#elif defined(TARGET_KL25Z) | defined(TARGET_KL46Z) | defined(TARGET_K20D5M) | defined(TARGET_K64F)
|
||||
#include "USBEndpoints_KL25Z.h"
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#if defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC1347) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPC11U68)
|
||||
#if defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC1347) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPC11U68) || defined(TARGET_LPC1549)
|
||||
|
||||
#if defined(TARGET_LPC1347)
|
||||
#if defined(TARGET_LPC1347) || defined(TARGET_LPC1549)
|
||||
#define USB_IRQ USB_IRQ_IRQn
|
||||
#elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPC11U68)
|
||||
#define USB_IRQ USB_IRQn
|
||||
|
@ -27,6 +27,9 @@
|
|||
#include "USBHAL.h"
|
||||
|
||||
USBHAL * USBHAL::instance;
|
||||
#if defined(TARGET_LPC1549)
|
||||
static uint8_t usbmem[2048] __attribute__((aligned(2048)));
|
||||
#endif
|
||||
|
||||
// Valid physical endpoint numbers are 0 to (NUMBER_OF_PHYSICAL_ENDPOINTS-1)
|
||||
#define LAST_PHYSICAL_ENDPOINT (NUMBER_OF_PHYSICAL_ENDPOINTS-1)
|
||||
|
@ -42,12 +45,21 @@ USBHAL * USBHAL::instance;
|
|||
#define OUT_EP(endpoint) ((endpoint) & 1U ? false : true)
|
||||
|
||||
// USB RAM
|
||||
#if defined(TARGET_LPC1549)
|
||||
#define USB_RAM_START ((uint32_t)usbmem)
|
||||
#define USB_RAM_SIZE sizeof(usbmem)
|
||||
#else
|
||||
#define USB_RAM_START (0x20004000)
|
||||
#define USB_RAM_SIZE (0x00000800)
|
||||
#endif
|
||||
|
||||
// SYSAHBCLKCTRL
|
||||
#if defined(TARGET_LPC1549)
|
||||
#define CLK_USB (1UL<<23)
|
||||
#else
|
||||
#define CLK_USB (1UL<<14)
|
||||
#define CLK_USBRAM (1UL<<27)
|
||||
#endif
|
||||
|
||||
// USB Information register
|
||||
#define FRAME_NR(a) ((a) & 0x7ff) // Frame number
|
||||
|
@ -145,6 +157,37 @@ USBHAL::USBHAL(void) {
|
|||
epCallback[6] = &USBHAL::EP4_OUT_callback;
|
||||
epCallback[7] = &USBHAL::EP4_IN_callback;
|
||||
|
||||
#if defined(TARGET_LPC1549)
|
||||
/* Set USB PLL input to system oscillator */
|
||||
LPC_SYSCON->USBPLLCLKSEL = 0x01;
|
||||
|
||||
/* Setup USB PLL (FCLKIN = 12MHz) * 4 = 48MHz
|
||||
MSEL = 3 (this is pre-decremented), PSEL = 1 (for P = 2)
|
||||
FCLKOUT = FCLKIN * (MSEL + 1) = 12MHz * 4 = 48MHz
|
||||
FCCO = FCLKOUT * 2 * P = 48MHz * 2 * 2 = 192MHz (within FCCO range) */
|
||||
LPC_SYSCON->USBPLLCTRL = (0x3 | (1UL << 6));
|
||||
|
||||
/* Powerup USB PLL */
|
||||
LPC_SYSCON->PDRUNCFG &= ~(CLK_USB);
|
||||
|
||||
/* Wait for PLL to lock */
|
||||
while(!(LPC_SYSCON->USBPLLSTAT & 0x01));
|
||||
|
||||
/* enable USB main clock */
|
||||
LPC_SYSCON->USBCLKSEL = 0x02;
|
||||
LPC_SYSCON->USBCLKDIV = 1;
|
||||
|
||||
/* Enable AHB clock to the USB block. */
|
||||
LPC_SYSCON->SYSAHBCLKCTRL1 |= CLK_USB;
|
||||
|
||||
/* power UP USB Phy */
|
||||
LPC_SYSCON->PDRUNCFG &= ~(1UL << 9);
|
||||
|
||||
/* Reset USB block */
|
||||
LPC_SYSCON->PRESETCTRL1 |= (CLK_USB);
|
||||
LPC_SYSCON->PRESETCTRL1 &= ~(CLK_USB);
|
||||
|
||||
#else
|
||||
#if defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501)
|
||||
// USB_VBUS input with pull-down
|
||||
LPC_IOCON->PIO0_3 = 0x00000009;
|
||||
|
@ -158,7 +201,7 @@ USBHAL::USBHAL(void) {
|
|||
|
||||
// Ensure device disconnected (DCON not set)
|
||||
LPC_USB->DEVCMDSTAT = 0;
|
||||
|
||||
#endif
|
||||
// to ensure that the USB host sees the device as
|
||||
// disconnected if the target CPU is reset.
|
||||
wait(0.3);
|
||||
|
|
|
@ -474,7 +474,7 @@ static void power_up_config(uint32_t val)
|
|||
*/
|
||||
void SystemInit (void) {
|
||||
#if (CLOCK_SETUP)
|
||||
volatile uint32_t i, tmp;
|
||||
volatile uint32_t i;
|
||||
#endif
|
||||
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<16);
|
||||
LPC_SYSCON->SYSPLLCTRL = SYSPLLCTRL_Val;
|
||||
|
|
|
@ -57,7 +57,7 @@ static int get_available_sct(void) {
|
|||
void pwmout_init(pwmout_t* obj, PinName pin) {
|
||||
// determine the SPI to use
|
||||
PWMName pwm_mapped = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
|
||||
if (pwm_mapped == (uint32_t)NC) {
|
||||
if (pwm_mapped == (PWMName)NC) {
|
||||
error("PwmOut pin mapping failed");
|
||||
}
|
||||
int sct_n = get_available_sct();
|
||||
|
@ -146,7 +146,6 @@ void pwmout_write(pwmout_t* obj, float value) {
|
|||
} else if (value > 1.0f) {
|
||||
value = 1.0;
|
||||
}
|
||||
uint32_t t_off = obj->pwm->MATCHREL0 - (uint32_t)((float)(obj->pwm->MATCHREL0) * value);
|
||||
uint32_t t_on = (uint32_t)((float)(obj->pwm->MATCHREL0) * value);
|
||||
obj->pwm->MATCHREL1 = t_on;
|
||||
}
|
||||
|
|
|
@ -128,7 +128,6 @@ void pwmout_write(pwmout_t* obj, float value) {
|
|||
} else if (value > 1.0f) {
|
||||
value = 1.0;
|
||||
}
|
||||
uint32_t t_off = pwm->MATCHREL0 - (uint32_t)((float)(pwm->MATCHREL0) * value);
|
||||
uint32_t t_on = (uint32_t)((float)(pwm->MATCHREL0) * value);
|
||||
pwm->MATCHREL1 = t_on;
|
||||
}
|
||||
|
|
|
@ -89,10 +89,10 @@ static void switch_pin(const SWM_Map *swm, PinName pn)
|
|||
if (pn != NC)
|
||||
{
|
||||
// check if we have any function mapped to this pin already and remove it
|
||||
for (int n = 0; n < sizeof(LPC_SWM->PINASSIGN)/sizeof(*LPC_SWM->PINASSIGN); n ++) {
|
||||
for (uint32_t n = 0; n < sizeof(LPC_SWM->PINASSIGN)/sizeof(*LPC_SWM->PINASSIGN); n ++) {
|
||||
regVal = LPC_SWM->PINASSIGN[n];
|
||||
for (int j = 0; j <= 24; j += 8) {
|
||||
if (((regVal >> j) & 0xFF) == pn)
|
||||
for (uint32_t j = 0; j <= 24; j += 8) {
|
||||
if (((regVal >> j) & 0xFF) == (uint32_t)pn)
|
||||
regVal |= (0xFF << j);
|
||||
}
|
||||
LPC_SWM->PINASSIGN[n] = regVal;
|
||||
|
@ -105,7 +105,7 @@ static void switch_pin(const SWM_Map *swm, PinName pn)
|
|||
|
||||
void serial_init(serial_t *obj, PinName tx, PinName rx) {
|
||||
int is_stdio_uart = 0;
|
||||
|
||||
|
||||
int uart_n = get_available_uart();
|
||||
if (uart_n == -1) {
|
||||
error("No available UART");
|
||||
|
@ -127,9 +127,8 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
|
|||
LPC_SYSCON->SYSAHBCLKCTRL1 |= (1 << (17 + uart_n));
|
||||
|
||||
/* Peripheral reset control to UART, a "1" bring it out of reset. */
|
||||
// LPC_SYSCON->PRESETCTRL1 &= ~(0x1 << (17 + uart_n));
|
||||
LPC_SYSCON->PRESETCTRL1 |= (0x1 << (17 + uart_n));
|
||||
LPC_SYSCON->PRESETCTRL1 ^= (0x1 << (17 + uart_n));
|
||||
LPC_SYSCON->PRESETCTRL1 &= ~(0x1 << (17 + uart_n));
|
||||
|
||||
UARTSysClk = SystemCoreClock / LPC_SYSCON->UARTCLKDIV;
|
||||
|
||||
|
@ -143,9 +142,6 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
|
|||
/* enable uart interrupts */
|
||||
NVIC_EnableIRQ((IRQn_Type)(UART0_IRQn + uart_n));
|
||||
|
||||
/* Enable UART interrupt */
|
||||
// obj->uart->INTENSET = RXRDY | TXRDY | DELTA_RXBRK;
|
||||
|
||||
/* Enable UART */
|
||||
obj->uart->CFG |= UART_EN;
|
||||
|
||||
|
|
Loading…
Reference in New Issue