Avoided accidents using can protocol through the smartwatch
Protocols: CAN, LCD
Brief: In this project, we checking initial conditions like seat belt etc after that if any case gets to sleep, increase or decrease blood pressure that will sense by smartwatch that information shares can protocol and giving a different indication to outside people and sending a message to 108 and their family members.
Hardware Used: lpc2129 development board (ARM7), Bluetooth, pulse measure sensor.
Software Used: Keil µVision 4, Flash Magic
code for the above project
#include "header.h"unsigned int MSG[4];
unsigned char can_test()
{
unsigned int a,b,key,sleep=0,wait=1;
test:
lcdstring("turn on ignitation");
delay(1000);
lcdclear();
key=IOPIN1;
key=IOPIN1 &(1<<25);
if(key)
{
lcdclear();
lcdstring("key pass");
delay(1000);
TX_from_CAN2(2);
while(!(RX_IN_CAN1()==2));
lcdclear();
lcdstring("ignitation start");
delay(1000);
lcdclear();
lcdstring("checking status");
delay(2000);
a=IOPIN0;
a=(0x0000010 & a);
b=IOPIN0;
b=(0x0000040 & b);
if(a==0&&b==0)
{
TX_from_CAN2(2);
while(!(RX_IN_CAN1()==2));
lcdclear();
lcdstring("braktest pass");
delay(2000);
TX_from_CAN2(2);
while(!(RX_IN_CAN1()==2));
lcdclear();
lcdstring("seat pass");
delay(2000);
TX_from_CAN2(2);
while(!(RX_IN_CAN1()==2));
while(wait)
{
if(sleep==1)
{
lcdstring("your in sleep");
}else if(a==1)
{
lcdstring("your remove seat belt");
wait=0;
}
}
return 1;
}
else
{
lcdclear();
delay(1000);
lcdstring("test fail");
delay(2000);
return 0;
}
}
goto test;
}
void canint()
{
VPBDIV =0X02;//divide frequncy by 2 30frequney
PINSEL1 |=(1<<22)|(1<<24)|(1<<26)|(1<<28)|(1<<18)|(1<<16)|(1<<14); //18,16.14 can tx & rx
C1MOD= 1<<0; // can data sheet reset bit because we writting something ex :electrical city repair
C1BTR=1<<20|1<<19|1<<18|29; //bus timing register plck/btr 1100 19-16
C1MOD=0;
C2MOD=1<<0;
C2BTR=1<<20|1<<19|1<<18|29;
C2MOD=0;
}
void TX_from_CAN2(unsigned int ch)
{
while((C2SR&0X00000004)!=0X00000004); //sr status register check 2 bit 1 2 4
C2TFI1=(1<<18); //transsimission frame information like dlc,rtr ,ide
C2TDA1=ch; // it will contaoined 32 bit
C2TID1=0x45; // 11 bit are 29 bit
C2CMR=(1<<0)|(1<<5); //0 bit for fillter 5 tx buffer
while((C2GSR&0x00000008)!=0x00000008);//goble data register read value s r no
}
unsigned int RX_IN_CAN1(void)
{
while((C1SR&0x01));
MSG[0]=C1RID;
MSG[1]=C1RDA;
MSG[2]=C1RDB;
MSG[3]=C1RFS; // NEXT FRAME
C1CMR=(1<<2); // DATA TRSNSPITE
return MSG[1];
}
Comments
Post a Comment