Serial Problem
Posted: Sat Feb 19, 2011 8:01 pm
Hi Giovanni,
i have an a questions . I write my first program using task using your fantastic os , but i have a doubt .
So The program is simple , this is the code :
#include "ch.h"
#include "hal.h"
#include "test.h"
/*
* Red LED blinker thread, times are in milliseconds.
*/
static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
(void)arg;
while (TRUE) {
palClearPad(IOPORT2, 7);
//sdAsynchronousWrite(&SD1,"CIAO",4);
chThdSleepMilliseconds(500);
palSetPad(IOPORT2, 7);
chThdSleepMilliseconds(500);
}
}
// USART thread, processes GPS inputs
static WORKING_AREA(waThread2, 512);
static msg_t Thread2(void *arg) {
(void)arg;
char c;
while (TRUE)
{
c = chIOGet(&SD1);
switch(c)
{
case '1':
sdWrite(&SD1,"Recived 1\n\r",11);
break;
case '2':
sdWrite(&SD1,"Recived 2\n\r",11);
break;
case '3':
sdWrite(&SD1,"Recived 3\n\r",11);
break;
case '4':
sdWrite(&SD1,"Recived 4\n\r",11);
break;
case '5':
sdWrite(&SD1,"Recived 5\n\r",11);
break;
default:
sdWrite(&SD1,"NO AVAILABLE\n\r",15);
menu();
}
}
}
/*
* Application entry point.
*/
int menu(void)
{
sdWrite(&SD1,"MP32 Testing Program Choose your test\n\r",40);
sdWrite(&SD1,"1) Test Radio Input\n\r",21);
sdWrite(&SD1,"2) Test PWM Output \n\r",21);
sdWrite(&SD1,"3) Read Anag Input (ANX)\n\r",27);
sdWrite(&SD1,"4) Read Anag Input (SPI)\n\r",27);
sdWrite(&SD1,"5) Read Anag Input (I2c)\n\r",27);
sdWrite(&SD1,"6) Read Barometer (I2c)\n\r",27);
sdWrite(&SD1,"7) Read GPS (Ser2)\n\r",27);
}
int main(void) {
/*
* System initializations.
* - HAL initialization, this also initializes the configured device drivers
* and performs the board-specific initializations.
* - Kernel initialization, the main() function becomes a thread and the
* RTOS is active.
*/
halInit();
chSysInit();
/*
* Activates the serial driver 2 using the driver default configuration.
*/
sdStart(&SD1, NULL);
/*
* Creates the blinker thread.
*/
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/*
* Creates the Serial1 Recive Thread.
*/
chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL);
menu();
/*
* Normal main() thread activity, in this demo it does nothing except
* sleeping in a loop and check the button state.
*/
while (TRUE) {
//chThdSleepMilliseconds(5000);
}
}
But when the thread2 call the menu some time i don't see some character in my terminal ...
Do you have some idea ? Problem with variable definition or passing ?
In the next day i start to write some Howto and tutorial on your hal for customers of MP32 . I hope that they decide to sue your OS on my board.
Onother request is but in your api there's a function that return the number of byte available in the buffer ? In the documentation i don't found it.
The last question is : I need to remap a external Xtal to different pin XTAL_REMAP , how is possible to do that in your OS ?
Regards
Roberto
i have an a questions . I write my first program using task using your fantastic os , but i have a doubt .
So The program is simple , this is the code :
#include "ch.h"
#include "hal.h"
#include "test.h"
/*
* Red LED blinker thread, times are in milliseconds.
*/
static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
(void)arg;
while (TRUE) {
palClearPad(IOPORT2, 7);
//sdAsynchronousWrite(&SD1,"CIAO",4);
chThdSleepMilliseconds(500);
palSetPad(IOPORT2, 7);
chThdSleepMilliseconds(500);
}
}
// USART thread, processes GPS inputs
static WORKING_AREA(waThread2, 512);
static msg_t Thread2(void *arg) {
(void)arg;
char c;
while (TRUE)
{
c = chIOGet(&SD1);
switch(c)
{
case '1':
sdWrite(&SD1,"Recived 1\n\r",11);
break;
case '2':
sdWrite(&SD1,"Recived 2\n\r",11);
break;
case '3':
sdWrite(&SD1,"Recived 3\n\r",11);
break;
case '4':
sdWrite(&SD1,"Recived 4\n\r",11);
break;
case '5':
sdWrite(&SD1,"Recived 5\n\r",11);
break;
default:
sdWrite(&SD1,"NO AVAILABLE\n\r",15);
menu();
}
}
}
/*
* Application entry point.
*/
int menu(void)
{
sdWrite(&SD1,"MP32 Testing Program Choose your test\n\r",40);
sdWrite(&SD1,"1) Test Radio Input\n\r",21);
sdWrite(&SD1,"2) Test PWM Output \n\r",21);
sdWrite(&SD1,"3) Read Anag Input (ANX)\n\r",27);
sdWrite(&SD1,"4) Read Anag Input (SPI)\n\r",27);
sdWrite(&SD1,"5) Read Anag Input (I2c)\n\r",27);
sdWrite(&SD1,"6) Read Barometer (I2c)\n\r",27);
sdWrite(&SD1,"7) Read GPS (Ser2)\n\r",27);
}
int main(void) {
/*
* System initializations.
* - HAL initialization, this also initializes the configured device drivers
* and performs the board-specific initializations.
* - Kernel initialization, the main() function becomes a thread and the
* RTOS is active.
*/
halInit();
chSysInit();
/*
* Activates the serial driver 2 using the driver default configuration.
*/
sdStart(&SD1, NULL);
/*
* Creates the blinker thread.
*/
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/*
* Creates the Serial1 Recive Thread.
*/
chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL);
menu();
/*
* Normal main() thread activity, in this demo it does nothing except
* sleeping in a loop and check the button state.
*/
while (TRUE) {
//chThdSleepMilliseconds(5000);
}
}
But when the thread2 call the menu some time i don't see some character in my terminal ...
Do you have some idea ? Problem with variable definition or passing ?
In the next day i start to write some Howto and tutorial on your hal for customers of MP32 . I hope that they decide to sue your OS on my board.
Onother request is but in your api there's a function that return the number of byte available in the buffer ? In the documentation i don't found it.
The last question is : I need to remap a external Xtal to different pin XTAL_REMAP , how is possible to do that in your OS ?
Regards
Roberto