From 45c4b0d56a77db2a0c545c95b9c019e3c0b6d1d3 Mon Sep 17 00:00:00 2001 From: Pascal Koch <pascal.koch@stud.h-da.de> Date: Mon, 18 Nov 2024 17:48:18 +0100 Subject: [PATCH] glorious working prak2 code --- src/main.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index e4db2dab..131525ae 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,7 @@ #include <pico/stdlib.h> #include <hardware/i2c.h> +#include <stdio.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); @@ -26,8 +28,17 @@ 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 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,0xff}; -const uint8_t empty[17] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +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}; + @@ -67,10 +78,71 @@ int main() { //i2c_write_blocking(i2c_default, 0x70 , fill, 17 ,false); i2c_write_blocking(i2c_default, 0x70 , empty, 17 ,false); - for(int i = 0 ; i <=8;i++){ + i2c_write_blocking(i2c_default, 0x70 , achtel, 17 ,false); + + for(int j = 0; j <10000000; j++){ + 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++){ + volatile int i = 0; + // *outregister = 0x01 << PICO_DEFAULT_LED_PIN; + } + // busy_wait_ms(1000); + + i2c_write_blocking(i2c_default, 0x70 , dreiachtel, 17 ,false); + for(int j = 0; j <10000000; j++){ + volatile int i = 0; + // *outregister = 0x01 << PICO_DEFAULT_LED_PIN; + } + // busy_wait_ms(1000); + + i2c_write_blocking(i2c_default, 0x70 , hälfte, 17 ,false); + for(int j = 0; j <10000000; j++){ + volatile int i = 0; + // *outregister = 0x01 << PICO_DEFAULT_LED_PIN; } + // busy_wait_ms(1000); + i2c_write_blocking(i2c_default, 0x70 , fünfachtel, 17 ,false); + for(int j = 0; j <10000000; j++){ + volatile int i = 0; + // *outregister = 0x01 << PICO_DEFAULT_LED_PIN; + } + // busy_wait_ms(1000); + + i2c_write_blocking(i2c_default, 0x70 , dreiviertel, 17 ,false); + for(int j = 0; j <10000000; j++){ + volatile int i = 0; + // *outregister = 0x01 << PICO_DEFAULT_LED_PIN; + } + // busy_wait_ms(1000); + + i2c_write_blocking(i2c_default, 0x70 , siebenachtel, 17 ,false); + for(int j = 0; j <10000000; j++){ + volatile int i = 0; + // *outregister = 0x01 << PICO_DEFAULT_LED_PIN; + } + // busy_wait_ms(1000); + + i2c_write_blocking(i2c_default, 0x70 , ganzes, 17 ,false); + for(int j = 0; j <10000000; j++){ + 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); -- GitLab