Main Page | Modules | File List | Globals

hemisson.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------------//
00002 //-                   HemiOs ( Hemisson Operating System )                       -//
00003 //-                                                                              -//
00004 //-  Copyright (C) Alexandre Colot, K-Team S.A. 2002                             -//
00005 //-  This library is free software; you can redistribute it and/or               -//
00006 //-  modify it under the terms of the GNU Lesser General Public                  -//
00007 //-  License as published by the Free Software Foundation; either                -//
00008 //-  version 2.1 of the License, or any later version.                           -//
00009 //-                                                                              -//
00010 //-  This library is distributed in the hope that it will be useful,             -//
00011 //-  but WITHOUT ANY WARRANTY; without even the implied warranty of              -//
00012 //-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU           -//
00013 //-  Lesser General Public License for more details.                             -//
00014 //-                                                                              -//
00015 //-  You should have received a copy of the GNU Lesser General Public            -//
00016 //-  License along with this library; if not, write to the Free Software         -//
00017 //-  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   -//
00018 //-                                                                              -//
00019 //-                               __  __  ________                               -//
00020 //- K-Team S.A.                  |  |/  /|__    __|___  _____  ___  ___          -//
00021 //- Chemin de Vuasset, CP 111    |     / __ |  | _____|/  _  \|   \/   |         -//
00022 //- 1028 Preverenges             |  |  \    |  | ____|/  /_\  |        |         -//
00023 //- Switzerland                  |__|\__\   |__|______|_/   \_|__|\/|__|         -//
00024 //- alexandre.colot@k-team.com   tel:+41 21 802 5472 fax:+41 21 802 5471         -//
00025 //-                                                                              -//
00026 //--------------------------------------------------------------------------------//
00027 
00028 #device PIC16F877 *=16 ADC=8
00029 #include "16F877.h"
00030 #fuses HS,NOWDT,NOPROTECT,NOPUT,NOBROWNOUT,NOLVP,WRT,NOCPD                       // Configuration Bits
00031 #use delay(clock=20000000)                                                       // Clock @ 20 MHz
00032 #use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7)                          // Serial Configuration
00033 #use i2c( master , sda = PIN_C4 , scl = PIN_C3, FORCE_HW, SLOW  )                // I2C Master Configuration
00034 
00035 #use fast_io (a)
00036 #use fast_io (b)
00037 #use standard_io (c)
00038 #use fast_io (d)
00039 #use fast_io (e)
00040 
00041 #include "constants.h"
00042 #include "variables.c"
00043 #include "hemisson_task1.c"
00044 #include "hemisson_task2.c"
00045 #include "hemisson_task3.c"
00046 #include "hemisson_task4.c"
00047 #include "hemisson.c"
00048 
00049 #org 0x1F00, 0x1FFF {}                                                             // Bootloader Protection
00050 
00051 
00053 
00056 
00057 
00062 
00063 
00068 
00069 void hemisson_init(void)
00070 {
00071    __hemisson_init();
00072 }
00073 
00075 
00080 
00081 void hemisson_config_auto_refresh_sensors(int1 Bit)
00082 {
00083    __Auto_Refresh_Sensors=Bit;
00084 }
00085 
00087 
00092 
00093 void hemisson_config_auto_refresh_tv_remote(int1 Bit)
00094 {
00095    __Auto_Refresh_TV_Remote=Bit;
00096 }
00097 
00099 
00104 
00105 void hemisson_config_rs232_control(int1 Bit)
00106 {
00107    __Enable_RS232_Control=Bit;
00108 }
00109 
00111 
00116 
00117 void hemisson_config_tv_remote_control(int1 Bit)
00118 {
00119    __Enable_TV_Remote_Control=Bit;
00120 }
00127 
00128 
00134 
00135 int1 hemisson_flag_sensors_refreshed(void)
00136 {
00137    return __Sensors_Refreshed_Flag;
00138 }
00140 
00145 
00146 void hemisson_flag_sensors_reset(void)
00147 {
00148    __Sensors_Refreshed_Flag = 0;
00149 }
00151 
00156 
00157 int1 hemisson_flag_rs232_filtering(void)
00158 {
00159    return __Enable_RS232_Control;
00160 }
00162 
00168 
00169 int1 hemisson_flag_tv_data_refreshed(void)
00170 {
00171    return __TV_Data_Available;
00172 }
00174 
00179 
00180 void hemisson_flag_tv_data_reset(void)
00181 {
00182    __TV_Data_Available = 0;
00183 }
00190 
00191 
00196 
00197 unsigned char hemisson_get_proximity(char Sensor)
00198 {
00199    return __IR_Proximity[Sensor];
00200 }
00201 
00203 
00208 
00209 unsigned char hemisson_get_brightness(char Sensor)
00210 {
00211    return __IR_Light[Sensor];
00212 }
00213 
00215 
00220 
00221 int1 hemisson_get_switch_state(char Switch_Number)
00222 {
00223    return __Switchs[Switch_Number];
00224 }
00225 
00227 
00232 
00233 char hemisson_get_tv_data(void)
00234 {
00235    return __TV_DATA;
00236 }
00237 
00239 
00244 
00245 void hemisson_set_speed(signed int8 LeftSpeed,signed int8 RightSpeed)
00246 {
00247    __PwmMotLeft = LeftSpeed;
00248    __PwmMotRight = RightSpeed;
00249 }
00250 
00252 
00257 
00258 void hemisson_beep(int1 State)
00259 {
00260    output_bit(PIN_D4,State);
00261 }
00262 
00264 
00269 
00270 void hemisson_led_frontleft(int1 State)
00271 {
00272    output_bit(PIN_D6,State);
00273 }
00274 
00276 
00281 
00282 void hemisson_led_frontright(int1 State)
00283 {
00284    output_bit(PIN_A4,!State);
00285 }
00286 
00288 
00293 
00294 void hemisson_led_pgmexec(int1 State)
00295 {
00296    output_bit(PIN_D5,State);
00297 }
00298 
00300 
00306 
00307 void hemisson_led_onoff(int1 State)
00308 {
00309    output_bit(PIN_D7,State);
00310 }
00311 
00313 
00318 
00319 void hemisson_manual_refresh_sensors(char Zone)
00320 {
00321    __hemisson_refresh_sensors(Zone);
00322 }
00329 
00330 
00335 
00336 void hemisson_delay_s(int Delay)
00337 {
00338    int i;
00339    for(i = 0; i< Delay; i++)
00340    {
00341       delay_ms(1000);
00342    }
00343 }
00344 
00346 
00351 
00352 void hemisson_delay_ms(int Delay)
00353 {
00354    delay_ms(Delay);
00355 }
00356 
00358 
00363 
00364 void hemisson_delay_us(int Delay)
00365 {
00366    delay_us(Delay);
00367 }
00368 
00370 
00375 
00376 unsigned int32 hemisson_get_time(void)
00377 {
00378    return __TimeTip;
00379 }
00380 
00382 
00387 
00388 void hemisson_set_time(unsigned int32 Time)
00389 {
00390    __TimeTip = Time;
00391 }
00392 
00400 // External Access
00402 
00407 
00408 int1 hemisson_ext_read_PINB0(void)
00409 {
00410    return input(PIN_B0);
00411 }
00413 
00418 
00419 int1 hemisson_ext_read_PINB6(void)
00420 {
00421    return input(PIN_B6);
00422 }
00424 
00429 
00430 int1 hemisson_ext_read_PINB7(void)
00431 {
00432    return input(PIN_B7);
00433 }
00435 
00440 
00441 void hemisson_ext_write_PINB0(int1 Bit)
00442 {
00443    output_bit(PIN_B0,bit);
00444 }
00446 
00451 
00452 void hemisson_ext_write_PINB6(int1 Bit)
00453 {
00454    output_bit(PIN_B6,bit);
00455 }
00457 
00462 
00463 void hemisson_ext_write_PINB7(int1 Bit)
00464 {
00465    output_bit(PIN_B7,bit);
00466 }

Generated on Mon Feb 23 23:53:21 2004 for HemiOs by doxygen 1.3.4