Changeset 7b35a36 in rtems


Ignore:
Timestamp:
Mar 11, 2015, 7:57:23 PM (5 years ago)
Author:
Martin Galvan <martin.galvan@…>
Branches:
4.11, master
Children:
9f34aa5
Parents:
6a941e3
git-author:
Martin Galvan <martin.galvan@…> (03/11/15 19:57:23)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/20/15 08:16:07)
Message:

Add CAN, PWM, ADC and UART1/2/3 support to the LPC176x BSP.

This patch adds support for the following devices to the LPC176x BSP:

  • CAN
  • PWM
  • ADC

It also adds the probe routines for UART1/2/3 to the console_device_table in console-config.c, and enables UART1 in configure.ac.

Location:
c/src/lib/libbsp
Files:
10 added
10 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/lpc176x/Makefile.am

    r6a941e3 r7b35a36  
    4343include_bsp_HEADERS += include/gpio-defs.h
    4444include_bsp_HEADERS += include/gpio.h
     45include_bsp_HEADERS += include/can.h
     46include_bsp_HEADERS += include/can-defs.h
     47include_bsp_HEADERS += include/pwmout.h
     48include_bsp_HEADERS += include/pwmout-defs.h
     49include_bsp_HEADERS += include/adc.h
     50include_bsp_HEADERS += include/adc-defs.h
    4551include_bsp_HEADERS += include/timer-defs.h
    4652include_bsp_HEADERS += include/timer.h
     
    5157include_bsp_HEADERS += include/lpc-clock-config.h
    5258include_bsp_HEADERS += include/system-clocks.h
     59include_bsp_HEADERS += include/mbed-pinmap.h
    5360
    5461include_HEADERS += ../../shared/include/tm27.h
     
    127134libbsp_a_SOURCES += gpio/gpio.c
    128135
     136# CAN
     137libbsp_a_SOURCES += can/can.c
     138
     139# PWMOUT
     140libbsp_a_SOURCES += pwmout/pwmout.c
     141
     142# ADC
     143libbsp_a_SOURCES += adc/adc.c
     144
    129145# Timer
    130146libbsp_a_SOURCES += timer/timer.c
  • c/src/lib/libbsp/arm/lpc176x/configure.ac

    r6a941e3 r7b35a36  
    5050RTEMS_BSPOPTS_HELP([LPC176X_UART_BAUD],[baud for UARTs])
    5151
     52RTEMS_BSPOPTS_SET([LPC176X_CONFIG_UART_1],[*],[1])
     53RTEMS_BSPOPTS_HELP([LPC176X_CONFIG_UART_1],[Use Uart 1])
     54
    5255RTEMS_BSPOPTS_SET([LPC176X_CONFIG_CONSOLE],[*],[0])
    5356RTEMS_BSPOPTS_HELP([LPC176X_CONFIG_CONSOLE],[configuration
  • c/src/lib/libbsp/arm/lpc176x/console/console-config.c

    r6a941e3 r7b35a36  
    6161
    6262  reg[ i ] = val;
     63}
     64
     65static bool lpc176x_uart1_probe(rtems_termios_device_context *ctx)
     66{
     67  (void)ctx;
     68
     69  lpc176x_module_enable( LPC176X_MODULE_UART_1, LPC176X_MODULE_PCLK_DEFAULT );
     70
     71  lpc176x_pin_select( LPC176X_PIN_UART_1_TXD, LPC176X_PIN_FUNCTION_01 );
     72  lpc176x_pin_select( LPC176X_PIN_UART_1_RXD, LPC176X_PIN_FUNCTION_01 );
     73
     74  return true;
     75}
     76
     77static bool lpc176x_uart2_probe(rtems_termios_device_context *ctx)
     78{
     79  (void)ctx;
     80
     81  lpc176x_module_enable( LPC176X_MODULE_UART_2, LPC176X_MODULE_PCLK_DEFAULT );
     82
     83  lpc176x_pin_select( LPC176X_PIN_UART_2_TXD, LPC176X_PIN_FUNCTION_01 );
     84  lpc176x_pin_select( LPC176X_PIN_UART_2_RXD, LPC176X_PIN_FUNCTION_01 );
     85
     86  return true;
     87}
     88
     89static bool lpc176x_uart3_probe(rtems_termios_device_context *ctx)
     90{
     91  (void)ctx;
     92
     93  lpc176x_module_enable( LPC176X_MODULE_UART_3, LPC176X_MODULE_PCLK_DEFAULT );
     94
     95  lpc176x_pin_select( LPC176X_PIN_UART_3_TXD, LPC176X_PIN_FUNCTION_10 );
     96  lpc176x_pin_select( LPC176X_PIN_UART_3_RXD, LPC176X_PIN_FUNCTION_10 );
     97
     98  return true;
    6399}
    64100
     
    127163    {
    128164      .device_file = "/dev/ttyS1",
    129       .probe = ns16550_probe,
     165      .probe = lpc176x_uart1_probe,
    130166      .handler = &ns16550_handler_interrupt,
    131167      .context = &lpc176x_uart_context_1.base
     
    135171    {
    136172      .device_file = "/dev/ttyS2",
    137       .probe = ns16550_probe,
     173      .probe = lpc176x_uart2_probe,
    138174      .handler = &ns16550_handler_interrupt,
    139175      .context = &lpc176x_uart_context_2.base
     
    143179    {
    144180      .device_file = "/dev/ttyS3",
    145       .probe = ns16550_probe,
     181      .probe = lpc176x_uart3_probe,
    146182      .handler = &ns16550_handler_interrupt,
    147183      .context = &lpc176x_uart_context_3.base
  • c/src/lib/libbsp/arm/lpc176x/include/common-types.h

    r6a941e3 r7b35a36  
    4747  LPC176X_MODULE_CAN_0,
    4848  LPC176X_MODULE_CAN_1,
     49  LPC176X_MODULE_ACCF,
    4950  LPC176X_MODULE_DAC,
    5051  LPC176X_MODULE_GPDMA,
  • c/src/lib/libbsp/arm/lpc176x/include/io-defs.h

    r6a941e3 r7b35a36  
    4444#define LPC176X_PIN_UART_0_TXD 2U
    4545#define LPC176X_PIN_UART_0_RXD 3U
     46#define LPC176X_PIN_UART_1_TXD 15U
     47#define LPC176X_PIN_UART_1_RXD 16U
     48#define LPC176X_PIN_UART_2_TXD 10U
     49#define LPC176X_PIN_UART_2_RXD 11U
     50#define LPC176X_PIN_UART_3_TXD 0U
     51#define LPC176X_PIN_UART_3_RXD 1U
    4652
    4753#define LPC176X_MODULE_BITS_COUNT 32U
     
    6874}
    6975lpc176x_pin_function;
     76
     77/**
     78 * @brief Defines the pin modes.
     79 *
     80 */
     81typedef enum {
     82  LPC176X_PIN_MODE_PULLUP,
     83  LPC176X_PIN_MODE_REPEATER,
     84  LPC176X_PIN_MODE_NONE,
     85  LPC176X_PIN_MODE_PULLDOWN,
     86  LPC176X_PIN_MODE_COUNT
     87}
     88lpc176x_pin_mode;
    7089
    7190/**
  • c/src/lib/libbsp/arm/lpc176x/include/io.h

    r6a941e3 r7b35a36  
    3232
    3333/**
    34  * @brief Set pin to the selected function.
     34 * @brief Sets pin to the selected function.
    3535 *
    3636 * @param pin The pin to set.
     
    4040  uint32_t             pin,
    4141  lpc176x_pin_function function
     42);
     43
     44/**
     45 * @brief Sets pin to the selected mode.
     46 *
     47 * @param pin The pin to set.
     48 * @param mode Defines the mode to set.
     49 */
     50void lpc176x_pin_set_mode(
     51  const uint32_t             pin,
     52  const lpc176x_pin_mode mode
    4253);
    4354
  • c/src/lib/libbsp/arm/lpc176x/include/lpc176x.h

    r6a941e3 r7b35a36  
    177177#define LPC176X_SCB_CLKOUTCFG_CLKOUTSEL( val ) BSP_FLD32( val, 3, 0 )
    178178#define LPC176X_SCB_CLKOUTCFG_CLKOUTSEL_GET( reg ) BSP_FLD32GET( reg, 3, 0 )
    179 #define LPC176X_SCB_CLKOUTCFG_CLKOUTSEL_SET( reg, val ) BSP_FLD32SET( reg, val, \
    180   3, 0 )
     179#define LPC176X_SCB_CLKOUTCFG_CLKOUTSEL_SET( reg, val ) BSP_FLD32SET( reg, \
     180  val, 3, 0 )
    181181#define LPC176X_SCB_CLKOUTCFG_CLKOUTDIV( val ) BSP_FLD32( val, 7, 4 )
    182182#define LPC176X_SCB_CLKOUTCFG_CLKOUTDIV_GET( reg ) BSP_FLD32GET( reg, 7, 4 )
    183 #define LPC176X_SCB_CLKOUTCFG_CLKOUTDIV_SET( reg, val ) BSP_FLD32SET( reg, val, \
    184   7, 4 )
     183#define LPC176X_SCB_CLKOUTCFG_CLKOUTDIV_SET( reg, val ) BSP_FLD32SET( reg, \
     184  val, 7, 4 )
    185185#define LPC176X_SCB_CLKOUTCFG_CLKOUT_EN BSP_BIT32( 8 )
    186186#define LPC176X_SCB_CLKOUTCFG_CLKOUT_ACT BSP_BIT32( 9 )
  • c/src/lib/libbsp/arm/lpc176x/misc/io.c

    r6a941e3 r7b35a36  
    3434  LPC176X_MODULE_ENTRY( LPC176X_MODULE_CAN_0, 1, 1, 13 ),
    3535  LPC176X_MODULE_ENTRY( LPC176X_MODULE_CAN_1, 1, 1, 14 ),
     36  LPC176X_MODULE_ENTRY(LPC176X_MODULE_ACCF, 0, 1, 15),
    3637  LPC176X_MODULE_ENTRY( LPC176X_MODULE_DAC, 0, 1, 11 ),
    3738  LPC176X_MODULE_ENTRY( LPC176X_MODULE_GPDMA, 1, 1, 29 ),
     
    7172}
    7273
     74void lpc176x_pin_set_mode(
     75  const uint32_t             pin,
     76  const lpc176x_pin_mode mode
     77)
     78{
     79  assert( pin <= LPC176X_IO_INDEX_MAX
     80    && mode < LPC176X_PIN_MODE_COUNT );
     81  const uint32_t           pin_selected = LPC176X_PIN_SELECT( pin );
     82  volatile uint32_t *const pinmode = &LPC176X_PINMODE[ pin_selected ];
     83  const uint32_t           shift = LPC176X_PIN_SELECT_SHIFT( pin );
     84  *pinmode = SET_FIELD( *pinmode, mode,
     85    LPC176X_PIN_SELECT_MASK << shift, shift );
     86}
     87
    7388/**
    7489 * @brief Checks if the module has power.
  • c/src/lib/libbsp/arm/lpc176x/preinstall.am

    r6a941e3 r7b35a36  
    118118PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/gpio.h
    119119
     120$(PROJECT_INCLUDE)/bsp/can.h: include/can.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     121        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/can.h
     122PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/can.h
     123
     124$(PROJECT_INCLUDE)/bsp/can-defs.h: include/can-defs.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     125        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/can-defs.h
     126PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/can-defs.h
     127
     128$(PROJECT_INCLUDE)/bsp/pwmout.h: include/pwmout.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     129        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/pwmout.h
     130PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/pwmout.h
     131
     132$(PROJECT_INCLUDE)/bsp/pwmout-defs.h: include/pwmout-defs.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     133        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/pwmout-defs.h
     134PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/pwmout-defs.h
     135
     136$(PROJECT_INCLUDE)/bsp/adc.h: include/adc.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     137        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/adc.h
     138PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/adc.h
     139
     140$(PROJECT_INCLUDE)/bsp/adc-defs.h: include/adc-defs.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     141        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/adc-defs.h
     142PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/adc-defs.h
     143
    120144$(PROJECT_INCLUDE)/bsp/timer-defs.h: include/timer-defs.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
    121145        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/timer-defs.h
     
    150174PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/system-clocks.h
    151175
     176$(PROJECT_INCLUDE)/bsp/mbed-pinmap.h: include/mbed-pinmap.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     177        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/mbed-pinmap.h
     178PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/mbed-pinmap.h
     179
    152180$(PROJECT_INCLUDE)/tm27.h: ../../shared/include/tm27.h $(PROJECT_INCLUDE)/$(dirstamp)
    153181        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/tm27.h
  • c/src/lib/libbsp/shared/include/uart-output-char.h

    r6a941e3 r7b35a36  
    5252    CONSOLE_IER = 0x00; \
    5353    CONSOLE_LCR = 0x80; \
    54     CONSOLE_DLL = (dll); \
    55     CONSOLE_DLM = 0x00; \
     54    CONSOLE_DLL = (dll & 0xFF); \
     55    CONSOLE_DLM = (dll >> 8); \
    5656    CONSOLE_LCR = 0x03; \
    5757    CONSOLE_FCR = 0x07; \
Note: See TracChangeset for help on using the changeset viewer.