Merge pull request #895 from weety/rtt3_9260
[BSP] update at91sam9260 bsp code.
This commit is contained in:
commit
67ffce7af2
|
@ -48,6 +48,8 @@ static int rt_led_app_init(void);
|
|||
|
||||
int main(void)
|
||||
{
|
||||
int timeout = 0;
|
||||
|
||||
/* Filesystem Initialization */
|
||||
#ifdef RT_USING_DFS
|
||||
{
|
||||
|
@ -74,21 +76,27 @@ int main(void)
|
|||
rt_mmcsd_core_init();
|
||||
rt_mmcsd_blk_init();
|
||||
at91_mci_init();
|
||||
rt_thread_delay(RT_TICK_PER_SECOND*2);
|
||||
/* mount sd card fat partition 1 as root directory */
|
||||
timeout = 0;
|
||||
while ((rt_device_find("sd0") == RT_NULL) && (timeout++ < RT_TICK_PER_SECOND*2))
|
||||
{
|
||||
rt_thread_delay(1);
|
||||
}
|
||||
|
||||
if (timeout < RT_TICK_PER_SECOND*2)
|
||||
{
|
||||
/* mount sd card fat partition 1 as root directory */
|
||||
if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
|
||||
{
|
||||
rt_kprintf("File System initialized!\n");
|
||||
}
|
||||
else
|
||||
rt_kprintf("File System initialzation failed!\n");
|
||||
#endif
|
||||
rt_kprintf("File System initialzation failed!%d\n", rt_get_errno());
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("No SD card found.\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_I2C
|
||||
{
|
||||
rt_i2c_core_init();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -150,18 +150,108 @@ static void at91sam926x_pit_init(void)
|
|||
writel(0xffff, AT91SAM9260_BASE_TC0 + AT91_TC_CV);
|
||||
}
|
||||
|
||||
#define RXRDY 0x01
|
||||
#define TXRDY (1 << 1)
|
||||
#define BPS 115200 /* serial baudrate */
|
||||
|
||||
typedef struct uartport
|
||||
{
|
||||
volatile rt_uint32_t CR;
|
||||
volatile rt_uint32_t MR;
|
||||
volatile rt_uint32_t IER;
|
||||
volatile rt_uint32_t IDR;
|
||||
volatile rt_uint32_t IMR;
|
||||
volatile rt_uint32_t CSR;
|
||||
volatile rt_uint32_t RHR;
|
||||
volatile rt_uint32_t THR;
|
||||
volatile rt_uint32_t BRGR;
|
||||
volatile rt_uint32_t RTOR;
|
||||
volatile rt_uint32_t TTGR;
|
||||
volatile rt_uint32_t reserved0[5];
|
||||
volatile rt_uint32_t FIDI;
|
||||
volatile rt_uint32_t NER;
|
||||
volatile rt_uint32_t reserved1;
|
||||
volatile rt_uint32_t IFR;
|
||||
volatile rt_uint32_t reserved2[44];
|
||||
volatile rt_uint32_t RPR;
|
||||
volatile rt_uint32_t RCR;
|
||||
volatile rt_uint32_t TPR;
|
||||
volatile rt_uint32_t TCR;
|
||||
volatile rt_uint32_t RNPR;
|
||||
volatile rt_uint32_t RNCR;
|
||||
volatile rt_uint32_t TNPR;
|
||||
volatile rt_uint32_t TNCR;
|
||||
volatile rt_uint32_t PTCR;
|
||||
volatile rt_uint32_t PTSR;
|
||||
}uartport;
|
||||
|
||||
#define CIDR FIDI
|
||||
#define EXID NER
|
||||
#define FNR reserved1
|
||||
|
||||
#define DBGU ((struct uartport *)AT91SAM9260_BASE_DBGU)
|
||||
|
||||
static void at91_usart_putc(char c)
|
||||
{
|
||||
while (!(DBGU->CSR & TXRDY));
|
||||
DBGU->THR = c;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to display a string on console, normally, it's
|
||||
* invoked by rt_kprintf
|
||||
*
|
||||
* @param str the displayed string
|
||||
*/
|
||||
void rt_hw_console_output(const char* str)
|
||||
{
|
||||
while (*str)
|
||||
{
|
||||
if (*str=='\n')
|
||||
{
|
||||
at91_usart_putc('\r');
|
||||
}
|
||||
|
||||
at91_usart_putc(*str++);
|
||||
}
|
||||
}
|
||||
|
||||
static void rt_hw_console_init(void)
|
||||
{
|
||||
int div;
|
||||
int mode = 0;
|
||||
|
||||
DBGU->CR = AT91_US_RSTTX | AT91_US_RSTRX |
|
||||
AT91_US_RXDIS | AT91_US_TXDIS;
|
||||
mode |= AT91_US_USMODE_NORMAL | AT91_US_USCLKS_MCK |
|
||||
AT91_US_CHMODE_NORMAL;
|
||||
mode |= AT91_US_CHRL_8;
|
||||
mode |= AT91_US_NBSTOP_1;
|
||||
mode |= AT91_US_PAR_NONE;
|
||||
DBGU->MR = mode;
|
||||
div = (clk_get_rate(clk_get("mck")) / 16 + BPS/2) / BPS;
|
||||
DBGU->BRGR = div;
|
||||
DBGU->CR = AT91_US_RXEN | AT91_US_TXEN;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function will init at91sam9260 board
|
||||
*/
|
||||
void rt_hw_board_init()
|
||||
{
|
||||
/* initialize mmu */
|
||||
rt_hw_mmu_init(at91_mem_desc, sizeof(at91_mem_desc)/sizeof(at91_mem_desc[0]));
|
||||
/* initialize hardware interrupt */
|
||||
rt_hw_interrupt_init();
|
||||
/* initialize the system clock */
|
||||
rt_hw_clock_init();
|
||||
|
||||
/* initialize console */
|
||||
rt_hw_console_init();
|
||||
|
||||
/* initialize mmu */
|
||||
rt_hw_mmu_init(at91_mem_desc, sizeof(at91_mem_desc)/sizeof(at91_mem_desc[0]));
|
||||
|
||||
/* initialize hardware interrupt */
|
||||
rt_hw_interrupt_init();
|
||||
|
||||
/* initialize early device */
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
rt_components_board_init();
|
||||
|
|
Loading…
Reference in New Issue