示例#1
0
BOOL EEPROMCommand(UINT8 command, UINT16 volatile * const address, const UINT16 data)
{  
  if (ECLKDIV_EDIVLD && EEPROM_ValidateAddress((void * const)address))
  {      
    /* clear PVIOL and ACCERR flags */
    ESTAT = ESTAT_PVIOL_MASK | ESTAT_ACCERR_MASK;
    while(!ESTAT_CBEIF)
    {
      /* feed watch dog */
      __RESET_WATCHDOG(); 
    }
    EEPROM_WORD(address) = data;
    ECMD = command;
    ESTAT = ESTAT_CBEIF_MASK;
    if (!ESTAT_PVIOL && !ESTAT_ACCERR)
    {
      while(!ESTAT_CCIF)
      {
        /* feed watchdog */
        __RESET_WATCHDOG(); 
      }
      return bTRUE;
    }
  }
  return bFALSE;    
}
示例#2
0
/******************************************************************************
 * Function:        void USB_Remote_Wakeup(void)
 * Input:           None
 * Output:          None
 * Overview:        This function is used to send wake-up signal from device to
 *                  host or hub
 *
 * Note:           According to USB 2.0 specification section 7.1.7.7,
 *                  "The remote wakeup device must hold the resume signaling
 *                  for at lest 1 ms but for no more than 15 ms."
 *****************************************************************************/
