Go to the documentation of this file.
69 volatile unsigned cprog;
77 const unsigned char min_length[]={
90 static unsigned char* buffer_ptr;
91 volatile unsigned char packet_len;
92 volatile unsigned char packet_src;
94 static sem_t packet_sem;
97 #define debugs(a) { cputs(a); msleep(500); }
98 #define debugw(a) { cputw(a); msleep(500); }
105 int lrkey_handler(
unsigned int etype,
unsigned int key);
124 static void program_run(
unsigned nr) {
142 static void packet_producer(
const unsigned char *data,
143 unsigned char length,
147 if(packet_len>0 || length==0)
153 buffer_ptr =
malloc(length);
154 memcpy(buffer_ptr,data,length);
161 static int packet_consumer(
int argc,
char *argv[]) {
178 debugw(*(
size_t*)buffer_ptr);
183 if (cmd>=
CMDlast || packet_len<min_length[cmd])
188 if (buffer_ptr[1]==0) {
189 debugs(
"nearmodeIR");
272 size_t offset=*(
size_t*)(buffer_ptr+2);
273 if(offset<=prog->downloaded) {
275 memcpy(prog->
text+offset,buffer_ptr+4,packet_len-4);
356 #ifdef CONF_LR_HANDLER
364 int key_handler(
int argc,
char *argv[]) {
377 debugs(
"key "); debugw(c);
476 #if defined(CONF_DSENSOR)
481 #endif // CONF_DSENSOR
495 #if defined(CONF_LR_HANDLER)
496 int lrkey_handler(
unsigned int etype,
unsigned int key) {
498 unsigned char pnr = 0;
517 #endif // CONF_DSOUND
540 #ifndef CONF_LCD_REFRESH
552 #if defined(CONF_DMOTOR)
578 #endif // CONF_DMOTOR
583 #ifndef CONF_LCD_REFRESH
593 #if defined(CONF_DMOTOR)
609 #endif // CONF_DMOTOR
627 #ifndef CONF_LCD_REFRESH
644 #ifdef CONF_LR_HANDLER
661 #ifdef CONF_LR_HANDLER
666 #endif // CONF_PROGRAM
void lr_set_handler(lr_handler_t handler)
set a new handler for LEGO IR Remote messages
Interface: console input / output.
Internal Interface: battery handling.
void lcd_refresh(void)
refresh the entire LCD display
Interface: LEGO Infrared Remote Control.
atomic_t sem_t
the semaphore data-type
1+12: b[nr] s[textsize] s[datasize]
unsigned int msleep(unsigned int msec)
unsigned char lnp_hostaddr
LNP host address.
volatile unsigned int nb_tasks
number of tasks
void dm_init(void)
initialize motors
Internal Interface: program data structures and functions.
void lr_shutdown(void)
stop the LEGO IR Remote subsystem
Interface: string functions.
#define LRKEY_STOP
Stop key.
void dsound_stop(void)
stop playing sound
int get_battery_mv()
get current battery voltage
void cputw(unsigned word)
Write a HEX word to LCD.
The program control structure.
int sem_destroy(sem_t *sem)
We're done with the semaphore, destroy it.
volatile unsigned int nb_system_tasks
void lnp_set_hostaddr(unsigned char host)
set new LNP host address
#define T_KERNEL
task flags
size_t bss_size
bss segment size in bytes
void program_init()
initialize program support
void * data
origin of data segment (imm. after text)
#define LRKEY_B2
Motor-B reverse (down)
wakeup_t wait_event(wakeup_t(*wakeup)(wakeup_t), wakeup_t data)
void * memcpy(void *dest, const void *src, size_t size)
copy memory block from src to dest.
#define LRKEY_P5
Run Program 5.
int sem_init(sem_t *sem, int pshared, unsigned int value)
Initialize a semaphore.
size_t downloaded
number of bytes downloaded so far.
size_t start
offset from text segment to start into.
void free(void *ptr)
return the allocated memory to memory management.
#define lcd_int(i)
display an integer in decimal
void * malloc(size_t size)
allocate and return pointer to uninitialized memory
Internal Interface: direct motor control.
#define KEY_VIEW
the view key is pressed
Interface: POSIX 1003.1b semaphores for task synchronization.
void * memset(void *s, int c, size_t n)
fill memory block with a byte value.
void ds_init(void)
initialize sensor a/d conversion
#define LRKEY_C2
Motor-C reverse (down)
1+>3: b[nr] s[offset] array[data]
#define KEY_RUN
the run key is pressed
size_t text_size
text segment size in bytes
Internal LNP Interface: link networking protocol.
volatile unsigned cprog
the current program
void motor_b_dir(MotorDirection dir)
set motor B direction to dir
tdata_t * ctid
ptr to current process data
#define CONF_LNP_HOSTMASK
LNP host mask.
tid_t execi(int(*code_start)(int, char **), int argc, char **argv, priority_t priority, size_t stack_size)
void cputc_0(unsigned c)
write ASCII char to position 0 of LCD
void * text
origin of text segment
void cputs(char *s)
Write string s to LCD (Only first 5 chars)
void lnp_addressing_set_handler(unsigned char port, lnp_addressing_handler_t handler)
set an addressing layer packet handler for a port.
#define KEY_ANY
any of the keys
int sem_wait(sem_t *sem)
Wait for semaphore (blocking)
#define LRKEY_A1
Motor-A forward (up)
void killall(priority_t p)
void program_shutdown()
shutdown program support
int getchar()
wait for keypress and return key code.
#define T_SHUTDOWN
shutdown requested
priority_t prio
priority to run this program at
void shutdown_tasks(tflags_t flags)
#define LRKEY_C1
Motor-C forward (up)
void * bss
origin of bss segment (imm. after data)
void lr_init(void)
initialize the LEGO IR Remote subsystem
#define PROG_MAX
maximum number of programs
#define LRKEY_P1
Run Program 1.
int lnp_addressing_write(const unsigned char *data, unsigned char length, unsigned char dest, unsigned char srcport)
send a LNP addressing layer packet of given length
#define LRKEY_A2
Motor-A reverse (down)
#define LNP_DUMMY_ADDRESSING
dummy addressing layer packet handler
void cls()
clear user portion of LCD
#define KEY_ONOFF
the on/off key is pressed
#define LRKEY_P2
Run Program 2.
size_t data_size
data segment size in bytes
#define LRKEY_P4
Run Program 4.
void lr_startup(void)
start the LEGO IR Remote subsystem
tflags_t tflags
task flags
static void dsound_system(unsigned nr)
play a system sound
Interface: reduced UNIX standard library.
#define LRKEY_P3
Run Program 3.
void motor_c_dir(MotorDirection dir)
set motor C direction to dir
void lnp_init(void)
Initialise protocol handlers.
#define LRKEY_B1
Motor-B forward (up)
#define KEY_PRGM
the program key is pressed
Internal Interface: task management.
a key on the remote was released
wakeup_t dkey_released(wakeup_t data)
wakeup if all of the given keys are released.
#define DEFAULT_STACK_SIZE
that's enough.
int mm_free_mem(void)
how many bytes of memory are free?
Interface: reduced standard C library.
void motor_a_dir(MotorDirection dir)
set motor A direction to dir
#define shutdown_requested()
test to see if task has been asked to shutdown
#define LRKEY_BEEP
Beep Key.
Internal Interface: direct sensor access.
void lnp_logical_range(int far)
Set the IR transmitter range.
size_t stack_size
stack segment size in bytes
void * data_orig
origin of backup copy of data segment
int sem_post(sem_t *sem)
Post a semaphore.
#define PRIO_HIGHEST
The highest possible task priority.
void cputc_hex_0(unsigned nibble)
write HEX digit to position 0 of LCD
a key on the remote was pressed
int program_valid(unsigned nr)
check if a given program is valid.
Internal LNP Interface: link networking protocol logical layer.
Internal Interface: memory management.
void program_stop(int flag)
stop program
Generated for brickOS Kernel Developer by
1.8.16