Hi Andrzej, It's a good idea, I'll create some documentation with samples. You can look at any of the automated tests in the meantime though. For example if you look at sem4.c you will see a sample application that creates several test threads. Put this file together with tests-main.c and you have a full application.
I haven't done anything with C++ on Atomthreads yet, but I have on previous projects and we use extern "C" in a similar way. I'll look into making it more suitable for C++ so that you do not need to do this. This might take a while though as I won't be able to do anything on Atomthreads for the next two weeks due to work commitments. I might be able to answer occasional emails but won't be getting heavily into any coding. Back to normal again in two weeks. Thanks, Kelvin. On 10 March 2010 12:03, Andrzej Telszewski <atelszew...@gmail.com> wrote: > Hi, > > It would be nice if you put some more examples on how to use atomthreads. > Let's say it would have 3 or 4 threads and some two interrupts and the stack > sizes explained. I'm novice in threads, so I might be asking for too much, > if so, then clarify me;) > > Also, I'm very interested in using C++ with atom and it seems that it works, > so maybe you could give some explanation on how to do it properly? I attach > my test application that uses one C++ object. > > Finally, I suggest that AVR_CPU_HZ in atomport.h was defined as: > #define AVR_CPU_HZ F_CPU > and that "atomport-asm.s" was renamed to "atomport-asm.S". Those two changes > will allow the atomthreads to integrate nicely with WinAVR (or with Makefile > from WinAVR, as I use it under Linux). > > By the way, as you may notice I'm interested in AVR's, but it might change;) > > -- > Best regards, > Andrzej Telszewski > > #include <avr/io.h> > #include "lcd.h" > > extern "C" { > # include "atom.h" > # include "atomport.h" > # include "atomtimer.h" > } > > #define IDLE_STACK_SIZE_BYTES 128 > #define STARTUP_STACK_SIZE_BYTES 64 > > static uint8_t idle_thread_stack[IDLE_STACK_SIZE_BYTES]; > > static ATOM_TCB main_tcb; > static void main_thread_func (uint32_t data); > > static ATOM_TCB lcd_tcb; > static void lcd_thread_func (uint32_t data); > > int main() > { > if( ATOM_OK == atomOSInit(&idle_thread_stack[IDLE_STACK_SIZE_BYTES - > 1]) ) > { > avrInitSystemTickTimer(); > > if( ATOM_OK != atomThreadCreate( &lcd_tcb, 64, > lcd_thread_func, 0, (POINTER)(RAMEND-STARTUP_STACK_SIZE_BYTES-128) ) ) > { > goto _ATOM_FAILED; > } > > if( ATOM_OK == atomThreadCreate( &main_tcb, 64, > main_thread_func, 0, (POINTER)(RAMEND-STARTUP_STACK_SIZE_BYTES)) ) > { > atomOSStart(); > } > } > > _ATOM_FAILED: > while( 1 ); > > return 0; > } > > static void main_thread_func (uint32_t data) > { > while( 1 ) > { > PORTB |= _BV(PB0); > atomTimerDelay( 20 ); > PORTB &= ~_BV(PB0); > atomTimerDelay( 20 ); > } > } > > static void lcd_thread_func (uint32_t data) > { > uint8_t sec = 35; > uint8_t min = 41; > uint8_t hour = 12; > > while( 1 ) > { > if( ++sec == 60 ) > { > sec = 0; > if( ++min == 60 ) > { > min = 0; > if( ++hour == 24 ) hour = 0; > } > } > > lcd.clrscr(); > lcd << pad() << (uint8_t)hour << ':' << (uint8_t)min << ':' > << (uint8_t)sec; > atomTimerDelay( SYSTEM_TICKS_PER_SEC ); > } > } > >