/* * Copyright (C) 2003 BLADOX, s.r.o. All rights reserved. * * This file is part of an example program for Turbo. This example * program may be used, distributed and modified without limitation. * */ #include <config.h> #include <turbo/turbo.h> #include <stdlib.h> #include <string.h> u8 PROGMEM t_Foo_en[] = "SAFE OPEN!"; // alarm text u8 PROGMEM t_ms[] = "+420123456789"; // whom to send alarm //------------------------------------------------------------------------ // INPUT pin of ALARM application (A15 = PC7) //------------------------------------------------------------------------ #define ALARM_DDR DDRC #define ALARM_DDR_PIN DD7 #define ALARM_PORT PORTC #define ALARM_PORT_PIN PORT7 #define ALARM_PIN PINC #define ALARM_PIN_PIN PIN7 void action_sms (void *data) { u8 *tmp = malloc (100); u8 *ms = str2msisdn (t_ms, MSISDN_ADN, MEM_R); memcpy (tmp, t_Foo_en, sizeof (t_Foo_en)); // answer // sms on display send_sms (tmp, sizeof (t_Foo_en), ms, MSISDN_ADN, 0xF4, 0, NULL, NULL); // sms to ME send_sms (tmp, sizeof (t_Foo_en), ms, MSISDN_ADN, 0xF5, 0, NULL, NULL); free (tmp); free (ms); } void turbo_handler (u8 action, void *data) { switch (action) { case ACTION_APP_INIT: sbi (ALARM_PORT, ALARM_PORT_PIN); //set ALARM pin output register bit to log.1 asm __volatile__ ("nop"); //wait cbi (ALARM_DDR, ALARM_DDR_PIN); //ALARM pin is INPUT reg_action (ACTION_STATUS); break; case ACTION_STATUS: // test if input ALARM pin is LOW if ((inb (ALARM_PIN) & (1 << ALARM_PIN_PIN)) != 0) stk_thread (action_sms, NULL); break; default: break; } }
Copyright © 2004-2006 BLADOX | Turbo version 1.2
|