Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Anyone have AT91SAM7X256 GCC Serial source ?

Posted by Nobody/Anonymous on September 4, 2006
Please.. Send me serial source file and AT91SAM7X256-EK GCC port files.



my e-mail : xpeedholic@hotmail.com


RE: Anyone have AT91SAM7X256 GCC Serial source ?

Posted by Nobody/Anonymous on September 4, 2006
#include "Board.h"
#include "commd.h"

//------------------------------------------------------------------ zamiast comm.c -------------------------------------------- dodalem commd_....
//static xSemaphoreHandle debug_sem;

static char comm_initialized[3] = {0, 0, 0};

void commd_init(int port, int baud) {
switch (port) {
case USART0:
*AT91C_PIOA_PDR = AT91C_PA5_RXD0 | /* Enable RxD0 Pin */
AT91C_PA6_TXD0; /* Enable TxD0 Pin */

AT91C_BASE_US0->US_CR = AT91C_US_RSTRX | /* Reset Receiver */
AT91C_US_RSTTX | /* Reset Transmitter */
AT91C_US_RXDIS | /* Receiver Disable */
AT91C_US_TXDIS; /* Transmitter Disable */

AT91C_BASE_US0->US_MR = AT91C_US_USMODE_NORMAL | /* Normal Mode */
AT91C_US_CLKS_CLOCK | /* Clock = MCK */
AT91C_US_CHRL_8_BITS | /* 8-bit Data */
AT91C_US_PAR_NONE | /* No Parity */
AT91C_US_NBSTOP_1_BIT; /* 1 Stop Bit */

AT91C_BASE_US0->US_BRGR = MCK / 16 / baud; /* Baud Rate Divisor */

AT91C_BASE_US0->US_CR = AT91C_US_RXEN | /* Receiver Enable */
AT91C_US_TXEN; /* Transmitter Enable */
comm_initialized[port] = 1;
break;

case USART1:
*AT91C_PIOA_PDR = AT91C_PA21_RXD1 | /* Enable RxD1 Pin */
AT91C_PA22_TXD1; /* Enable TxD1 Pin */

AT91C_BASE_US1->US_CR = AT91C_US_RSTRX | /* Reset Receiver */
AT91C_US_RSTTX | /* Reset Transmitter */
AT91C_US_RXDIS | /* Receiver Disable */
AT91C_US_TXDIS; /* Transmitter Disable */

AT91C_BASE_US1->US_MR = AT91C_US_USMODE_NORMAL | /* Normal Mode */
AT91C_US_CLKS_CLOCK | /* Clock = MCK */
AT91C_US_CHRL_8_BITS | /* 8-bit Data */
AT91C_US_PAR_NONE | /* No Parity */
AT91C_US_NBSTOP_1_BIT; /* 1 Stop Bit */

AT91C_BASE_US1->US_BRGR = MCK / 16 / baud; /* Baud Rate Divisor */

AT91C_BASE_US1->US_CR = AT91C_US_RXEN | /* Receiver Enable */
AT91C_US_TXEN; /* Transmitter Enable */
comm_initialized[port] = 1;
break;

case DUSART:
*AT91C_PIOA_PDR = AT91C_PA9_DRXD | /* Enable RxD1 Pin */
AT91C_PA10_DTXD; /* Enable TxD1 Pin */

AT91C_BASE_DBGU->DBGU_CR = AT91C_US_RSTRX | /* Reset Receiver */
AT91C_US_RSTTX | /* Reset Transmitter */
AT91C_US_RXDIS | /* Receiver Disable */
AT91C_US_TXDIS; /* Transmitter Disable */

AT91C_BASE_DBGU->DBGU_MR = AT91C_US_USMODE_NORMAL | /* Normal Mode */
AT91C_US_CLKS_CLOCK | /* Clock = MCK */
AT91C_US_CHRL_8_BITS | /* 8-bit Data */
AT91C_US_PAR_NONE | /* No Parity */
AT91C_US_NBSTOP_1_BIT; /* 1 Stop Bit */

AT91C_BASE_DBGU->DBGU_BRGR = MCK / 16 / baud; /* Baud Rate Divisor */

AT91C_BASE_DBGU->DBGU_CR = AT91C_US_RXEN | /* Receiver Enable */
AT91C_US_TXEN; /* Transmitter Enable */
comm_initialized[port] = 1;
break;

default:
break;
}
}

