2020-07-01 23:44:57 +08:00
|
|
|
/*
|
2021-03-21 22:23:24 +08:00
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
2020-07-01 23:44:57 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2020-06-27 AHTYDHD the first version
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <rtthread.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "inc/hw_memmap.h"
|
|
|
|
#include "driverlib/pin_map.h"
|
|
|
|
#include "driverlib/sysctl.h"
|
|
|
|
#include "driverlib/gpio.h"
|
2020-06-24 19:54:42 +08:00
|
|
|
#include "tm4c123_config.h"
|
|
|
|
|
2020-07-01 23:44:57 +08:00
|
|
|
#ifdef RT_USING_SERIAL
|
2020-07-02 13:01:57 +08:00
|
|
|
#include "driverlib/uart.h"
|
2020-07-01 23:44:57 +08:00
|
|
|
#endif /* RT_USING_SERIAL */
|
|
|
|
#ifdef RT_USING_ADC
|
2020-07-02 13:01:57 +08:00
|
|
|
#include "driverlib/adc.h"
|
2020-07-01 23:44:57 +08:00
|
|
|
#endif /* RT_USING_ADC */
|
|
|
|
#ifdef RT_USING_PWM
|
2020-07-02 13:01:57 +08:00
|
|
|
#include "driverlib/pwm.h"
|
2020-07-01 23:44:57 +08:00
|
|
|
#endif /* RT_USING_PWM */
|
|
|
|
#ifdef RT_USING_SPI
|
2020-07-02 13:01:57 +08:00
|
|
|
#include "driverlib/ssi.h"
|
2020-07-01 23:44:57 +08:00
|
|
|
#endif /* RT_USING_SPI */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef RT_USING_SERIAL
|
2020-06-24 19:54:42 +08:00
|
|
|
void uart_hw_config(void)
|
|
|
|
{
|
2020-07-01 23:44:57 +08:00
|
|
|
/* UART0 */
|
|
|
|
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
|
2020-06-24 19:54:42 +08:00
|
|
|
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
|
2020-07-01 23:44:57 +08:00
|
|
|
GPIOPinConfigure(GPIO_PA0_U0RX);
|
2020-06-24 19:54:42 +08:00
|
|
|
GPIOPinConfigure(GPIO_PA1_U0TX);
|
|
|
|
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
|
2020-07-01 23:44:57 +08:00
|
|
|
/* UART1 */
|
|
|
|
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
|
2020-06-24 19:54:42 +08:00
|
|
|
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
|
2020-07-01 23:44:57 +08:00
|
|
|
GPIOPinConfigure(GPIO_PC4_U1RX);
|
2020-06-24 19:54:42 +08:00
|
|
|
GPIOPinConfigure(GPIO_PC5_U1TX);
|
|
|
|
GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5);
|
|
|
|
}
|
2020-07-01 23:44:57 +08:00
|
|
|
#endif /* RT_USING_SERIAL */
|
2020-06-24 19:54:42 +08:00
|
|
|
|
2020-07-01 23:44:57 +08:00
|
|
|
#ifdef RT_USING_ADC
|
|
|
|
void adc_hw_config(void)
|
|
|
|
{
|
|
|
|
/* ADC0 */
|
|
|
|
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
|
|
|
|
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
|
|
|
|
GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
|
|
|
|
}
|
|
|
|
#endif /* RT_USING_ADC */
|
2020-06-24 19:54:42 +08:00
|
|
|
|
2020-07-01 23:44:57 +08:00
|
|
|
#ifdef RT_USING_PWM
|
2020-06-24 19:54:42 +08:00
|
|
|
void pwm_hw_config(void)
|
|
|
|
{
|
2020-07-01 23:44:57 +08:00
|
|
|
/* PWM7 (PWM1 module,M1PWM6 and M1PWM7) */
|
|
|
|
SysCtlPWMClockSet(SYSCTL_PWMDIV_2);
|
|
|
|
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1);
|
2020-06-24 19:54:42 +08:00
|
|
|
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
|
|
|
|
GPIOPinConfigure(GPIO_PF2_M1PWM6);
|
|
|
|
GPIOPinConfigure(GPIO_PF3_M1PWM7);
|
2020-07-01 23:44:57 +08:00
|
|
|
GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3);
|
2020-06-24 19:54:42 +08:00
|
|
|
}
|
2020-07-01 23:44:57 +08:00
|
|
|
#endif /* RT_USING_PWM */
|
2020-06-24 19:54:42 +08:00
|
|
|
|
2020-07-01 23:44:57 +08:00
|
|
|
#ifdef RT_USING_SPI
|
2020-06-24 19:54:42 +08:00
|
|
|
void spi_hw_config(void)
|
|
|
|
{
|
2020-07-01 23:44:57 +08:00
|
|
|
/* SPI0 */
|
2020-06-24 19:54:42 +08:00
|
|
|
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
|
|
|
|
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
|
|
|
|
GPIOPinConfigure(GPIO_PA2_SSI0CLK);
|
|
|
|
GPIOPinConfigure(GPIO_PA4_SSI0RX);
|
|
|
|
GPIOPinConfigure(GPIO_PA5_SSI0TX);
|
|
|
|
GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_2);
|
|
|
|
}
|
2020-07-01 23:44:57 +08:00
|
|
|
#endif /* RT_USING_SPI */
|
2020-06-24 19:54:42 +08:00
|
|
|
|
2021-03-21 22:23:24 +08:00
|
|
|
/************************** end of file ******************/
|