Moderadores: 51, guest2003, Renie, gpenga
/******************************************************************************
** Descrição: FUNÇÃO PRINCIPAL
*****************************************************************************/
int main (void) {
configura_sistema();
WDCLKSEL= 0x00000001; //seleciona fonte de clock o cristal para o watchdog
WDTC = 0x0599ffff;
WDMOD |= 0x00000003;
WDFEED = 0xAA;
WDFEED = 0x55;
os_sys_init (inicia);
for(;;);
}
/*****************************************************************************
** Descrição: TAREFAS RTOS - CACHORRO BRAVO
*****************************************************************************/
void watchdog (void) __task {
WDCLKSEL= 0x00000001; //seleciona fonte de clock o cristal para o watchdog
for (;;){
delay(1);
if(!reset){
WDTC = WDTEMPO; //constante com o tempo de estouro
WDMOD |= 0x00000003;
WDFEED = 0xAA;
WDFEED = 0x55;
}
}
}
*****************************************************************************
** Function name: TAREFAS RTOS - INICIALIZAÇÃO DO SISTEMA
*****************************************************************************/
void inicia (void) __task {
t_inicia = os_tsk_self ();
debug("PRO-CONTROL SERVICOS INDUSTRIAIS\r\n"
"HKM MACHINE - REVISAO 1.0\r\n"
"Aguarde inicializacao do sistema...\r\n");
t_watchdog = os_tsk_create (watchdog, 0);
/*INCIA SD CARD E FAT SYSTEM*/
finit();
/*HABILITA PWM*/
// PWM1TCR = 0x00000009;
/*PINO GERA INTERRUPÇÃO*/
IO0_INT_EN_R |= ENCH_1;
/*INICIA TAREFAS*/
t_funcionando = os_tsk_create (funcionando, 0);
t_encoders = os_tsk_create (encoders, 0);
t_sensores = os_tsk_create (sensores, 0);
t_prepara= os_tsk_create (prepara, 0);
t_relogio = os_tsk_create (relogio, 0);
t_sdcard = os_tsk_create (sdcard, 0);
t_le_eeprom = os_tsk_create (le_eeprom, 0);
t_escreve_eeprom= os_tsk_create (escreve_eeprom, 0);
t_menu = os_tsk_create (menu, 0);
t_biometria = os_tsk_create (biometria , 0);
t_teclado = os_tsk_create (teclado, 0);
t_zigbee = os_tsk_create (zigbee, 0);
t_motores = os_tsk_create (motores, 0);
t_alarme = os_tsk_create (alarme, 0);
t_luzbuzina= os_tsk_create (luzbuzina, 0);
/*ATIVA INTERRUPÇÕES SERIAIS*/
U0IER = 0x00000001;
U1IER = 0x00000001;
/*HABILITA I2C*/
I20CONSET = 0x00000040;
/*INICIA CAIXAS DE MENSAGENS*/
os_mut_init (critico);
os_mbx_init (msgemail, sizeof(msgemail));
os_mbx_init (msgsdcard, sizeof(msgsdcard));
os_mbx_init (msgzigbee, 20);
os_mbx_init (msglcd, sizeof(msglcd));
os_mbx_init (msgbiometria, sizeof(msgbiometria));
os_mbx_init (msgteclado, sizeof(msgteclado));
os_mbx_init (msgrelogio, sizeof(msgrelogio));
// os_mbx_init (msgsensores, sizeof(msgsensores));
seta_evento(t_prepara);
os_tsk_delete_self ();
}
anderson.correia escreveu:... por isso eu achei interessante deixa-las fora, em um sub rotina.
void ClearWDT ( char pointer )
{
static char internal_pointer = 0 ;
internal_pointer = pointer ;
switch ( internal_pointer )
{
case 0 : ClrWdt() ; internal_pointer = 1 ; break ;
case 1 : ClrWdt() ; internal_pointer = 2 ; break ;
case 2 : ClrWdt() ; internal_pointer = 0 ; break ;
}
}
Usuários navegando neste fórum: Nenhum usuário registrado e 1 visitante