-
-
Save shima-529/9f44f83b7cb9aebcd6f8a1aa55592893 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include "i2c.h" | |
// Blink 4Hz | |
static const uint8_t gp_nvmdata[] = { | |
#include "../../blink.array" | |
}; | |
#define GP_CONTROL_CODE (0x01 << 4) | |
void gp_erase(void) { | |
for(int i = 0; i < 16; i++) { | |
uint8_t dat[] = { | |
0xE3, // Erase Command Register | |
0x80 | i // Page Address | |
}; | |
i2c_send(GP_CONTROL_CODE | 0x02, dat, 2, 20); | |
} | |
} | |
void gp_reg_write(void) { | |
for(int i = 0; i < 16; i++) { | |
uint8_t dat[1 + 16] = {i * 16}; | |
for(int j = 0; j < 16; j++) { | |
dat[1 + j] = gp_nvmdata[i * 16 + j]; | |
} | |
i2c_send(GP_CONTROL_CODE | 0x02, dat, 1 + 16, 20); // Write | |
} | |
} | |
void gp_nvm_write(void) { | |
for(int i = 0; i < 16; i++) { | |
uint8_t dat[1 + 16] = {i * 16}; | |
for(int j = 0; j < 16; j++) { | |
dat[1 + j] = gp_nvmdata[i * 16 + j]; | |
} | |
i2c_send(GP_CONTROL_CODE | 0x04, dat, 1 + 16, 20); // Write | |
} | |
} | |
void gp_invoke_por(void) { | |
uint8_t dat[] = {0xC8, 2}; | |
i2c_send(GP_CONTROL_CODE | 0x02, dat, 2, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment