Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: i2c_mbed_fpga.cpp
- Revision:
- 5:daab0e0e67e2
- Parent:
- 0:fe3c7dde9771
- Child:
- 6:019ab407ac3c
--- a/i2c_mbed_fpga.cpp Tue Jan 12 12:01:27 2021 +0000
+++ b/i2c_mbed_fpga.cpp Fri Jan 22 14:06:54 2021 +0000
@@ -2,28 +2,16 @@
#include "i2c_mbed_fpga.h"
-char i2cKey[4] = {0x13, 0xA4, 0xD0, 0xD0};
-char CtrPortWactive[4] = {0x00, 0x30, 0x00, 0x71};
-char CtrPortRactive[4] = {0x00, 0x30, 0x00, 0x01};
-
/** i2c write to slave DUT
*
* @param i2c_master specifies the i2c interface
* @param word is considered as 4byte char data
*/
-int i2c_word_write(I2C i2c_master, char *word){
- int ack=1;
-
- if(ack!=0)
- {
- ack = i2c_master.write(i2c_slave_addr, word, 4, 0);
- wait_ms(1);
- }
-
- if(ack==0)
- return 0;
- else
- return 1;
+int i2c_mbed_fpga::i2c_word_write(char *word){
+ int ack;
+ ack = i2c_master.write(i2c_slave_addr, word, 4, 0);
+ wait_us(100);
+ return ack;
}
@@ -32,45 +20,29 @@
* @param i2c_master specifies the i2c interface
* @param word is 4byte, first 2bytes as addr, the rest 2bytes to store data
*/
-int i2c_word_read(I2C i2c_master, char *word){
- int ack=1;
-
- if(ack!=0)
- {
- ack = i2c_master.write(i2c_slave_addr, word, 2, 1);
- ack += i2c_master.read(i2c_slave_addr, word+2, 2, 0);
- wait_ms(1);
- }
-
- if(ack==0)
- return 0;
- else
- return 1;
+int i2c_mbed_fpga::i2c_word_read(char *word){
+ int ack;
+ ack = i2c_master.write(i2c_slave_addr, word, 2, 1);
+ ack += i2c_master.read(i2c_slave_addr, word+2, 2, 0);
+ wait_us(100);
+ return (ack == 0) ? 0 : 1;
}
-/** i2c enter key
+/** i2c enter key to open I2C window
*
* @param specifc key needed to enter i2c mode of DUT
*/
-int i2c_keyEntry(I2C i2c_master){
- return i2c_word_write(i2c_master, i2cKey);
+int i2c_mbed_fpga::i2c_window_open(){
+ char i2cKey[4] = {0x13, 0xA4, 0xD0, 0xD0};
+ return i2c_word_write(i2cKey);
}
-
-/** Activate eeprom for write operations
+/** i2c enter key to Start the motor
*
* @param specifc key needed to enter i2c mode of DUT
*/
-int ctrPort_WriteActive(I2C i2c_master){
- return i2c_word_write(i2c_master, CtrPortWactive);
+int i2c_mbed_fpga::i2c_motor_start(){
+ char i2cKey[4] = {0x13, 0xA4, 0xCA, 0xFE};
+ return i2c_word_write(i2cKey);
}
-
-
-/** Activate eeprom for read operations
-*
-* @param specifc key needed to enter i2c mode of DUT
-*/
-int ctrPort_ReadActive(I2C i2c_master){
- return i2c_word_write(i2c_master, CtrPortRactive);
-}
\ No newline at end of file
