//###########################################################################
// FILE: smbus.c
// TITLE: SMBus protocol layer API.
//###########################################################################
// $TI Release: F28M35x Support Library v201 $
// $Release Date: Fri Jun 7 10:51:13 CDT 2013 $
//###########################################################################
#include "inc/hw_i2c.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_sysctl.h"
#include "inc/hw_types.h"
#include "inc/hw_udma.h"
#include "driverlib/debug.h"
#include "driverlib/interrupt.h"
#include "driverlib/i2c.h"
#include "driverlib/sysctl.h"
#include "driverlib/udma.h"
#include "utils/crc.h"
#include "utils/smbus.h"
//*****************************************************************************
//! \addtogroup smbus_api
//! @{
//*****************************************************************************
//*****************************************************************************
// The states for the master and slave interrupt handler state machines.
//*****************************************************************************
#define SMBUS_STATE_IDLE 0
#define SMBUS_STATE_SLAVE_POST_COMMAND 1
#define SMBUS_STATE_WRITE_BLOCK_SIZE 2
#define SMBUS_STATE_WRITE_NEXT 3
#define SMBUS_STATE_WRITE_FINAL 4
#define SMBUS_STATE_WRITE_DMA_FINAL 5
#define SMBUS_STATE_WRITE_DONE 6
#define SMBUS_STATE_READ_ONE 7
#define SMBUS_STATE_READ_FIRST 8
#define SMBUS_STATE_READ_BLOCK_SIZE 9
#define SMBUS_STATE_READ_NEXT 10
#define SMBUS_STATE_READ_FINAL 11
#define SMBUS_STATE_READ_DMA_FINAL 12
#define SMBUS_STATE_READ_WAIT 13
#define SMBUS_STATE_READ_PEC 14
#define SMBUS_STATE_READ_DONE 15
#define SMBUS_STATE_READ_ERROR_STOP 16
#define SMBUS_STATE_DMA_TX_SEND_SIZE 32
#define SMBUS_STATE_DMA_TX_SEND_DATA 33
#define SMBUS_STATE_DMA_TX_WAIT_DMA 34
#define SMBUS_STATE_DMA_TX_WAIT_DONE 35
#define SMBUS_STATE_DMA_TX_WAIT_CRC 36
#define SMBUS_STATE_DMA_RX_START_DMA 38
#define SMBUS_STATE_DMA_RX_START_2_DMA 39
#define SMBUS_STATE_DMA_RX_WAIT_DMA 40
#define SMBUS_STATE_DMA_RX_WAIT_DONE 41
#define SMBUS_STATE_DMA_RAW_TX_SEND_DATA 42
#define SMBUS_STATE_DMA_RAW_TX_SEND_2_DATA 43
#define SMBUS_STATE_DMA_RAW_RX_START 44
#define SMBUS_STATE_DMA_RAW_TXRX_TURN 46
#define SMBUS_STATE_DMA_TX_LAST_BYTE 47
#define SMBUS_STATE_DMA_RAW_RX_WAIT 48
//*****************************************************************************
// Status flags for various instance-specific tasks.
//*****************************************************************************
#define FLAG_PEC 0
#define FLAG_DMA 1
#define FLAG_PROCESS_CALL 2
#define FLAG_BLOCK_TRANSFER 3
#define FLAG_TRANSFER_IN_PROGRESS 4
#define FLAG_RAW_I2C 5
#define FLAG_ADDRESS_RESOLVED 6
#define FLAG_ADDRESS_VALID 7
#define FLAG_ARP 8
#define FLAG_USE_DMA_TX 9
#define FLAG_USE_DMA_RX 10
#define DMA_MIN_TRANSFER 5
typedef struct
{
unsigned long ulI2CBase;
unsigned long ulTxDMAChannel;
unsigned long ulRxDMAChannel;
} tDMAChannelTable;
// Mapping of I2C base address to DMA channel.
static const tDMAChannelTable psDMAChannelMap[] =
{
{ I2C0_MASTER_BASE, UDMA_CH7_I2C0TX, UDMA_CH6_I2C0RX },
{ I2C1_MASTER_BASE, UDMA_CH9_I2C1TX, UDMA_CH8_I2C1RX },
{ I2C2_MASTER_BASE, UDMA_CH11_I2C2TX, UDMA_CH10_I2C2RX },
{ I2C3_MASTER_BASE, UDMA_CH19_I2C3TX, UDMA_CH18_I2C3RX },
{ I2C4_MASTER_BASE, UDMA_CH21_I2C4TX, UDMA_CH20_I2C4RX },
{ I2C5_MASTER_BASE, UDMA_CH23_I2C5TX, UDMA_CH22_I2C5RX },
};
// Generate constant size of the DMA channel map table.
static const int iDMAChannelMapEntries = sizeof(psDMAChannelMap)/
sizeof(tDMAChannelTable);
static unsigned long ulRun = I2C_MCS_RUN;
static unsigned long ulStop = I2C_MCS_STOP;
static unsigned long ulDMADisable = 0;
//*****************************************************************************
//! Enables DMA for SMBus and I2C transfers.
//!
//! \param pSMBus specifies the SMBus configuration structure.
//!
//! This function enables DMA use when using the SMBus API.
//!
//! This function also enables the DMA error interrupt. If an error handler
//! is not implemented and a DMA error occurs then the error will not be
//! handled.
//!
//! The only functions that support DMA are SMBusMasterI2CWrite() and
//! SMBusMasterI2CRead(). All other functions use interrupt-driven transfers,
//! even if DMA is enabled at the stack level (i.e. calling this function).
//!
//! \return None.
//*****************************************************************************
void
SMBusDMAEnable(tSMBus *pSMBus)
{
// Set the DMA flag in the configuration structure.
HWREGBITB(&pSMBus->usFlags, FLAG_DMA) = 1;
// Enable the uDMA controller error interrupt. This interrupt will occur
// if there is a bus error during a transfer.
IntEnable(INT_UDMAERR);
}
//*****************************************************************************
//! \internal
//! Disable DMA for I2C transfers.
//!
//! \param pSMBus specifies the SMBus configuration structure.
//!
//! This function disables DMA use when using the SMBus API.
//!
//! \return None.
//*****************************************************************************
void
SMBusDMADisable(tSMBus *pSMBus)
{
// Clear the DMA flag in the configuration structure.
HWREGBITB(&pSMBus->usFlags, FLAG_DMA) = 0;
// Clear the DMA bits in the I2C.
I2CDMAConfigSet(pSMBus->ulI2CBase, 0);
// Enable the uDMA controller error interrupt. This interrupt will occur
// if there is a bus error during a transfer.
IntDisable(INT_UDMAERR);
}
//*****************************************************************************
//! Enables Packet Error Checking (PEC).
//!
//! \param pSMBus specifies the SMBus configuration structure.
//!
//! This function enables the transmission and checking of a PEC byte in SMBus
//! transactions.
//!
//! \return None.
//*****************************************************************************
void
SMBusPECEnable(tSMBus *pSMBus)
{
// Set the PEC flag in the configuration structure.
HWREGBITB(&pSMBus->usFlags, FLAG_PEC) = 1;
}
//*****************************************************************************
//! Disables Packet Error Checking (PEC).
//!
//! \param pSMBus specifies the SMBus configuration structure.
//!
//! This function disables the transmission and checking of a PEC byte in SMBus
//! transactions.
//!
//! \return None.
//*****************************************************************************
void
SMBusPECDisable(tSMBus *pSMBus)
{
// Clear the PEC flag in the configuration structure.
HWREGBITB(&pSMBus->usFlags, FLAG_PEC) = 0;
}
//*****************************************************************************
//! Sets the ARP flag in the configuration structure.
//!
//! \param pSMBus specifies the SMBus configuration structure.
//!
//! This function sets the Address Resolution Protocol (ARP) flag in the
//! configuration structure. This flag can be used to track the state of a
//! device during the ARP process.
//!
//! \return None.
//*****************************************************************************
void
SMBusARPEnable(tSMBus *pSMBus)
{
// Set the ARP flag in the configuration structure.
HWREGBITB(&pSMBus->usFlags, FLAG_ARP) = 1;
}
//*****************************************************************************
//! Clears the ARP flag in the configuration structure.
//!
//! \param pSMBus specifies the SMBus configuration structure.
//!
//! This function clears the Address Resolution Protocol (ARP) flag in the
//! configuration structure.
没有合适的资源?快使用搜索试试~ 我知道了~
欧瑞伺服(源码+按键板+功率板+控制板+FPGA).zip
共3087个文件
c:350个
obj:331个
pp:255个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 13 下载量 124 浏览量
2021-06-15
11:33:38
上传
评论
收藏 37.52MB ZIP 举报
温馨提示
基于 DSP 欧瑞伺服 源码+按键板原理图+功率板+控制板+FPGA源码
资源推荐
资源详情
资源评论
收起资源包目录
欧瑞伺服(源码+按键板+功率板+控制板+FPGA).zip (3087个子文件)
000a07999148001319bbb410dedc8f82(1) 3KB
000a6948008700131e1bf1c3b210ba26 6KB
000da5c6784700131b34afe4ebca48cd 2KB
000fec833670001716299c21b3490862 2KB
00110ed846aa001313ad8065ed43472b 3KB
0013efb4b94500131772d26e04522a25 87B
001878153748001311e8f4a77a11da45 12KB
001a7397a25200141b238e3ecf124ddb 250B
001cf664b34500131161c90325a00f84 2KB
001d77e0be4600131943a4118d3535bb 2KB
002024e9926000171bc1fed3ee7eb0ae 8KB
00274ffd6c08001310fcead4e06b4dd1 5KB
00315d35666000171b2edb05daf5da84 8KB
0037a37dfe8b001410bbcfffe691f68e 2KB
0039f05f238d00171e9ce9e144cd6b50 2KB
003c5585e9880013133bdd1070b8275e 2KB
003edb7f5960001710c5b2dcfbcafea7 8KB
004313235e6c001715d381a76c6dcf7b 2KB
00491f8da7cc0014133bf3fac86a1c1c 3KB
004c9e2eb63300171b37dbb2a4552e94 2KB
004de6eb238d00171e9ce9e144cd6b50 8KB
00528d8d6260001710c5b2dcfbcafea7 2KB
005377ee7f6000171d6af1b0479686f4 8KB
005f6ff7d26300131898a26b40b24685 51KB
0060f697228d00171e9ce9e144cd6b50 2KB
00651cc7953300171394d4e279ab004b 265B
006a46c3ba4600131943a4118d3535bb 247B
006fe2496160001710c5b2dcfbcafea7 2KB
0074e0d72f8d00171d73c121d9eb5b0d 8KB
007676877dff001417a6f1e29c5ee52d 8KB
0076de56d0e300141dc7c15a723db4bf 265B
007a9458c0d0001210f8eaffef4ad2aa 4KB
007b11c25d60001710c5b2dcfbcafea7 2KB
007c868bc44500131772d26e04522a25 2KB
007f1335806000171d6af1b0479686f4 2KB
009016be721f00141b2cffc727aa81cb 265B
009325093948001311e8f4a77a11da45 3KB
00952107135400131e38d12e8e2fb0d8 6KB
0097acc33b47001715ce917d04a2d88f 8KB
0099d621c64500131772d26e04522a25 18KB
009ab806135400131e38d12e8e2fb0d8 9KB
009c7c25864700131b34afe4ebca48cd 660B
00a410fa3d7000171faba5f9d2b99474 2KB
00a6c16e3848001311e8f4a77a11da45 2KB
00a887b02b8d001715edd3c2987318b6 8KB
00abf364b34500131161c90325a00f84 885B
00af6bfd5c60001710c5b2dcfbcafea7 8KB
00b016032e8d00171564e0393c06c8f8 2KB
00b0d5bb6060001710c5b2dcfbcafea7 8KB
00b1b973014500131329d70e82dcaabe 3KB
00b2f057c64500131772d26e04522a25 2KB
00b78757c64500131772d26e04522a25 2KB
00b962c82c8d00171564e0393c06c8f8 2KB
00ba221ce2a80013179de3b022326682 10KB
00c97c70916000171bc1fed3ee7eb0ae 8KB
00cd312d00e800141063d246f4dc254a 12KB
00d01002daa80013179de3b022326682 9KB
00d827879148001319bbb410dedc8f82 10KB
00dc795b774700131b34afe4ebca48cd 690B
00dce92dcd4500131772d26e04522a25 3KB
00e0a085774700131b34afe4ebca48cd 3KB
00e9357bb34500131161c90325a00f84 2KB
00eb9f465d60001710c5b2dcfbcafea7 8KB
00ec4bf0bdd0001212c4f092ce48ce50 4KB
00ef46d7806000171d6af1b0479686f4 2KB
00f27e4a585200131abd93fc7674797e 3KB
00f70bf55c48001311e8f4a77a11da45 9KB
00f860b3004500131329d70e82dcaabe 2KB
00fe3c19be7a00141eb4978cb1289730 2KB
00ff7be0be4600131943a4118d3535bb 582B
01274ffd6c08001310fcead4e06b4dd1 250B
013edb7f5960001710c5b2dcfbcafea7 265B
0174e0d72f8d00171d73c121d9eb5b0d 265B
01b1b973014500131329d70e82dcaabe 9KB
01b962c82c8d00171564e0393c06c8f8 885B
01e9357bb34500131161c90325a00f84 7KB
01ff7be0be4600131943a4118d3535bb 937B
02b962c82c8d00171564e0393c06c8f8(1) 2KB
100089535047001314e9eed5009256a1 50KB
1003b280666000171b2edb05daf5da84 2KB
100618c08b6000171d6af1b0479686f4 2KB
10073bf88e6000171bc1fed3ee7eb0ae 8KB
100cf19e5a60001710c5b2dcfbcafea7 2KB
1013e0ba989f001418ecbbc5df4958f1 8KB
101fbd5b5f60001710c5b2dcfbcafea7 2KB
1023fa787856001316b0e225234cb90e 250B
102717ff3948001311e8f4a77a11da45 2KB
102aded72f8d00171d73c121d9eb5b0d 7KB
103146db2b8d001715edd3c2987318b6 8KB
1034a7485a60001710c5b2dcfbcafea7 8KB
103c07f55c48001311e8f4a77a11da45 3KB
103c5c21ca4500131772d26e04522a25 3KB
10413490ce4500131772d26e04522a25 3KB
1041f5787856001316b0e225234cb90e 6KB
104394a5656000171b2edb05daf5da84 2KB
104c8b24238d00171e9ce9e144cd6b50 2KB
1054d182c45700131029af2eba575fdb 265B
1058bcac7f4700131b34afe4ebca48cd 2KB
10640fbe721f00141b2cffc727aa81cb 8KB
1066b345298d001715edd3c2987318b6 8KB
共 3087 条
- 1
- 2
- 3
- 4
- 5
- 6
- 31
newzhpfree
- 粉丝: 105
- 资源: 121
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页