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:
- 3:1d0c09e43e22
- Parent:
- 2:af09cade52df
- Child:
- 4:1f708415c442
diff -r af09cade52df -r 1d0c09e43e22 OTP.cpp
--- a/OTP.cpp Tue May 13 10:38:10 2014 +0000
+++ b/OTP.cpp Tue May 13 11:04:01 2014 +0000
@@ -1,4 +1,5 @@
#include "OTP.h"
+#include <ctype.h>
OTP::OTP(PinName PDIO_pin, PinName CLK_pin, PinName CSn_pin, Serial &pc):
PDIO( DigitalInOut(PDIO_pin, PIN_INPUT, PullNone, 0) ),
@@ -180,7 +181,7 @@
wait_us(30);
for(int i=0; i<29; i++)
{
- //PDIO = ( factory_section>>(29-i-1) )&1;
+ PDIO = ( factory_section>>(29-i-1) )&1;
CLK = 1;
wait_us(30);
CLK = 0;
@@ -205,44 +206,60 @@
void OTP::prog()
{
- pc.printf("Install capacitor on PDIO\n");
- pc.scanf("\n");
- pc.printf("Fusing...");
- PDIO = 1;
- CLK = 1;
- wait_us(30);
- CSn = 1;
- wait_us(30);
- CLK = 0;
- wait_us(30);
+ char input;
+ pc.printf("Install capacitor on PDIO (y/n): ");
+ pc.scanf("%c", &input);
- //generate four CLK pulses
- for(int i=0; i<4; i++)
+ if(tolower(input) == 'y')
{
+ pc.printf("\nFusing...\n");
+ PDIO = 1;
CLK = 1;
wait_us(30);
+ CSn = 1;
+ wait_us(30);
CLK = 0;
wait_us(30);
- }
-
- //factory_section
- for(int i=0; i<29; i++)
- {
+
+ //generate three CLK pulses
+ for(int i=0; i<3; i++)
+ {
+ CLK = 1;
+ wait_us(30);
+ CLK = 0;
+ wait_us(30);
+ }
+
+ //mbit0
CLK = 1;
wait_us(15); //T_PROG_BURN
CLK = 0;
wait_us(30);
+
+ //factory_section
+ for(int i=0; i<29; i++)
+ {
+ CLK = 1;
+ wait_us(15); //T_PROG_BURN
+ CLK = 0;
+ wait_us(30);
+ }
+
+ //I2C_A
+ for(int i=0; i<5; i++)
+ {
+ CLK = 1;
+ wait_us(15); //T_PROG_BURN
+ CLK = 0;
+ wait_us(30);
+ }
}
-
- //I2C_A
- for(int i=0; i<5; i++)
+ else
{
- CLK = 1;
- wait_us(15); //T_PROG_BURN
- CLK = 0;
- wait_us(30);
+ pc.printf("\nCancelled.\n");
}
-
+
+ wait_us(30);
CSn = 0;
wait_us(30);
}