void USB_Remote_Wakeup(void)
{
    static word delay_count;

    /*delay to make sure the remote wakeup is generated after 5ms idle*/
    delay_count = 2000; 
     do
     {
       delay_count--;
       __RESET_WATCHDOG();
     }while(delay_count);  
     
    USB_WakeFrom_Suspend();   
     
    CTL_CRESUME = 1;          /* Start RESUME signaling*/
       
    delay_count = 5000;       /* Set RESUME line for 1-15 ms*/
     do
     {
       delay_count--;
       __RESET_WATCHDOG();
     }while(delay_count);        
        

    CTL_CRESUME = 0;
}
示例#3
0
void main(void) {
    unsigned char count = 0;
    GPIO_ConfigPinDirection(PORTA,1,INPUT);
    while(!GPIO_ReadPin(PORTA,1))
    {
        __RESET_WATCHDOG();
    }



    EnableInterrupts;
    /* include your code here */



    //Para el serial
    SCIBD = 26;
    SCIC2 = 0x0C;

    //Para el ADC
    //APCTL1 = 0x01; //Este si

    //ADCCFG = 0xA0;
    //ADCSC1 = 0x40; //Este si


    count = 0;
    voltage[3] = 0x31;
    voltage[2] = 0x31;
    voltage[0] = 0x31;

    do
    {
        do
        {
            __RESET_WATCHDOG();

        }
        while(!SCIS1_TC);
        SCID = voltage[count];
        count++;

    }
    while(count<5);




    for(;;) {
        __RESET_WATCHDOG();	/* feeds the dog */

    } /* loop forever */
    /* please make sure that you never leave main */
}
示例#4
0
/*********************************************************
* Name: SPI_Send_byte
* Desc: Send one byte 
* Parameter: The byte to be sent
* Return: None
**********************************************************/
void SPI_Send_byte(uint_8 u8Data)
{
    while(!SPI1S_SPTEF)
    {
        __RESET_WATCHDOG();
    }
    (void)SPI1S;
    SPI1DL=u8Data;
    while(!SPI1S_SPRF)
    {
        __RESET_WATCHDOG();
    }
    (void)SPI1DL;
}
示例#5
0
void System_Time(void)
{
   // task setup
   INT8U i = 0;
   INT8U cnt = 0;
   
   OSResetTime();
  
   // task main loop
   for (;;)
   {
      #if (WATCHDOG == 1)
        __RESET_WATCHDOG();
      #endif
      
      DelayTask(10);
      i++;
      
      VerifyNeighbourhoodLastIDTimeout();
      
      if (i >= 100)
      {
        OSUpdateUptime();
        i = 0;
      }
   }
}
示例#6
0
/******************************************************************************
 * Function:        unsigned char USB_WakeUp()
 * Input:          
 * Output:          0: noise, re-entern into sleep
 *                  1: Bus wake-up
 *                  2: remote wake up
 * Overview:        The USB sleep and wake up
 * Note:            None
 *****************************************************************************/
 unsigned char USB_WakeUp(void )
 {
    int delay_count;
    
    USBCTL0_USBRESMEN = 1;
    asm STOP;                                /*MCU enter into stop3*/
    
    if(Usb_State_Flag & WAKE_UP_BY_RESET) 
    {
      //Usb_Device_State = DEFAULT_STATE;
      Usb_State_Flag &= (~WAKE_UP_BY_RESET); 
      return 3;
    }
    
    
                                        /*add delay to filter the noise */
       if(USBCTL0_LPRESF)
          USBCTL0_USBRESMEN =0 ;
        
        delay_count = 50;               
        do
         {
           delay_count--;
           __RESET_WATCHDOG();
         }while(delay_count);        
        
        if(INTSTAT_RESUMEF)                  /*The resume signal has engouh time to set RESUMEF bit*/
        {
            return 1;                        /*USB resume*/
        }
        else
            return 0;                        /*resume is caused by noise*/
        
   
}      
示例#7
0
void SD_Write_Block(PTR_LBA_APP_STRUCT lba_data_ptr)
{
    /* Body */
    uint_32 u32Counter;
    SPI_set_SS();
    gu8SD_Argument.lword = lba_data_ptr->offset; 
    if(SD_SendCommand(SD_CMD24|0x40,SD_OK))
    {
        SPI_clr_SS() ;
        return;   /* Command IDLE fail */
    } /* EndIf */
    SPI_Send_byte(0xFE);
    for(u32Counter=0;u32Counter<lba_data_ptr->size;u32Counter++)  
    {
        SPI_Send_byte(*(lba_data_ptr->buff_ptr + u32Counter));
    } /* EndFor */
    SPI_Send_byte(0xFF);    /* checksum Bytes not needed */
    SPI_Send_byte(0xFF);
    if((SPI_Receive_byte() & 0x0F) != 0x05)
    {
        SPI_clr_SS() ;
        return;     /* Command fail */
    } /* EndIf */
    while(SPI_Receive_byte()==0x00)
    {
        __RESET_WATCHDOG();   /* Dummy SPI cycle */
    } /* EndWhile */
    SPI_clr_SS() ;
    return;
} /* EndBody */
示例#8
0
void _Entry(void)
{

/* Check if bootloader flasher is enable */
#if (defined BOOTLOADER_ENABLE) && (BOOTLOADER_ENABLE == 1) 
#include "MCF51_Bootloader.h"
            
  unsigned int status_prog;
    
    
/* check flag status (@STATUS_ADDR address) which indicate where to go:
 bootloader mode or application (main) mode */ 
    
  status_prog = *(dword *) STATUS_ADDR;   

    
  __RESET_WATCHDOG();

 
  // decide which mode to go: user code or bootloader 
  if(status_prog != BOOTLOADER_ENTER_FLAG) 
  {
     asm (JMP MAIN_ENTRY_POINT);      // jump to user entry       
  }  
  else 
  {
示例#9
0
文件: tarefas.c 项目: monkaco/BRTOS
void System_Time(void)
{
   // task setup
   INT16U i = 0;

   OSResetTime();
   Init_Calendar();

   // task main loop
   for (;;)
   {
      #if (WATCHDOG == 1)
        __RESET_WATCHDOG();
      #endif

      DelayTask(10);
      i++;

      if (i >= 100)
      {
        i = 0;
        OSUpdateUptime();
        OSUpdateCalendar();
      }
   }
}
示例#10
0
//Programa que envia valor de ADC por serial
interrupt 19 void AdcISR(void)
{
    unsigned char count = 0;
    unsigned int Adc;
    ADCSC1 = 0x20;
    Adc = (unsigned int)ADCRL;


    //Al leer, se apaga la bandera
    Adc = (Adc*13);
    Adc /= 10;
    voltage[3] = (Adc%10) + 0x30;
    Adc /= 10;
    voltage[2] = (Adc%10) + 0x30;
    voltage[0] = (Adc/10) + 0x30;

    do
    {
        do
        {
            __RESET_WATCHDOG();

        }
        while(!SCIS1_TDRE);
        SCID = voltage[count];
        count++;
        /*while(!GPIO_ReadPin(PORTA,1))
        {
        	__RESET_WATCHDOG();
        }*/
    }
    while(count<5);
    ADCSC1 = 0x20;
}
示例#11
0
UINT8 SD_ReadSector(UINT32 u32SD_Block,UINT8 pu8DataPointer[]) {
  volatile UINT8 u8Temp = 0;

  __RESET_WATCHDOG(); /* feeds the dog */
	
  if (!gSDCard.SDHC) u32SD_Block <<= SD_BLOCK_SHIFT;
     
  SPI_SS = ENABLE;
  //Utilizo u8Temp para capturar respuesta de la tarjeta SD (fines depurativos)
  u8Temp = SD_SendCommand(SD_CMD17_READ_BLOCK, u32SD_Block, NULL, 0); 
  if((u8Temp & SD_R1_ERROR_MASK) != SD_OK) {
    SPI_SS = DISABLE;    
    return (SD_FAIL_READ);
  }
  
	while(u8Temp != 0xFE) u8Temp = SPI_ReceiveByte(); 
	//La SD responde 0xFF...0xFF mientras accede al sector y 0xFE cuando esta lista. 
	//Los datos que envía a continuación corresponden al sector solicitado. 
	
  if (SD_ReadData(pu8DataPointer,SD_BLOCK_SIZE) != SD_OK) return (SD_FAIL_READ);
  
  SPI_SS = DISABLE;
  
  return (SD_OK);
}
示例#12
0
void main(void) {

	EnableInterrupts;
	SerialManager_Init();
	Bootloader_FlashErase(address);
	/* include your code here */
	for(;;) {
		SerialManager_GetValue(&u8new_data, &data_byte, &u8complete_data, &finish_write);
		__RESET_WATCHDOG();	/* feeds the dog */
		if((u8new_data == 1) && (u8complete_data==1))
		{
			FCDIV = u8mask_write;
			if(TRUE){
				u8error=Bootloader_FlashWrite(address,&data_byte,1);
				address++;
			}
		}
		if(finish_write)
		{
			__asm{
				JMP address;
			}
		}
	} /* loop forever */
	/* please make sure that you never leave main */
}
示例#13
0
/*********************************************************
* Name: SPI_Send_byte
* Desc: Send one byte 
* Parameter: The byte to be sent
* Return: None
**********************************************************/
void SPI_Send_byte(uint_8 u8Data)
{
   
   if (SPI_SS) SPI_SS &= ~ENABLE; 
    while(!(SPI0_S & SPI_S_SPTEF_MASK))
    {
        __RESET_WATCHDOG();
    }
    (void)SPI0_S;
    SPI0_DL=u8Data;
    while(!(SPI0_S & SPI_S_SPRF_MASK))
    {
        __RESET_WATCHDOG();
    }
    
    (void)SPI0_DL;
}
示例#14
0
/*********************************************************
* Name: SPI_Receive_byte
* Desc: The byte received by SPI  
* Parameter: None
* Return: Received byte
**********************************************************/
uint_8 SPI_Receive_byte(void)
{
    SPI0_DL = 0xFF;
    while(!(SPI0_S & SPI_S_SPRF_MASK))
    {
        __RESET_WATCHDOG();
    }
    return(SPI0_DL);
}
示例#15
0
void main(void)
{
  USB_STATUS      status = USB_OK;

   
   /* Initialize the current platform. Call for the _bsp_platform_init which is specific to each processor family */
   _bsp_platform_init();
   sci1_init();
   sci2_init();
   IIC_ModuleInit();
   TimerInit();    

   DisableInterrupts;   
	/* enable interrupt OTG module */	           
	 Int_Ctl_int_init(IRQ3_INT_CNTL, IRQ3_ISR_SRC, 2,2, TRUE); 
	 MCF_EPORT_EPPAR   |= MCF_EPORT_EPPAR_EPPA3_FALLING; /* falling edge */
	 MCF_EPORT_EPDDR	&= ~MCF_EPORT_EPDDR_EPDD3; /* set input*/
	 MCF_EPORT_EPIER   |= MCF_EPORT_EPIER_EPIE3;	/* enable interrupts IRQ 3 */  
	  /* set VHost pin ( PUC3) */	 
	 
	 MCF_GPIO_DDRUC  |= MCF_GPIO_DDRUC_DDRUC3; /* set output */
	 MCF_GPIO_PUCPAR  |= MCF_GPIO_PUCPAR_UCTS2_GPIO; /* set as GPIO */
	 ENABLE_USB_5V;
   status = _usb_otg_init(0, (OTG_INIT_STRUCT*)&otg_init, &otg_handle);
   if(status == USB_OK)
   {   
	   status = _usb_otg_register_callback(otg_handle, App_OtgCallback);
   }	   
 	
   EnableInterrupts;
   #if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
   usb_int_en();
   #endif	  

   printf("\n\rInitialization passed. Plug-in MSD device to USB port");
   printf("\n\rPress P to print the menu:");
   
   for(;;) 
   {      
     _usb_otg_task();
	 
	   if(dev_stack_active)
	   {	      
       App_PeripheralTask();
	   }
	   if(host_stack_active)
	   {
	     App_Host_Task();
	   }
      
      App_HandleUserInput();
      __RESET_WATCHDOG(); /* feeds the dog */     
      
      
  } /* loop forever */
  /* please make sure that you never leave main */
}
示例#16
0
文件: main.c 项目: mildrock/batteryMs
void main(void) {
  EnableInterrupts;
  /* include your code here */

  for(;;) {
    __RESET_WATCHDOG();	/* feeds the dog */
  } /* loop forever */
  /* please make sure that you never leave main */
}
示例#17
0
/**
 * Execute Flash command at runtime: must run at another FLASH block 
 * that is being modified. Usually from RAM
 * @param flash address to modify
 * @param flash number of longwords to modify
 * @param flash data pointer
 * @param flash command  
 * @return none
 */
__relocate_code__
uint8 /*far*/ 
Flash_Cmd(uint32 FlashAddress, 
          uint16 FlashDataCounter, 
          uint32 *pFlashDataPtr, 
          uint8 FlashCommand)
{
    /* Check to see if FACCERR or PVIOL is set */
    if (FSTAT&0x30)  
    {         
        /* Clear Flags if set*/
        FSTAT = 0x30;  
    }

    if (FlashDataCounter)
    {
      do
      {
          /* Wait for the Last Busrt Command to complete */
          while(!(FSTAT&FSTAT_FCBEF_MASK))
          {
            __RESET_WATCHDOG(); /* feeds the dog */
          }/*wait until termination*/
          
          /* Write Data into Flash*/
          (*((volatile unsigned long *)(FlashAddress))) = *pFlashDataPtr;
          FlashAddress += 4;
          pFlashDataPtr++;
          
          /* Write Command */
          FCMD = FlashCommand;
          
          /* Put FCBEF at 1 */
          FSTAT = FSTAT_FCBEF_MASK;
          
          asm(nop);
          asm(nop);
          asm(nop);
          asm(nop);
          
          /* Check if Flash Access Error or Protection Violation Error are Set */
          if (FSTAT&0x30)
          {     
            /* If so, finish the function returning 1 to indicate error */
            return (1);
          }
          
      }while (--FlashDataCounter);
    }
    /* wait for the last command to complete */
    while ((FSTAT&FSTAT_FCCF_MASK)==0)
    ;/*wait until termination*/
    
    /* Return zero to indicate that the function executed OK */
    return (0);
}
示例#18
0
/*********************************************************
* Name: SPI_Receive_byte
* Desc: The byte received by SPI  
* Parameter: None
* Return: Received byte
**********************************************************/
uint_8 SPI_Receive_byte(void)
{
    SPI1DL=0xFF;
    while(!SPI1S_SPRF)
    {
        __RESET_WATCHDOG();
    }

    return(SPI1DL);
}
示例#19
0
void main(void) {
	
  KeyboardManager_Init();
  EnableInterrupts;

  for(;;) {
	  __RESET_WATCHDOG();	/* feeds the dog */
  } /* loop forever */
  /* please make sure that you never leave main */
}
char TERMIO_GetChar()
{
    int ch;

    do {
        __RESET_WATCHDOG();
        ch = xbee_ser_getchar( &HOST_SERIAL_PORT);
    } while (ch < 0);

    return (char) ch;
}
示例#21
0
文件: main.c 项目: ninux/mc
/**
 * main program
 */  
void main(void) 
{
    EnableInterrupts;       // Interrupts aktivieren

    for(;;) 
    {   
      __RESET_WATCHDOG();  /* feeds the dog */
    }
    
  /* please make sure that you never leave main */
}
示例#22
0
void main(void) 
#endif
{
    USB_STATUS status = USB_OK;
    /* Initialize the current platform. Call for the _bsp_platform_init which is specific to each processor family */
    _bsp_platform_init();
    #ifdef MCU_MK70F12
        sci2_init();
    #else
        sci1_init();
    #endif
    TimerInit();
    
    /* Init polling global variable */
    POLL_init();
    DisableInterrupts;
    
    status = _usb_host_init(HOST_CONTROLLER_NUMBER, /* Use value in header file */
                            MAX_FRAME_SIZE,         /* Frame size per USB spec  */
                            &host_handle);          /* Returned pointer */
    if(status != USB_OK) 
    {
        printf("\nUSB Host Initialization failed! STATUS: 0x%x",(unsigned int) status);
        fflush(stdout);
        exit(1);
    }
    
    /*
    ** Since we are going to act as the host driver, register the driver
    ** information for wanted class/subclass/protocols
    */
    status = _usb_host_driver_info_register(host_handle, (void *)DriverInfoTable);
    if(status != USB_OK) 
    {
        printf("\nUSB Initialization driver info failed! STATUS: 0x%x", status);
        fflush(stdout);      
        exit(1);
    }
    EnableInterrupts;

    printf("\nUSB Printer Host Demo\nWaiting for USB printer to be attached...\n");
    fflush(stdout);
    
    for(;;) 
    {
        Poll();
        Printer_Task(NULL);
        __RESET_WATCHDOG(); /* feeds the dog */
    } /* Loop forever */
    /* Please make sure that you never leave main */
#ifdef __GNUC__
return 0;
#endif
}
示例#23
0
void main(void)
{
	unsigned int u16RpmSpeed;
	char u8RpmSpeed;
	unsigned int u16adcVoltage;
	char u8adcVoltage;
	
	EnableInterrupts;
	SpeedManager_Init();
	DelayManager_Init();
	StepperMotor_Init();
	LcdManager_Init();
	
	sgu8OldSpeedLevel = 0;
	(void)DelayManager_SetDelayBySpeed(0);
	DelayManager_Delay();
	
	for(;;){
		sgu8SpeedLevel = SpeedManager_ReadSpeedLevel(&sgu8AdcValue);
		if(DelayManager_IsBusy() == 0)
		{
			StepperMotor_NextStep();
			sgu8Dir = StepperMotor_RefreshDirection();
			(void)DelayManager_SetDelayBySpeed(sgu8SpeedLevel);
			DelayManager_Delay();
		}
		
		LcdManager_UpdateTask();
		if((sgu8SpeedLevel != sgu8OldSpeedLevel) && (LcdManager_IsBusy() == 0))
		{
			//RPM Speed
			u16RpmSpeed = ((sgu8SpeedLevel+1)*11)+1;
			sgpu8_3bitLcdMsg[0] = (char)(u16RpmSpeed/100) + 0x30;
			u8RpmSpeed = (u16RpmSpeed%100);
			sgpu8_3bitLcdMsg[1] = u8RpmSpeed/10 + 0x30;
			sgpu8_3bitLcdMsg[2] = u8RpmSpeed%10 + 0x30;
			LcdManager_WriteString(1,0,sgpu8_3bitLcdMsg,3);
			
			//ADC value
			/*u16adcVoltage = ((129*sgu8AdcValue)/100);
			sgpu8_3bitLcdMsg[0] = (u16adcVoltage/100) + 0x30;
			u8adcVoltage = (u16adcVoltage%100);
			sgpu8_3bitLcdMsg[1] = u8adcVoltage/10 + 0x30;
			sgpu8_3bitLcdMsg[2] = u8adcVoltage%10 + 0x30;
			LcdManager_WriteString(1,4,sgpu8_3bitLcdMsg,3);*/
			
			sgu8OldSpeedLevel = sgu8SpeedLevel;
		}
		__RESET_WATCHDOG();
	}	
} 
示例#24
0
void SerialReset(INT8U Comm)
{
	INT8U reset1 = 0;
	INT8U reset2 = 0;

	reset1 = SRS / 100;
	putcharSer(Comm, reset1 + '0');

	reset2 = ((SRS - reset1 * 100) / 10);
	putcharSer(Comm, reset2 + '0');

	reset1 = ((SRS - reset1 * 100 - reset2 * 10) % 10);
	putcharSer(Comm, reset1 + '0');
	putcharSer(Comm, LF);
	putcharSer(Comm, CR);
	__RESET_WATCHDOG();
}
示例#25
0
void main(void)
#endif
{       
    /* Initialize the current platform. Call for the _bsp_platform_init which is specific to each processor family */
    _bsp_platform_init();
#ifdef MCU_MK70F12
    sci2_init();
#else
    sci1_init();
#endif
    TimerInit();
    
   /* Init polling global variable */
   POLL_init();

    /* event for USB callback signaling */
    _usb_event_init(&USB_Event);   
  
    DisableInterrupts; 
    #if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
    usb_int_dis();
    #endif	
    ApplicationInit();
	EnableInterrupts;
    #if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
    usb_int_en();
    #endif		
    
    fflush(stdout);
	
	/*
     ** Infinite loop, waiting for events requiring action
     */
    for(;;) 
    {
      Poll();
      Main_App_Task();
      __RESET_WATCHDOG(); /* feeds the dog */
    }  
#ifdef __GNUC__
    return 0;
#endif
}
示例#26
0
void main(void) {
	unsigned char counter;
	EnableInterrupts;
	MCU_init();
	
	/* include your code here */
	//3. Disable interrupts to permit execution of the code
	DisableInterrupts;

	//4. Cycle that writes a byte form value 0 to 127
	Erase(0x3200);
	for(counter=0;counter<=127;counter++)
	{
		Program(0x3200 + counter, counter);
	}
	for(;;) {
		__RESET_WATCHDOG();	/* feeds the dog */
	} /* loop forever */
	/* please make sure that you never leave main */
}
示例#27
0
文件: main.c 项目: mistyrain83/seos
void main(void)
{
    /* include your code here */
    // Disable COP
    SOPT1_COPT = 0b00;
    board_init();       // initialise multi-purpose clock generator
    led_init(); // initialise led pin settings
    //relay_init();
    //sci_init();
    seos_tpm_init();
    //relay_on();
    EnableInterrupts;
    
    for (;;)
    {
        __RESET_WATCHDOG(); // feeds the dog
        seos_goto_sleep();
    } /* loop forever */
    
    /* please make sure that you never leave main */
}
示例#28
0
void main(void) {
	unsigned char state = 0;
	unsigned char cuenta = 0;
  EnableInterrupts;
  /* include your code here */ 
  for(;;) {
	state = 0;
	while(cuenta < 250)
	{
		cuenta++;
	}
	state = 1;
	cuenta = 0;
	while(cuenta < 250)
	{
		cuenta++;
	}
    __RESET_WATCHDOG();	/* feeds the dog */
  } /* loop forever */
  /* please make sure that you never leave main */
}
示例#29
0
uint_8 SD_Init(void) 
{
    /* Body */
    SPI_Init();                 /* SPI Initialization */
    SPI_set_SS();
    SD_CLKDelay(10);            /* Send 80 clocks  */
    SPI_clr_SS() ;
    gu8SD_Argument.lword = 0;
    SD_CLKDelay(8);  
    /* IDLE Command */
    SPI_set_SS();
    if(SD_SendCommand(SD_CMD0|0x40,SD_IDLE))
    {
        SPI_clr_SS() ;
        return(1);          /* Command IDLE fail */
    } /* EndIf */
    SPI_clr_SS() ;
    (void)SPI_Receive_byte();   /* Dummy SPI cycle */
    /*  Initialize SD Command */
    SPI_set_SS();
    while(SD_SendCommand(SD_CMD1|0x40,SD_OK))
    {
        __RESET_WATCHDOG();
    } /* EndWhile */
    SPI_clr_SS() ;
    (void)SPI_Receive_byte();  /* Dummy SPI cycle */
    /*  Block Length */
    SPI_set_SS();
    gu8SD_Argument.lword = SD_BLOCK_SIZE;
    if(SD_SendCommand(SD_CMD16|0x40,SD_OK))
    {
        SPI_clr_SS() ;
        return(1);      /* Command IDLE fail */
    } /* EndIf */
    SPI_clr_SS() ;
    SPI_High_rate();
    SPI_Send_byte(0x00);
    SPI_Send_byte(0x00);
    return(0);
} /* EndBody */
示例#30
0
文件: main.c 项目: turcoale/monofan
void main(void) 
{
   /* Port F Bit 1 active when error occurs */
   PTFDD |= 0x01;
   PTFD |= 0x01;

   EnableInterrupts;

   flash_init();
  
   copyinRAM();                       /* Copy flash routine to RAM */
  
   if (flash_erase( 0xF800))          /* Erase flash sector */
      PTFD &= ~0x01;
   if (flash_program( 0xF800, data))  /* Program single byte*/
      PTFD &= ~0x01;
  
  for( ; ; ) {
    __RESET_WATCHDOG();

  }  /* Loop always */
}