Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


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 ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

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

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner