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: OTP.cpp
- Revision:
- 4:1f708415c442
- Parent:
- 3:1d0c09e43e22
--- a/OTP.cpp Tue May 13 11:04:01 2014 +0000
+++ b/OTP.cpp Tue May 13 13:54:32 2014 +0000
@@ -7,15 +7,7 @@
CSn( DigitalOut(CSn_pin, 0) ),
pc( pc )
{
- factory_section = 0;
- I2C_A = 0;
- CCW = 0;
- Z = 0;
- output_md1 = 0;
- output_md0 = 0;
- pwmDIS = 0;
- MagCompEN = 0;
- PWMhalfEN_IndexWidth = 0;
+ clear_registers();
}
void OTP::setup()
@@ -177,15 +169,15 @@
//factory_section
{
- PDIO = 0;
- wait_us(30);
+ factory_section = 0;
for(int i=0; i<29; i++)
{
PDIO = ( factory_section>>(29-i-1) )&1;
+ wait_us(15);
CLK = 1;
wait_us(30);
CLK = 0;
- wait_us(30);
+ wait_us(15);
}
}
@@ -232,26 +224,35 @@
//mbit0
CLK = 1;
- wait_us(15); //T_PROG_BURN
+ wait_us(T_PROG_BURN);
CLK = 0;
- wait_us(30);
+ wait_us(T_PROG_REFRESH);
//factory_section
for(int i=0; i<29; i++)
{
CLK = 1;
- wait_us(15); //T_PROG_BURN
+ wait_us(T_PROG_BURN);
CLK = 0;
- wait_us(30);
+ wait_us(T_PROG_REFRESH);
}
//I2C_A
for(int i=0; i<5; i++)
{
CLK = 1;
- wait_us(15); //T_PROG_BURN
+ wait_us(T_PROG_BURN);
CLK = 0;
- wait_us(30);
+ wait_us(T_PROG_REFRESH);
+ }
+
+ //burn other bits
+ for(int i=0; i<19; i++)
+ {
+ CLK = 1;
+ wait_us(T_PROG_BURN);
+ CLK = 0;
+ wait_us(T_PROG_REFRESH);
}
}
else
@@ -267,4 +268,17 @@
void OTP::set_id(uint8_t id)
{
I2C_A = ID_to_I2C_A(id);
+}
+
+void OTP::clear_registers()
+{
+ factory_section = 0;
+ I2C_A = 0;
+ CCW = 0;
+ Z = 0;
+ output_md1 = 0;
+ output_md0 = 0;
+ pwmDIS = 0;
+ MagCompEN = 0;
+ PWMhalfEN_IndexWidth = 0;
}
\ No newline at end of file