int commd_putc(int port,int ch) {
if (!comm_initialized[port]) return -3;
switch (port) {
case USART0:
while (!(AT91C_BASE_US0->US_CSR & AT91C_US_TXRDY)); /* Wait for Empty Tx Buffer */
return (AT91C_BASE_US0->US_THR = ch); /* Transmit Character */

case USART1:
while (!(AT91C_BASE_US1->US_CSR & AT91C_US_TXRDY)); /* Wait for Empty Tx Buffer */
return (AT91C_BASE_US1->US_THR = ch); /* Transmit Character */

case DUSART:
while (!(AT91C_BASE_DBGU->DBGU_CSR & AT91C_US_TXRDY)); /* Wait for Empty Tx Buffer */
AT91C_BASE_DBGU->DBGU_THR = ch; /* Transmit Character */
return ch;

default:
break;
}
return -1;
}

int commd_puts( int port, char* buff) {
if (!comm_initialized[port]) return -3;
while(*buff) {
if (*buff == '\n') commd_putc(port, '\r');
commd_putc(port, *buff++);
}
return 0;
}

int commd_getc (int port) {
if (!comm_initialized[port]) return -3;
switch (port) {
case USART0:
while (!(AT91C_BASE_US0->US_CSR & AT91C_US_RXRDY)); /* Wait for Full Rx Buffer */
return (AT91C_BASE_US0->US_RHR); /* Read Character */

case USART1:
while (!(AT91C_BASE_US1->US_CSR & AT91C_US_RXRDY)); /* Wait for Full Rx Buffer */
return (AT91C_BASE_US1->US_RHR); /* Read Character */

case DUSART:
while (!(AT91C_BASE_DBGU->DBGU_CSR & AT91C_US_RXRDY)); /* Wait for Full Rx Buffer */
return (AT91C_BASE_DBGU->DBGU_RHR); /* Read Character */

default:
break;
}
return -1;
}

int commd_is_rx_empty(int port) {
if (!comm_initialized[port]) return -3;
switch (port) {
case USART0:
return (!(AT91C_BASE_US0->US_CSR & AT91C_US_RXRDY)); /* Full Rx Buffer */
case USART1:
return (!(AT91C_BASE_US1->US_CSR & AT91C_US_RXRDY)); /* Full Rx Buffer */
case DUSART:
return (!(AT91C_BASE_DBGU->DBGU_CSR & AT91C_US_RXRDY)); /* Full Rx Buffer */
default:
break;
}
return -1;
}

//------------------------------------------------------------------------------------------------------- PRINTF -------------------------------------------
#include <stdio.h> /* I/O Functions */
#include <stdarg.h>
#include "FreeRTOS.h"
#include "semphr.h"

static xSemaphoreHandleprintf_sem;

void kprintf_init() {
vSemaphoreCreateBinary( printf_sem );
while (printf_sem == NULL);//halt if failed
}

void kprintfFromISR(const char *format,...) {
static char buf[100];
va_list ap;
va_start(ap, format);
vsnprintf(buf, sizeof(buf), format, ap);//viprintf() - without floating numbers. %f..
va_end(ap);
commd_puts(DBG_DEV, buf);
//comm_puts(DBG_DEV, buf);
}

void kprintf(const char *format,...) {
static char buf[100];
va_list ap;
va_start(ap, format);
vsnprintf(buf, sizeof(buf), format, ap);//viprintf() - without floating numbers. %f..
va_end(ap);
while (!xSemaphoreTake(printf_sem, 100));//block
commd_puts(DBG_DEV, buf);
//comm_puts(DBG_DEV, buf);
xSemaphoreGive(printf_sem);//unblock
}

void ppp_trace(int level, const char *format,...) {// ppp debug
static char buf[100];
va_list ap;
va_start(ap, format);
vsnprintf(buf, sizeof(buf), format, ap);//viprintf() - without floating numbers. %f..
va_end(ap);
while (!xSemaphoreTake(printf_sem, 100));//block
commd_puts(DBG_DEV, buf);
//comm_puts(DBG_DEV, buf);
xSemaphoreGive(printf_sem);//unblock
}

Janusz

RE: Anyone have AT91SAM7X256 GCC Serial source ?

Posted by Nobody/Anonymous on September 5, 2006
Thank you..
I have tested your source code. Mr Janusz

But It didn't work.

Can you send all project files related with serial to me?

Best Regards.





[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists