Skip to content
Snippets Groups Projects
Commit ce97addf authored by jamesimmanuel.magsino@stud.h-da.de's avatar jamesimmanuel.magsino@stud.h-da.de
Browse files

Minor refactoring

parent 45c4b0d5
Branches
No related tags found
No related merge requests found
...@@ -2,181 +2,90 @@ ...@@ -2,181 +2,90 @@
#include <hardware/i2c.h> #include <hardware/i2c.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
/*
unsigned* enablerregister = (void *) (SIO_BASE + SIO_GPIO_OE_SET_OFFSET);
unsigned* volatile outregister = (void *) (SIO_BASE + SIO_GPIO_OUT_SET_OFFSET);
unsigned* volatile outclearregister = (void *) (SIO_BASE + SIO_GPIO_OUT_CLR_OFFSET);
unsigned* gpioregister = (void *) (IO_BANK0_BASE + IO_BANK0_GPIO25_CTRL_OFFSET );
unsigned* resetspace = (void *) (RESETS_BASE);
unsigned* resetdone = (void*) (RESETS_BASE + RESETS_RESET_DONE_IO_BANK0_BITS);
//unsigned* resetdone = (void*) RESETS_RESET_DONE_IO_BANK0_BITS;
*/
//unsigned* SDApin = (void*)(SIO_BASE + IO_BANK0_GPIO0_CTRL_FUNCSEL_VALUE_I2C0_SDA); unsigned *SDApinctrl = (void *)(IO_BANK0_BASE + IO_BANK0_GPIO0_CTRL_OFFSET);
//unsigned* SCLpin = (void*)(IO_BANK0_GPIO1_CTRL_FUNCSEL_VALUE_I2C0_SCL); unsigned *SCLpinctrl = (void *)(IO_BANK0_BASE + IO_BANK0_GPIO1_CTRL_OFFSET);
const uint8_t init[4] = {0x21, 0xa0, 0xe1, 0x81};
const uint8_t zeile[8] = {0x00, 0x02, 0x04, 0x06, 0x08, 0x10, 0x12, 0x14};
const uint8_t fill[17] = {0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
const uint8_t empty[17] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const uint8_t achtel[17] = {0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const uint8_t viertel[17] = {0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const uint8_t dreiachtel[17] = {0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const uint8_t hälfte[17] = {0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const uint8_t fünfachtel[17] = {0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const uint8_t dreiviertel[17] = {0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00};
const uint8_t siebenachtel[17] = {0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00};
const uint8_t ganzes[17] = {0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00};
int main()
{
unsigned* SDApinctrl = (void*)(IO_BANK0_BASE + IO_BANK0_GPIO0_CTRL_OFFSET);
unsigned* SCLpinctrl = (void*)(IO_BANK0_BASE + IO_BANK0_GPIO1_CTRL_OFFSET);
//unsigned* SDApinctrl = (void *)PICO_DEFAULT_I2C_SDA_PIN;
//unsigned* SCLpinctrl = (void *)PICO_DEFAULT_I2C_SCL_PIN;
const uint8_t init[4] = { 0x21,0xa0,0xe1,0x81};
const uint8_t zeile[8] = { 0x00,0x02,0x04,0x06,0x08,0x10,0x12,0x14};
//const uint8_t test[1] = { 0x21,0xa0,0xe1,0x81};
const uint8_t fill[17] = { 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
const uint8_t empty[17] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const uint8_t achtel[17] = { 0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const uint8_t viertel[17] = { 0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const uint8_t dreiachtel[17] = { 0x00,0xff,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const uint8_t hälfte[17] = { 0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const uint8_t fünfachtel[17] = { 0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const uint8_t dreiviertel[17] = { 0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00};
const uint8_t siebenachtel[17] = { 0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0x00,0x00};
const uint8_t ganzes[17] = { 0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00};
int main() {
//*SDApinctrl = IO_BANK0_GPIO0_CTRL_FUNCSEL_VALUE_I2C0_SDA;
//*SCLpinctrl = IO_BANK0_GPIO1_CTRL_FUNCSEL_VALUE_I2C0_SCL;
//gpio_set_function_masked(1 | 2, GPIO_FUNC_I2C); //
//gpio_pull_up(*SDApinctrl);
//gpio_pull_up(*SCLpinctrl);
// gpio_set_function_masked(*SDApinctrl , IO_BANK0_GPIO0_CTRL_FUNCSEL_VALUE_I2C0_SDA); //
// gpio_set_function_masked(*SCLpinctrl , IO_BANK0_GPIO1_CTRL_FUNCSEL_VALUE_I2C0_SCL); //
i2c_init(i2c_default, 100000); i2c_init(i2c_default, 100000);
gpio_set_function(0 ,GPIO_FUNC_I2C); gpio_set_function(0, GPIO_FUNC_I2C);
gpio_set_function(1 ,GPIO_FUNC_I2C); gpio_set_function(1, GPIO_FUNC_I2C);
gpio_pull_up(1); gpio_pull_up(1);
gpio_pull_up(0); gpio_pull_up(0);
//uint8_t* lampe [2] = {0x01,0xff}; i2c_write_blocking(i2c_default, 0x70, &init[0], 1, false);
i2c_write_blocking(i2c_default, 0x70, &init[1], 1, false);
i2c_write_blocking(i2c_default, 0x70, &init[2], 1, false);
i2c_write_blocking(i2c_default, 0x70 , init+0, 1 ,false); i2c_write_blocking(i2c_default, 0x70, &init[3], 1, false);
i2c_write_blocking(i2c_default, 0x70 ,init+1, 1 ,false);
i2c_write_blocking(i2c_default, 0x70 ,init+2, 1 ,false);
i2c_write_blocking(i2c_default, 0x70 ,init+3, 1 ,false);
//const uint8_t zeile[8] = { 0x00,0x02,0x04,0x06,0x08,0x10,0x12,0x14};
i2c_write_blocking(i2c_default, 0x70 , zeile, 4 ,false); i2c_write_blocking(i2c_default, 0x70, zeile, 4, false);
//i2c_write_blocking(i2c_default, 0x70 , fill, 17 ,false); i2c_write_blocking(i2c_default, 0x70, empty, 17, false);
i2c_write_blocking(i2c_default, 0x70 , empty, 17 ,false);
i2c_write_blocking(i2c_default, 0x70 , achtel, 17 ,false); i2c_write_blocking(i2c_default, 0x70, achtel, 17, false);
for(int j = 0; j <10000000; j++){ for (int j = 0; j < 10000000; j++)
{
volatile int i = 0; volatile int i = 0;
// *outregister = 0x01 << PICO_DEFAULT_LED_PIN;
} }
// busy_wait_ms(1000); i2c_write_blocking(i2c_default, 0x70, viertel, 17, false);
for (int j = 0; j < 10000000; j++)
i2c_write_blocking(i2c_default, 0x70 , viertel, 17 ,false); {
for(int j = 0; j <10000000; j++){
volatile int i = 0; volatile int i = 0;
// *outregister = 0x01 << PICO_DEFAULT_LED_PIN;
} }
// busy_wait_ms(1000);
i2c_write_blocking(i2c_default, 0x70 , dreiachtel, 17 ,false); i2c_write_blocking(i2c_default, 0x70, dreiachtel, 17, false);
for(int j = 0; j <10000000; j++){ for (int j = 0; j < 10000000; j++)
{
volatile int i = 0; volatile int i = 0;
// *outregister = 0x01 << PICO_DEFAULT_LED_PIN;
} }
// busy_wait_ms(1000);
i2c_write_blocking(i2c_default, 0x70 , hälfte, 17 ,false); i2c_write_blocking(i2c_default, 0x70, hälfte, 17, false);
for(int j = 0; j <10000000; j++){ for (int j = 0; j < 10000000; j++)
{
volatile int i = 0; volatile int i = 0;
// *outregister = 0x01 << PICO_DEFAULT_LED_PIN;
} }
// busy_wait_ms(1000);
i2c_write_blocking(i2c_default, 0x70 , fünfachtel, 17 ,false); i2c_write_blocking(i2c_default, 0x70, fünfachtel, 17, false);
for(int j = 0; j <10000000; j++){ for (int j = 0; j < 10000000; j++)
{
volatile int i = 0; volatile int i = 0;
// *outregister = 0x01 << PICO_DEFAULT_LED_PIN;
} }
// busy_wait_ms(1000);
i2c_write_blocking(i2c_default, 0x70 , dreiviertel, 17 ,false); i2c_write_blocking(i2c_default, 0x70, dreiviertel, 17, false);
for(int j = 0; j <10000000; j++){ for (int j = 0; j < 10000000; j++)
{
volatile int i = 0; volatile int i = 0;
// *outregister = 0x01 << PICO_DEFAULT_LED_PIN;
} }
// busy_wait_ms(1000);
i2c_write_blocking(i2c_default, 0x70 , siebenachtel, 17 ,false); i2c_write_blocking(i2c_default, 0x70, siebenachtel, 17, false);
for(int j = 0; j <10000000; j++){ for (int j = 0; j < 10000000; j++)
{
volatile int i = 0; volatile int i = 0;
// *outregister = 0x01 << PICO_DEFAULT_LED_PIN;
} }
// busy_wait_ms(1000);
i2c_write_blocking(i2c_default, 0x70 , ganzes, 17 ,false); i2c_write_blocking(i2c_default, 0x70, ganzes, 17, false);
for(int j = 0; j <10000000; j++){ for (int j = 0; j < 10000000; j++)
{
volatile int i = 0; volatile int i = 0;
// *outregister = 0x01 << PICO_DEFAULT_LED_PIN;
}
// busy_wait_ms(1000);
//i2c_write_blocking(i2c_default, 0x70 ,(const uint8_t *) 0x81, 1 ,false);
/*
*resetspace &= ~(1u<<5);
*gpioregister = 5;
*enablerregister = 0x01 << PICO_DEFAULT_LED_PIN;
if(*resetdone & (0x1 <<5)){
} }
for(int i = 0; i< 10 ;i++){
for(int j = 0; j <1000000; j++){
*outregister = 0x01 << PICO_DEFAULT_LED_PIN;
}
for(int j = 0; j <1000000; j++){
//*outregister = 0x00 << SIO_GPIO_HI_OUT_CLR_OFFSET;
*outclearregister = 0x01 << PICO_DEFAULT_LED_PIN;
}
}
*/
return 0; return 0;
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment