// Enhanced RS232
// A simple Multi-slave
// sistem with rs232 to
// use between PIC to
// PIC or PIC to PC.
// MASTER VERSIÓN
/*****************************************************************************
* *
* THIS LIBRARY WAS CREATED BY ISMAEL CONCHA V. (FANTAXMAX) *
* AND YOU ARE ALLOWED TO SHARE &/OR MODIFY *
* AS YOU LIKE, BUT YOU HAVE TO SHARE THE NEW LIBRARY *
* IN THE POST OF TODOPIC.COM.AR THAT WAS POSTED. *
* *
*****************************************************************************/
#define in input
#define ol output_low
#define oh output_float
#ifndef TX
#define TX PIN_B7
#define RX PIN_B6
#endif
int dirs;
void init_master_bus(int TX, int RX, int BAUD)
{
rst_bus();
#use RS232(stream=ers232, baud=BAUD, XMIT=TX, RCV=RX)
}
void send(int dir, char text)
{
wait_freebus();
rst_bus();
}
char rcv()
{
char buff[];
return buff[];
}
int new_hw() //MUST USE AN EXTERNAL INTERRUPT CONNECTED TO RI OUT OF SLAVE
{
dirs++;
return dirs;
}
//END USER FUNCTIONS
void wait_freebus()
{
while(1)
{if(in(TX)&&in(RX)){
delay_ms(100);
if(in(TX)&&in(RX)){break;}}}
}
void rst_bus()
{
oh(TX);
oh(RX);
}