⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s8051.h

📁 silicon wireless开发套件F920+Si4432原理图,源码
💻 H
字号:
/*
** ============================================================================
**
** FILE
**  S8051.h
**
** DESCRIPTION
**  Contains the 8051 specific declarations, IO declarations, type declarations
**
** CREATED
**  Silicon Laboratories Hungary Ltd
**
** COPYRIGHT
**  Copyright 2008 Silicon Laboratories, Inc.  
**	http://www.silabs.com
**
** ============================================================================
*/
#ifndef S8051_H
#define S8051_H

#include <compiler_defs.h>             // compiler declarations
#include <C8051F930_defs.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


                /* ======================================= *
                 *     T Y P E   D E C L A R A T I O N     *
                 * ======================================= */

//Only these type of variables are used in this software
#undef	uint8
#undef	sint8
#undef	uint16
#undef	sint16
#undef	uint32
#undef	sint32

#define	uint8	unsigned char
#define	sint8	signed char
#define	uint16	unsigned short
#define	sint16	signed short
#define	uint32	unsigned long
#define	sint32	signed long



typedef struct
{
unsigned int bit0 : 1;
unsigned int bit1 : 1;
unsigned int bit2 : 1;
unsigned int bit3 : 1;
unsigned int bit4 : 1;
unsigned int bit5 : 1;
unsigned int bit6 : 1;
unsigned int bit7 : 1;
} reg;

typedef union
{
   reg testreg;
   uint8 adat;
}reg_union;

typedef union
{
   reg_union bytes[2];
   uint16 adat;
}reg16_union;

					                /* ======================================= *
					                 *          D E F I N I T I O N S          *
					                 * ======================================= */
#undef	TRUE
#undef 	FALSE
#undef	INPUT
#undef	OUTPUT

#define TRUE						(1)
#define FALSE						(0)
#define	INPUT						(1)
#define	OUTPUT						(0)

//I/O pin definitions
SBIT(LED1_PIN,		SFR_P1, 4);
SBIT(LED2_PIN,		SFR_P1, 5);
SBIT(LED3_PIN,		SFR_P1, 6);
SBIT(LED4_PIN,		SFR_P1, 7);
SBIT(BLED_PIN,		SFR_P2, 2);
SBIT(PB1_PIN,		SFR_P0, 0);
SBIT(PB2_PIN,		SFR_P0, 1);
SBIT(PB3_PIN,		SFR_P2, 0);
SBIT(PB4_PIN,		SFR_P2, 1);
//RF chip
SBIT(RF_NSEL_PIN,		SFR_P1, 3);
SBIT(RF_NIRQ_PIN,		SFR_P0, 6);
//SPI port
SBIT(SPI_MISO_PIN,		SFR_P1, 1);
SBIT(SPI_MOSI_PIN,		SFR_P1, 2);
SBIT(SPI_SCK_PIN,		SFR_P1, 0);
//Testcard EEPROM
SBIT(EE_NSEL_PIN,		SFR_P2, 6);
//LCD
SBIT(LCD_NSEL_PIN,		SFR_P2, 5);
SBIT(LCD_A0_PIN,		SFR_P2, 3);
SBIT(LCD_RESET_PIN,		SFR_P2, 4);
SBIT(LCD_BL_PIN,		SFR_P2, 7);


#define SYSCLK       			(16000000L/2)        // SYSCLK frequency in Hz
#define	SPI_CLOCK				(SYSCLK/4)
	
#define	EnableGlobalIt()		EA = 1
#define	DisableGlobalIt()		EA = 0

#define RF_NIRQ_PIN				6					//specify into which pin the NIRQ pin is connected
#define	ACTIVE_LOW_IT			0x00
#define ACTIVE_HIGH_IT			0x08
#define LEVEL_TRIGGERED_IT		0x00
#define	EDGE_TRIGGERED_IT		0x01
#define	INT1_SETTINGS			(0x00)				//not used in the current project
#define INT0_SETTINGS			(ACTIVE_LOW_IT | RF_NIRQ_PIN)	
#define INTERRUPT_SETTINGS		(INT1_SETTINGS + INT0_SETTINGS)
#define SetExt0ItFallingEdge()  IT0 = EDGE_TRIGGERED_IT; IT01CF = INTERRUPT_SETTINGS
#define EnableExt0It() 			EX0 = 1; IE0 = 0
#define DisableExt0It()			EX0 = 0; IE0 = 0

								
               				/* ======================================= *
                 			 *  F U N C T I O N   P R O T O T Y P E S  *
                			 * ======================================= */

void SetHwMasterSpi(void);
void SpiWrite(uint8 spi_in);
uint8 SpiReadWrite(uint8 spi_in);
void SpiWriteByte(uint8 spi_in);
void SpiRfWriteWord(UU16 spi_in);
void SpiRfWriteAddressData(uint8 address, uint8 d);
UU16 SpiRfReadWriteWord(UU16 spi_in);
uint8 SpiRfReadRegister(uint8 address);
UU16 SpiRfReadWriteAddressData(uint8 address, uint8 d);
uint8 SpiReadByteFromTestcardEEPROM(uint16 address);
void SpiWriteByteToTestcardEEPROM(uint16 address, uint8 d);
void SpiReadSegmentFromTestcardEEPROM(uint16 start_address, uint8 * d, uint8 length);


#endif 


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -