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

📄 slave.c

📁 是关于KeilC下串口Baudrat设定的。
💻 C
字号:
/*------------------------------------------------------------------------------
;  This file is part of the RLC instruction
;  Copyright (c)
;  Version: 1.0 
;-------------------------------------------------------------------------------
;  Filename:
;  main.c
;  Function:   
;
;  Author:
;  pirate
;     
;  Writedate:
;  Oct.15 2005
;  Moddate(latest):
;  Oct.15 2005
;-------------------------------------------------------------------------------
*/

//--------------------------------------
// Included files
//--------------------------------------
#include <reg51.h>
#include ".\HEAD\dtype.h"
#include ".\HEAD\externf.h"
#include ".\HEAD\sdefine.h"

//--------------------------------------
// Local Definitions and Types
//--------------------------------------

//! the table data
const uchar sequence[] =
{
    0x81, 0x55,
	0x42, 0xC3
};


// struct data
struct date {
    uint year;
	uchar month, day;
};

/*******************************************************************************
/*   
//   Function:    char shift control
//
//!  Description: 
//!               - After a reset and power cycle the crystal is given time to
//!               settle and then it comes out of reset and then the radio is
//!               configured
//!
//!  Inputs:      None
//!
//!  Returns:     newdata
/*
/*******************************************************************************
/*/
void shiftchar()
{
    
    uchar i, j;
    uchar xdata *p = 0x0020;
	uchar data *x = 0x20;
	uchar v;

//	nop();
	// define a struct var
    struct date Bursday = {1979, 01, 05};
	
    for(i = 0; 4 > i; ++i)
	{
	   *p = sequence[i];
	   ++p;
	}

	Nop(1);

	*x = 0x33;
	// shift the value of ACC
	ACC = Bursday.month;
	ACC = 0xFF;
	v = ACC;
	for(j = 0; 8 > j; ++j)
	{
	  v = v & PARAM;
	  *x = v;
	  v = v << 1;
	  ++x;
	}
	*x = 0x99;
}

/*******************************************************************************
/*   
//   Function:    test time of the C instruction
//
//!  Description: 
//!               - After a reset and power cycle the crystal is given time to
//!               settle and then it comes out of reset and then the radio is
//!               configured
//!
//!  Inputs:      x
//!
//!  Returns:     newdata
/*
/*******************************************************************************
/*/
void test()
{
    TEST_PIN = ~TEST_PIN;
}

/*******************************************************************************
/*   
//   Function:    read & write SPI interface
//
//!  Description: 
//!               - After a reset and power cycle the crystal is given time to
//!               settle and then it comes out of reset and then the radio is
//!               configured
//!
//!  Inputs:      dev, address, data
//!
//!  Returns:     newdata
/*
/*******************************************************************************
/*/

/*
uchar spi_access(SPI_DEVICE dev, uchar address, uchar data)
{
#ifdef RADIO_NON_BLOCKING_CALLS
    uchar isr_state = GPIO_ISR_RADIO_IE_PORT;

    RADIO_ISR_DISABLE();
#endif // RADIO_NON_BLOCKING_CALLS

    // Turn high-z back on for MISO
    PRT1DM1 = PORT_1_DRIVE_1;

	// assert the slave select
    if( dev == SPI_RADIO )
    {
        RADIO_PORT &= ~N_SS;
    }
    else
    {
		return(0x00);
    }
	
    // write the select address
	SPIM_TX_BUFFER_REG = address;

    while(!(SPIM_CONTROL_REG & SPIM_SPI_COMPLETE));
	
    // read the data
	SPIM_TX_BUFFER_REG = data;

    while(!(SPIM_CONTROL_REG & SPIM_SPI_COMPLETE));

	// deassert the slave select
    if( dev == SPI_RADIO )
    {
        RADIO_PORT |= N_SS;
    }
    else
    {
		return(0x00);
    }

    // Turn on pull up for MISO to reduce current
    PRT1DM1 = PORT_1_DRIVE_1 & ~MISO_MASK;

    data = SPIM_RX_BUFFER_REG;

#ifdef RADIO_NON_BLOCKING_CALLS
    if( isr_state & GPIO_ISR_RADIO_INT )
    {
        RADIO_ISR_ENABLE();
	}
#endif // RADIO_NON_BLOCKING_CALLS

	return data;
}


*/

⌨️ 快捷键说明

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