Exemplo n.º 1
0
BYTE PHYGetLongRAMAddr(WORD address)
{
    BYTE toReturn;
    
    #if defined(__C30__)
        IntStatus.CCP2IntF = RFIE;
        RFIE = 0;
    	PHY_CS = 0;
        SPIPut(((address>>3)&0b01111111)|0x80);
        SPIPut(((address<<5)&0b11100000));
        toReturn = SPIGet();
        PHY_CS = 1;	
        RFIE = IntStatus.CCP2IntF;
    #else    
        IntStatus.CCP2IntF = RFIE;
        RFIE = 0;
        PHY_CSn = 0;
        NOP();
        SPIPut(((address>>3)&0b01111111)|0x80);
        SPIPut(((address<<5)&0b11100000));
        toReturn = SPIGet();
        NOP();
        PHY_CSn = 1;
        RFIE = IntStatus.CCP2IntF;
    #endif    
    return toReturn;
}
Exemplo n.º 2
0
/************************************************************************
* Function: BYTE SST25ReadByte(DWORD address)             
*                                                                       
* Overview: this function reads a byte from the address specified         
*                                                                       
* Input: address                                                     
*                                                                       
* Output: data read
*                                                                       
************************************************************************/
BYTE SST25ReadByte(DWORD address)
{
    BYTE    temp;
    
    while(!SPILock(spiInitData.channel))
        ;
    
    DRV_SPI_Initialize(spiInitData.channel, (DRV_SPI_INIT_DATA *)&spiInitData);

    SST25CSLow();

    SPIPut(spiInitData.channel, SST25_CMD_READ);
    SPIGet(spiInitData.channel);

    SPIPut(spiInitData.channel, ((DWORD_VAL) address).v[2]);
    SPIGet(spiInitData.channel);

    SPIPut(spiInitData.channel, ((DWORD_VAL) address).v[1]);
    SPIGet(spiInitData.channel);

    SPIPut(spiInitData.channel, ((DWORD_VAL) address).v[0]);
    SPIGet(spiInitData.channel);

    SPIPut(spiInitData.channel, 0);
    temp = SPIGet(spiInitData.channel);

    SST25CSHigh();

    SPIUnLock(spiInitData.channel);

    return (temp);
}
Exemplo n.º 3
0
/************************************************************************
* Function: void SST25WriteByte(BYTE data, DWORD address)                                           
*                                                                       
* Overview: this function writes a byte to the address specified
*                                                                       
* Input: data to be written and address
*                                                                       
* Output: none                                 
*                                                                       
************************************************************************/
void SST25WriteByte(BYTE data, DWORD address)
{
   // SST25SectorErase(address);
	//DelayMs(100);	
    SST25WriteEnable();
    SST25SSLow();

    SPIPut(SST25_CMD_WRITE);
    SPIGet();

    SPIPut(((DWORD_VAL) address).v[2]);
    SPIGet();

    SPIPut(((DWORD_VAL) address).v[1]);
    SPIGet();

    SPIPut(((DWORD_VAL) address).v[0]);
    SPIGet();

    SPIPut(data);
    SPIGet();

    SST25SSHigh();

    // Wait for write end
    while(SST25IsWriteBusy());
}
Exemplo n.º 4
0
BYTE PHYGetShortRAMAddr(BYTE address)
{
    BYTE toReturn;
    	
    #if defined(__C30__)
        IntStatus.CCP2IntF = RFIE;
        RFIE = 0;
    	PHY_CS = 0;
    	SPIPut((address<<1)&0b01111110);
        toReturn = SPIGet();
        PHY_CS = 1;
        RFIE = IntStatus.CCP2IntF;
    #else	
        IntStatus.CCP2IntF = RFIE;
        RFIE = 0;
        PHY_CSn = 0;
        NOP();
        SPIPut((address<<1)&0b01111110);
        toReturn = SPIGet();
        NOP();
        PHY_CSn = 1;
        RFIE = IntStatus.CCP2IntF;
    #endif    
    return toReturn;
}
Exemplo n.º 5
0
/*********************************************************************
* Function:         void ReadMacAddress()
*
* PreCondition:     none
*
* Input:		    none
*
* Output:		    Reads MAC Address from MAC Address EEPROM
*
* Side Effects:	    none
*
* Overview:		    Uses the MAC Address from the EEPROM for addressing
*
* Note:			    
**********************************************************************/
void ReadMacAddress(void)
{
    RF_EEnCS_TRIS = 0;
    {
        uint8_t    Address0, Address1, Address2;
        RF_EEnCS = 0;
        SPIPut(0x03);   //Read Sequence to EEPROM
        SPIPut(0xFA);   //MAC address Start byte
        Address0 = SPIGet();
        Address1 = SPIGet();
        Address2 = SPIGet();
        RF_EEnCS = 1;
        if((Address0 == 0x00) && (Address1 == 0x04) && (Address2 == 0xA3))  //Compare the value against Microchip's OUI
        {
            RF_EEnCS = 0;
            SPIPut(0x03);
            SPIPut(0xFD);
            switch(MY_ADDRESS_LENGTH)
            {
            	case 8: myLongAddress[7] = 0x00;
                case 7: myLongAddress[6] = 0x04;
                case 6: myLongAddress[5] = 0xA3;
                case 5: myLongAddress[4] = 0xFF;
                case 4: myLongAddress[3] = 0xFE;
                case 3: myLongAddress[2] = SPIGet();
                case 2: myLongAddress[1] = SPIGet();
                case 1: myLongAddress[0] = SPIGet();
                        break;
                default: break;
            }
            RF_EEnCS = 1;
        }
    }
}
Exemplo n.º 6
0
/************************************************************************
* Function: void SST25SectorErase(DWORD address)                                           
*                                                                       
* Overview: this function erases a 4Kb sector
*                                                                       
* Input: address within sector to be erased
*                                                                       
* Output: none                                 
*                                                                       
************************************************************************/
void SST25SectorErase(DWORD address)
{
    SST25WriteEnable();
    
    while(!SPILock(spiInitData.channel))
        ;

    DRV_SPI_Initialize(spiInitData.channel, (DRV_SPI_INIT_DATA *)&spiInitData);

    SST25CSLow();

    SPIPut(spiInitData.channel, SST25_CMD_SER);
    SPIGet(spiInitData.channel);

    SPIPut(spiInitData.channel, ((DWORD_VAL) address).v[2]);
    SPIGet(spiInitData.channel);

    SPIPut(spiInitData.channel, ((DWORD_VAL) address).v[1]);
    SPIGet(spiInitData.channel);

    SPIPut(spiInitData.channel, ((DWORD_VAL) address).v[0]);
    SPIGet(spiInitData.channel);

    SST25CSHigh();
    SPIUnLock(spiInitData.channel);

    // Wait for write end
    while(SST25IsWriteBusy());
}
Exemplo n.º 7
0
/************************************************************************
* Function: void SST25ReadArray(DWORD address, BYTE* pData, nCount)
*                                                                       
* Overview: this function reads data into buffer specified
*                                                                       
* Input: flash memory address, pointer to the data buffer, data number
*                                                                       
************************************************************************/
void SST25ReadArray(DWORD address, BYTE *pData, WORD nCount)
{
    while(!SPILock(spiInitData.channel))
        ;

    DRV_SPI_Initialize(spiInitData.channel, (DRV_SPI_INIT_DATA *)&spiInitData);

    SST25CSLow();

    SPIPut(spiInitData.channel, SST25_CMD_READ);
    SPIGet(spiInitData.channel);

    SPIPut(spiInitData.channel, ((DWORD_VAL) address).v[2]);
    SPIGet(spiInitData.channel);

    SPIPut(spiInitData.channel, ((DWORD_VAL) address).v[1]);
    SPIGet(spiInitData.channel);

    SPIPut(spiInitData.channel, ((DWORD_VAL) address).v[0]);
    SPIGet(spiInitData.channel);

    while(nCount--)
    {
        SPIPut(spiInitData.channel, 0);
        *pData++ = SPIGet(spiInitData.channel);
    }

    SST25CSHigh();
    SPIUnLock(spiInitData.channel);
}
Exemplo n.º 8
0
/************************************************************************
* Function: void SST25SectorErase(DWORD address)                                           
*                                                                       
* Overview: this function erases a 4Kb sector
*                                                                       
* Input: address within sector to be erased
*                                                                       
* Output: none                                 
*                                                                       
************************************************************************/
void SST25SectorErase(uint32_t address)
{
    SST25WriteEnable();
    
 //   while(!SPILock(spiInitData.spiId));

    SST25CSLow();

    SPIPut(spiInitData.spiId, SST25_CMD_SER);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SPIPut(spiInitData.spiId, address>>16);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SPIPut(spiInitData.spiId, address>>8);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SPIPut(spiInitData.spiId, address);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SST25CSHigh();
 //   SPIUnLock(spiInitData.spiId);

    // Wait for write end
    while(SST25IsWriteBusy());
}
Exemplo n.º 9
0
/************************************************************************
* Function: BYTE SST25ReadByte(DWORD address)             
*                                                                       
* Overview: this function reads a byte from the address specified         
*                                                                       
* Input: address                                                     
*                                                                       
* Output: data read
*                                                                       
************************************************************************/
uint8_t SST25ReadByte(uint32_t address)
{
    uint8_t    temp;
    
    SST25CSLow();

    SPIPut(spiInitData.spiId, SST25_CMD_READ);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SPIPut(spiInitData.spiId, address>>16);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SPIPut(spiInitData.spiId, address>>8);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SPIPut(spiInitData.spiId, address);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SPIPut(spiInitData.spiId, 0);
    temp = PLIB_SPI_BufferRead(spiInitData.spiId);

    SST25CSHigh();

    return (temp);
}
Exemplo n.º 10
0
/************************************************************************
* Function: void SST25ReadArray(DWORD address, BYTE* pData, nCount)
*                                                                       
* Overview: this function reads data into buffer specified
*                                                                       
* Input: flash memory address, pointer to the data buffer, data number
*                                                                       
************************************************************************/
void SST25ReadArray(uint32_t address, uint8_t *pData, uint16_t nCount)
{

    SST25CSLow();

    SPIPut(spiInitData.spiId, SST25_CMD_READ);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SPIPut(spiInitData.spiId, address>>16);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SPIPut(spiInitData.spiId, address>>8);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SPIPut(spiInitData.spiId, address);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    while(nCount--)
    {
        SPIPut(spiInitData.spiId, 0);
        *pData++ = PLIB_SPI_BufferRead(spiInitData.spiId);
    }

    SST25CSHigh();

}
Exemplo n.º 11
0
/************************************************************************
* Function: void SST25WriteByte(BYTE data, DWORD address)                                           
*                                                                       
* Overview: this function writes a byte to the address specified
*                                                                       
* Input: data to be written and address
*                                                                       
* Output: none                                 
*                                                                       
************************************************************************/
void SST25WriteByte(uint8_t data, uint32_t address)
{
    SST25WriteEnable();

    SST25CSLow();

    SPIPut(spiInitData.spiId, SST25_CMD_WRITE);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SPIPut(spiInitData.spiId, address>>16);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SPIPut(spiInitData.spiId, address>>8);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SPIPut(spiInitData.spiId, address);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SPIPut(spiInitData.spiId, data);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SST25CSHigh();

    // Wait for write end
    while(SST25IsWriteBusy());
}
Exemplo n.º 12
0
Arquivo: hal_radio.c Projeto: gxp/node
uint8  CC2420_WriteRegister(uint8 addr, uint16 data)
{
	uint8 status;
	MAKE_CC_CS_LOW();
	status = SPIPut(addr);
	status = SPIPut(data>>8);
	status = SPIPut(data);
	MAKE_CC_CS_HIGH();
	return status;
}
Exemplo n.º 13
0
/************************************************************************
* Function: void SST25ResetWriteProtection()
*                                                                       
* Overview: this function reset write protection bits
*                                                                       
* Input: none                                                     
*                                                                       
* Output: none
*                                                                       
************************************************************************/
void SST25ResetWriteProtection(void)
{
#if defined(USE_M25P80)    
    BYTE status;
#endif

    while(!SPILock(spiInitData.channel))
        ;
    
    DRV_SPI_Initialize(spiInitData.channel, (DRV_SPI_INIT_DATA *)&spiInitData);

    SST25CSLow();
    
    // send write enable command
    SPIPut(spiInitData.channel, SST25_CMD_EWSR);
    SPIGet(spiInitData.channel);
	
    SST25CSHigh();
	
#if defined(USE_M25P80)    
    SST25CSLow();
    // verify if the WEL bit is set high
    while(1)
    {
        SPIPut(spiInitData.channel, SST25_CMD_RDSR);
        SPIGet(spiInitData.channel);

        status = 0xFF;
        while((status & SST25_STATUS_MASK) > 0)
        {
            SPIPut(spiInitData.channel, 0);
            status = SPIGet(spiInitData.channel);
        }
        if ((status & SST25_WEL_STATUS) == SST25_WEL_STATUS)
            break;
    }
    SST25CSHigh();
#endif


    SST25CSLow();

    SPIPut(spiInitData.channel, SST25_CMD_WRSR);
    SPIGet(spiInitData.channel);

    SPIPut(spiInitData.channel, 0);
    SPIGet(spiInitData.channel);

    SST25CSHigh();
    SPIUnLock(spiInitData.channel);

    // Wait for write end
    while(SST25IsWriteBusy());
}
Exemplo n.º 14
0
 void LCDWritePortB(BYTE v)
 {
     BYTE preRFIE = RFIE;
     RFIE = 0;
     LCD_CS = 0;
     SPIPut(0x40);
     SPIPut(0x13);
     SPIPut(v);
     LCD_CS = 1;
     RFIE = preRFIE;
 }
Exemplo n.º 15
0
 void LCDInitPortB(void)
 {
     BYTE preRFIE = RFIE;
     RFIE = 0;
     LCD_CS = 0;
     SPIPut(0x40);
     SPIPut(0x01);
     SPIPut(0x00);
     LCD_CS = 1;
     RFIE = preRFIE;
 }
Exemplo n.º 16
0
Arquivo: hal_radio.c Projeto: gxp/node
void CC2420_FlushRxFIFO()
{
	MAKE_CC_CS_LOW();
	SPIPut(CC2420_RXFIFO | 0x40);
	SPIGet();
	MAKE_CC_CS_HIGH();
	MAKE_CC_CS_LOW();
	SPIPut(CC2420_SFLUSHRX);
    SPIPut(CC2420_SFLUSHRX);
    MAKE_CC_CS_HIGH();
}
Exemplo n.º 17
0
void LCDWritePortB(uint8_t v)
{
    uint8_t preRFIE = RFIE;
    RFIE = 0;
    LCD_CS = 0;
    SPIPut(0x40);
    SPIPut(0x13);
    SPIPut(v);
    LCD_CS = 1;
    RFIE = preRFIE;
}
Exemplo n.º 18
0
void LCDInitPortA(void)
{
    uint8_t preRFIE = RFIE;
    RFIE = 0;
    LCD_CS = 0;
    SPIPut(0x40);
    SPIPut(0x00);
    SPIPut(0x00);
    LCD_CS = 1;
    RFIE = preRFIE;
}
Exemplo n.º 19
0
  void EEPROMRead(uint8_t *dest, uint8_t addr, uint8_t count)
  {   
      EE_nCS = 0;
      SPIPut(SPI_READ);
      SPIPut(addr);
      while( count )
      {
          *dest++ = SPIGet();
          count--;
      }
      EE_nCS = 1;     
 
  }
Exemplo n.º 20
0
/************************************************************************
* Function: void SST25ResetWriteProtection()
*                                                                       
* Overview: this function reset write protection bits
*                                                                       
* Input: none                                                     
*                                                                       
* Output: none
*                                                                       
************************************************************************/
void SST25ResetWriteProtection(void)
{
#if defined(USE_M25P80)    
    uint8_t status;
#endif

 //   while(!SPILock(spiInitData.spiId));
   
    SST25CSLow();
    
    // send write enable command
    SPIPut(spiInitData.spiId, SST25_CMD_EWSR);
    PLIB_SPI_BufferRead(spiInitData.spiId);
	
    SST25CSHigh();
	
#if defined(USE_M25P80)    
    SST25CSLow();
    // verify if the WEL bit is set high
    while(1)
    {
        SPIPut(spiInitData.spiId, SST25_CMD_RDSR);
        SPIGet(spiInitData.spiId);

        status = 0xFF;
        while((status & SST25_STATUS_MASK) > 0)
        {
            SPIPut(spiInitData.spiId, 0);
            status = SPIGet(spiInitData.spiId);
        }
        if ((status & SST25_WEL_STATUS) == SST25_WEL_STATUS)
            break;
    }
    SST25CSHigh();
#endif


    SST25CSLow();

    SPIPut(spiInitData.spiId, SST25_CMD_WRSR);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SPIPut(spiInitData.spiId, 0);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SST25CSHigh();
 //   SPIUnLock(spiInitData.spiId);

    // Wait for write end
    while(SST25IsWriteBusy());
}
Exemplo n.º 21
0
/************************************************************************
* Function: BYTE SST25IsWriteBusy(void)  
*                                                                       
* Overview: this function reads status register and chek BUSY bit for write operation
*                                                                       
* Input: none                                                          
*                                                                       
* Output: non zero if busy
*                                                                       
************************************************************************/
uint8_t SST25IsWriteBusy(void)
{
    uint8_t    temp;

    SST25CSLow();
    SPIPut(spiInitData.spiId, SST25_CMD_RDSR);
    PLIB_SPI_BufferRead(spiInitData.spiId);

    SPIPut(spiInitData.spiId, 0);
    temp = PLIB_SPI_BufferRead(spiInitData.spiId);
    SST25CSHigh();

    return (temp & 0x01);
}
Exemplo n.º 22
0
/************************************************************************
* Function: BYTE SST25IsWriteBusy(void)  
*                                                                       
* Overview: this function reads status register and chek BUSY bit for write operation
*                                                                       
* Input: none                                                          
*                                                                       
* Output: non zero if busy
*                                                                       
************************************************************************/
BYTE SST25IsWriteBusy(void)
{
    BYTE    temp;

    SST25SSLow();
    SPIPut(SST25_CMD_RDSR);
    SPIGet();

    SPIPut(0);
    temp = SPIGet();
    SST25SSHigh();

    return (temp & 0x01);
}
Exemplo n.º 23
0
/************************************************************************
* Function: MCHP25LC256ReadStatus()                                          
*                                                                       
* Overview: this function reads status register
*                                                                       
* Input: none                                                          
*                                                                       
* Output: status register value
*                                                                       
************************************************************************/
union _MCHP25LC256Status_ MCHP25LC256ReadStatus(void)
{
    BYTE    temp;

    MCHP25LC256CSLow();
    SPIPut(MCHP25LC256_spi_channel, EEPROM_CMD_RDSR);
    SPIGet(MCHP25LC256_spi_channel);

    SPIPut(MCHP25LC256_spi_channel, 0);
    temp = SPIGet(MCHP25LC256_spi_channel);
    MCHP25LC256CSHigh();

    return (union _MCHP25LC256Status_)temp;
}
Exemplo n.º 24
0
Arquivo: hal_radio.c Projeto: gxp/node
void CC2420_Restart()
{
	uint8 status;
	status = CC2420_StrobCmd(CC2420_SXOSCON);
	while (!(status & 0x40))
	{
		//CC2420_StrobCmd(CC2420_SXOSCOFF);
		status = CC2420_StrobCmd(CC2420_SXOSCON);
	}
	status = CC2420_StrobCmd(CC2420_SRXON);
	MAKE_CC_CS_LOW();
	SPIPut(CC2420_SFLUSHRX);
	SPIPut(CC2420_SFLUSHRX);
	MAKE_CC_CS_HIGH();
}
Exemplo n.º 25
0
/************************************************************************
* Function: BYTE SST25WriteArray(DWORD address, BYTE* pData, nCount)
*                                                                       
* Overview: this function writes a data array at the address specified
*                                                                       
* Input: flash memory address, pointer to the data array, data number
*                                                                       
* Output: return 1 if the operation was successfull
*                                                                     
************************************************************************/
uint8_t SST25WriteArray(uint32_t address, uint8_t *pData, uint16_t nCount)
{
    uint32_t   addr;
    uint8_t    *pD;
    uint16_t    counter;
#if defined(USE_M25P80)    
    uint8_t status;
#endif

    addr = address;
    pD = pData;

    // WRITE
    for(counter = 0; counter < nCount; counter++)
    {
        SST25WriteByte(*pD++, addr++);
    }

#if defined(USE_M25P80)

    // check status of Write in Progress
    // wait for BULK ERASE to be done
    SST25CSLow();
    SPIPut(spiInitData.spiId, SST25_CMD_RDSR);
    SPIGet(spiInitData.spiId);
    while(1)
    {
        SPIPut(spiInitData.spiId, 0);
        status = (SPIGet(spiInitData.spiId)& SST25_WIP_STATUS);
        if ((status & SST25_WIP_STATUS) == 0)
            break;
    }

    SST25CSHigh();
	
#endif

    // VERIFY
    for(counter = 0; counter < nCount; counter++)
    {
        if(*pData != SST25ReadByte(address))
            return (0);
        pData++;
        address++;
    }

    return (1);
}
Exemplo n.º 26
0
/************************************************************************
* Function: BYTE SST25WriteArray(DWORD address, BYTE* pData, nCount)
*                                                                       
* Overview: this function writes a data array at the address specified
*                                                                       
* Input: flash memory address, pointer to the data array, data number
*                                                                       
* Output: return 1 if the operation was successfull
*                                                                     
************************************************************************/
BYTE SST25WriteArray(DWORD address, BYTE *pData, WORD nCount)
{
    DWORD   addr;
    BYTE    *pD;
    WORD    counter;
#if defined(USE_M25P80)    
    BYTE status;
#endif

    addr = address;
    pD = pData;

    // WRITE
    for(counter = 0; counter < nCount; counter++)
    {
        SST25WriteByte(*pD++, addr++);
    }

#if defined(USE_M25P80)

    // check status of Write in Progress
    // wait for BULK ERASE to be done
    SST25CSLow();
    SPIPut(spiInitData.channel, SST25_CMD_RDSR);
    SPIGet(spiInitData.channel);
    while(1)
    {
        SPIPut(spiInitData.channel, 0);
        status = (SPIGet(spiInitData.channel)& SST25_WIP_STATUS);
        if ((status & SST25_WIP_STATUS) == 0)
            break;
    }

    SST25CSHigh();
	
#endif

    // VERIFY
    for(counter = 0; counter < nCount; counter++)
    {
        if(*pData != SST25ReadByte(address))
            return (0);
        pData++;
        address++;
    }

    return (1);
}
Exemplo n.º 27
0
/************************************************************************
* Function: MCHP25LC256WriteEnable()                                         
*                                                                       
* Overview: this function allows write/erase MCHP25LC256. Must be called  
* before every write/erase command.                                         
*                                                                       
* Input: none                                                          
*                                                                       
* Output: none                                 
*                                                                       
************************************************************************/
void MCHP25LC256WriteEnable(void)
{
    MCHP25LC256CSLow();
    SPIPut(MCHP25LC256_spi_channel, EEPROM_CMD_WREN);
    SPIGet(MCHP25LC256_spi_channel);
    MCHP25LC256CSHigh();
}
Exemplo n.º 28
0
/************************************************************************
* Function: SST25WriteEnable()                                         
*                                                                       
* Overview: this function allows write/erase SST25. Must be called  
* before every write/erase command.                                         
*                                                                       
* Input: none                                                          
*                                                                       
* Output: none                                 
*                                                                       
************************************************************************/
void SST25WriteEnable(void)
{
    SST25SSLow();
    SPIPut(SST25_CMD_WREN);
    SPIGet();
    SST25SSHigh();
}
Exemplo n.º 29
0
    void NVMRead (BYTE *dest, WORD  src, BYTE count)
    {
        #if !defined(__C30__)
        BYTE oldGIEH;
        #endif
        
        #ifdef ENABLE_DEBUG
            ConsolePut('r');
            PrintChar( (BYTE)(((WORD)src>>8)&0xFF) );
            PrintChar( (BYTE)((WORD)src&0xFF) );
            ConsolePut('-');
            PrintChar( count );
        #endif
        #if !defined(__C30__)
            oldGIEH = 0;
            if ( INTCONbits.GIEH )
            {
                oldGIEH = 1;
            }
            INTCONbits.GIEH = 0;
        #endif

        SPISelectEEPROM();
        SPIPut( SPIREAD );
        SPIPut( (BYTE)(((WORD)src>>8) & 0xFF) );
        SPIPut( (BYTE)((WORD)src & 0xFF) );
        while( count )
        {
            *dest = SPIGet();
            #ifdef ENABLE_DEBUG
            #endif
            dest++;
            count--;
        }
        SPIUnselectEEPROM();

        #if !defined(__C30__)
            if (oldGIEH)
            {
                INTCONbits.GIEH = 1;
            }
        #endif

        #ifdef ENABLE_DEBUG
            ConsolePutROMString((ROM char * const)"\r\n");
        #endif
    }
Exemplo n.º 30
0
Arquivo: hal_radio.c Projeto: gxp/node
uint8  CC2420_WriteTxFIFO(uint8 length, uint8* data)
{
	uint8 status;
	uint8 i;

	MAKE_CC_CS_LOW();
	status = SPIPut(CC2420_TXFIFO);
	
	// add another 2 bytes on the data length
	status = SPIPut(length + 2);
	for(i=0; i<length; i++)
	{
		SPIPut(data);
	}
	MAKE_CC_CS_HIGH();
	return status;
}