📄 spi.c
字号:
/****************************************************************************
*
* MODULE: Timer1.c
*
* COMPONENT: $RCSfile: $
*
* VERSION: $Name: $
*
* REVISION: $Revision: $
*
* DATED: $Date: 30/06/06 $
*
* STATUS: $State: $
*
* AUTHOR: Gordon MacNee
*
* DESCRIPTION
* code segment to demonstrate the operation of the timers
* running in two modes of PWM
* no interrupts are used in these routines
*
* CHANGE HISTORY:
*
* $Log: $
*
*
* LAST MODIFIED BY: $Author: pc1 $
* $Modtime: $
*
*
****************************************************************************
* This software is owned by Jennic and/or its supplier and is protected
* under applicable copyright laws. All rights are reserved. We grant you,
* and any third parties, a license to use this software solely and
* exclusively on Jennic products. You, and any third parties must
* reproduce the copyright and warranty notice and any other legend of
* ownership on each copy or partial copy of the software.
*
* THIS SOFTWARE IS PROVIDED 揂S IS? JENNIC MAKES NO WARRANTIES, WHETHER
* EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE,
* ACCURACY OR LACK OF NEGLIGENCE. JENNIC SHALL NOT, IN ANY CIRCUMSTANCES,
* BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, SPECIAL,
* INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON WHATSOEVER.
*
* Copyright Jennic Ltd 2005, 2006. All rights reserved
*
****************************************************************************/
/****************************************************************************/
/*** Include files ***/
/****************************************************************************/
#include <jendefs.h>
#include <AppHardwareApi.h>
/****************************************************************************/
/*** Macro Definitions ***/
/****************************************************************************/
/****************************************************************************/
/*** Type Definitions ***/
/****************************************************************************/
/****************************************************************************/
/*** Local Function Prototypes ***/
/****************************************************************************/
/****************************************************************************/
/*** Exported Variables ***/
/****************************************************************************/
/****************************************************************************/
/*** Local Variables ***/
/****************************************************************************/
/****************************************************************************/
/*** Exported Functions ***/
/****************************************************************************/
/****************************************************************************/
/*** Local Functions ***/
/****************************************************************************/
PRIVATE void vProcessEventQueues(void);
PRIVATE void vReadFromFlash();
/****************************************************************************
*
* NAME: vTimerConfig
*
* DESCRIPTION:
* PWM output from timer0 in Delta Sigma mode
* with a low period of 0x8000 and a high of (0xffff - 0x8000)
*
* PWM output from timer1 in standard PWM mode
* with a low period of 0x8000 and a high of (0xffff - 0x8000)
*
* PARAMETERS: Name RW Usage
* None.
*
* RETURNS:
* None.
*
* NOTES:
* In this mode the period of timer0 is fixed
* at 2^16 or 2^17 and the u16Lo the SPACE period
****************************************************************************/
PRIVATE void vReadFromFlash(uint32 u32Addr,
uint32 u32NumWords,
uint32 *pau32Buffer )
{
#define FLASHREADCMD 0x03
#define SPI_SLCT_NONE 0x00
uint32 u32Temp;
uint32 i;
vAHI_SpiConfigure( 1, /* number of slave select
lines in use */
E_AHI_SPIM_MSB_FIRST, /* send data MSB first */
E_AHI_SPIM_TXNEG_EDGE, /* TX data to change on
negative edge */
E_AHI_SPIM_RXNEG_EDGE, /* RX data to change on
negative edge */
0, /* Generate 16MHz SPI clock */
E_AHI_SPIM_INT_DISABLE, /* Disable SPI interrupt */
E_AHI_SPIM_AUTOSLAVE_DSABL); /* Disable auto slave select
*/
/* combine read cmd & addr into single value to be sent over SPI */
u32Temp = (u32Addr & 0x00FFFFFF) | (FLASHREADCMD << 24);
/* select spi device */
vAHI_SpiSelect(E_AHI_SPIM_SLAVE_ENBLE_0);
/* send read cmd and address location */
vAHI_SpiStartTransfer32(u32Temp);
vAHI_SpiWaitBusy();
for (i=0; i<=u32NumWords; i++)
{
/* read data 4 bytes at a time */
vAHI_SpiStartTransfer32(u32Addr);
vAHI_SpiWaitBusy();
/* copy into temp variable */
u32Temp = u32AHI_SpiReadTransfer32();
/* copy to buffer */
memcpy( (pau32Buffer+i), &u32Temp, sizeof(u32Temp) );
}
/* deselect select spi device */
vAHI_SpiSelect(SPI_SLCT_NONE);
}
/****************************************************************************
*
* NAME: AppWarmStart
*
* DESCRIPTION:
* Entry point for a wake from sleep mode with the memory contents held. We
* are not using this mode and so should never get here.
*
* PARAMETERS: Name RW Usage
* None.
*
* RETURNS:
* None.
*
* NOTES:
* None.
****************************************************************************/
PUBLIC void AppWarmStart(void)
{
AppColdStart();
}
/****************************************************************************/
/*** END OF FILE ***/
/****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -