📄 spi_master.c
字号:
/** ###################################################################
** Filename : spi_master.C
** Project : spi_master
** Processor : 56F8346
** Version : Driver 01.10
** Compiler : Metrowerks DSP C Compiler
** Date/Time : 2009-1-12, 16:11
** Abstract :
** Main module.
** Here is to be placed user's code.
** Settings :
** Contents :
** No public methods
**
** (c) Copyright UNIS, spol. s r.o. 1997-2005
** UNIS, spol. s r.o.
** Jundrovska 33
** 624 00 Brno
** Czech Republic
** http : www.processorexpert.com
** mail : info@processorexpert.com
** ###################################################################*/
/* MODULE spi_master */
/* Including used modules for compiling procedure */
#include "Cpu.h"
#include "Events.h"
#include "slave_select.h"
#include "PC_M1.h"
#include "Inhr1.h"
#include "SM1.h"
#include "Delay_timer.h"
/* Include shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
SM1_TComData TxByte = NULL;
SM1_TComData RxByte = NULL;
SM1_TComData spiRxchar;
volatile bool flag = FALSE;
void main(void)
{
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/
PC_M1_pcmasterdrvRecorder();
/* Write your code here */
while(1)
{
/*select the slave*/
slave_select_ClrVal();
if(SM1_SendChar(TxByte)==ERR_OK)
{
TxByte=NULL;
}
/*Delay for periodic polling*/
Delay_timer_Enable();
while(flag==FALSE)
{
}
Delay_timer_Disable();
flag=FALSE;
/*receive data*/
if(SM1_RecvChar(&spiRxchar)==ERR_OK)
{
if((spiRxchar!=NULL)&&(spiRxchar!=0xFF))
{
RxByte=spiRxchar;
}
}
/*delect the slave*/
slave_select_SetVal();
}
for(;;) {}
}
/* END spi_master */
/*
** ###################################################################
**
** This file was created by UNIS Processor Expert 2.97 [03.74]
** for the Freescale 56800 series of microcontrollers.
**
** ###################################################################
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -