From d38d1f7abd1b91b216172f1d356cec2124e62fac Mon Sep 17 00:00:00 2001
From: ThomasintAnker <thomasintanker1@gmail.com>
Date: Fri, 21 Jun 2024 15:03:06 +0200
Subject: WIP Added puzzle module i2c research

---
 docs/research.adoc | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

(limited to 'docs/research.adoc')

diff --git a/docs/research.adoc b/docs/research.adoc
index a6ef255..4f64538 100644
--- a/docs/research.adoc
+++ b/docs/research.adoc
@@ -522,6 +522,49 @@ The way these puzzles are solved has been summarized in this research document,
 but the most complete versions of how to solve these puzzles are given in the
 group's respective design document.
 
+== I^2^C (Thomas)
+
+=== Research question
+
+How can we use I^2^C for the internal communication between puzzle modules 
+and the main controller, and how can we detect new puzzle modules using I^2^C?
+
+=== Puzzle Module Detection
+
+Puzzle module detection is vital to the puzzelbox, as this allows changing the 
+puzzles without much software or hardware configuration needed. An option will 
+be given for the choice of main controller (RP2040); namely to scan the full 
+I^2^C bus for responsive slaves. The RPI Pico SDK has an API for I^2^C which 
+also supports functions create a bus scanning function. An example of just the 
+bus scan function according to the API examples can be found in the code block 
+below.
+
+[source, c]
+----
+#include <stdio.h>
+#include "pico/stdlib.h"
+#include "hardware/i2c.h"
+
+void bus_scan() {
+    int ret;
+    uint8_t rxdata;
+    
+    for (int addr = 0; addr < (1 << 7); ++addr) {
+        ret = i2c_read_blocking(i2c_default, addr, &rxdata, 1, false);
+        printf(ret < 0 ? "." : "@");
+        printf(addr % 16 == 15 ? "\n" : "  ");
+    }
+    printf("Done.\n");
+}
+
+----
+
+// TODO: references (API) & code block naming?
+
+=== Arduino
+
+
+
 == Research of hardware designs of previous groups (21-22 and 22-23)
 
 This part of the research looks at the hardware designs of the previous groups
-- 
cgit v1.2.3


From 454032718251eac7788c4d1b45767c18c0aa11ed Mon Sep 17 00:00:00 2001
From: ThomasintAnker <thomasintanker1@gmail.com>
Date: Fri, 21 Jun 2024 15:23:24 +0200
Subject: Changed order of researcg

---
 docs/research.adoc | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

(limited to 'docs/research.adoc')

diff --git a/docs/research.adoc b/docs/research.adoc
index 4f64538..65cc68b 100644
--- a/docs/research.adoc
+++ b/docs/research.adoc
@@ -526,8 +526,7 @@ group's respective design document.
 
 === Research question
 
-How can we use I^2^C for the internal communication between puzzle modules 
-and the main controller, and how can we detect new puzzle modules using I^2^C?
+How can we use I^2^C for the puzzle module detection?
 
 === Puzzle Module Detection
 
@@ -535,9 +534,9 @@ Puzzle module detection is vital to the puzzelbox, as this allows changing the
 puzzles without much software or hardware configuration needed. An option will 
 be given for the choice of main controller (RP2040); namely to scan the full 
 I^2^C bus for responsive slaves. The RPI Pico SDK has an API for I^2^C which 
-also supports functions create a bus scanning function. An example of just the 
-bus scan function according to the API examples can be found in the code block 
-below.
+also supports functions create a bus scanning function. An example of this 
+bus scan function, according to the API examples, can be found in the pseudo 
+code below.
 
 [source, c]
 ----
@@ -556,14 +555,20 @@ void bus_scan() {
     }
     printf("Done.\n");
 }
-
 ----
 
-// TODO: references (API) & code block naming?
-
-=== Arduino
-
+The bus scan function tries to read data from all possible I^2^C addresses, 
+and prints a table which shows what the addresses are from found I^2^C 
+slaves. This is possible due to the i2c_read_blocking function, which returns 
+the length of the read data if the slave address is in use (in this case 1) or 
+a number below 0 if the slave address is not in use. The puzzelbox, however, 
+has the 'Neotrellis' puzzle which also uses I^2^C to function. The bus scan 
+function would also see the 'Neotrellis' rgb matrix as a puzzle module (slave) 
+using this implementation. This can easily be fixed using a handshake between 
+puzzle modules and the main controller, as the 'Neotrellis' rgb matrix cannot 
+answer this handshake and is therefor not recognized as a puzzle module.
 
+// TODO: references (API) & code block naming?
 
 == Research of hardware designs of previous groups (21-22 and 22-23)
 
-- 
cgit v1.2.3


From a536385ba46e9f55414593a1c47683e2f9abe628 Mon Sep 17 00:00:00 2001
From: ThomasintAnker <thomasintanker1@gmail.com>
Date: Fri, 21 Jun 2024 15:24:28 +0200
Subject: WIP

---
 docs/research.adoc | 100 ++++++++++++++++++++++++++++-------------------------
 1 file changed, 52 insertions(+), 48 deletions(-)

(limited to 'docs/research.adoc')

diff --git a/docs/research.adoc b/docs/research.adoc
index 65cc68b..88e43a7 100644
--- a/docs/research.adoc
+++ b/docs/research.adoc
@@ -400,6 +400,58 @@ testing. Including mocking tests, a large amount of assertions, multiple test
 with different input support, and lastly being supported in the newest
 non-experimental version of {cpp}. 
 
+== I^2^C (Thomas)
+
+=== Research question
+
+How can we use I^2^C for the puzzle module detection?
+
+=== Puzzle Module Detection
+
+Puzzle module detection is vital to the puzzelbox, as this allows changing the 
+puzzles without much software or hardware configuration needed. An option will 
+be given for the choice of main controller (RP2040); namely to scan the full 
+I^2^C bus for responsive slaves. The RPI Pico SDK has an API for I^2^C which 
+also supports functions create a bus scanning function. An example of this 
+bus scan function, according to the API examples, can be found in the pseudo 
+code below.
+
+[source, c]
+----
+#include <stdio.h>
+#include "pico/stdlib.h"
+#include "hardware/i2c.h"
+
+void bus_scan() {
+    int ret;
+    uint8_t rxdata;
+    
+    for (int addr = 0; addr < (1 << 7); ++addr) {
+        ret = i2c_read_blocking(i2c_default, addr, &rxdata, 1, false);
+        printf(ret < 0 ? "." : "@");
+        printf(addr % 16 == 15 ? "\n" : "  ");
+    }
+    printf("Done.\n");
+}
+----
+
+The bus scan function tries to read data from all possible I^2^C addresses, 
+and prints a table which shows what the addresses are from found I^2^C 
+slaves. This is possible due to the i2c_read_blocking function, which returns 
+the length of the read data if the slave address is in use (in this case 1) or 
+a number below 0 if the slave address is not in use. The puzzelbox, however, 
+has the 'Neotrellis' puzzle which also uses I^2^C to function. The bus scan 
+function would also see the 'Neotrellis' rgb matrix as a puzzle module (slave) 
+using this implementation. This can easily be fixed using a handshake between 
+puzzle modules and the main controller, as the 'Neotrellis' rgb matrix cannot 
+answer this handshake and is therefor not recognized as a puzzle module.
+
+// TODO: references (API) & code block naming?
+
+=== Welke microcontroller famillies zijn slave addresseerbaar while in master die ook multimaster vriendelijk zijn.
+
+=== multi master == standaard?
+
 == Original Puzzle Box Functionality Research (Thomas)
 
 === Research question
@@ -522,54 +574,6 @@ The way these puzzles are solved has been summarized in this research document,
 but the most complete versions of how to solve these puzzles are given in the
 group's respective design document.
 
-== I^2^C (Thomas)
-
-=== Research question
-
-How can we use I^2^C for the puzzle module detection?
-
-=== Puzzle Module Detection
-
-Puzzle module detection is vital to the puzzelbox, as this allows changing the 
-puzzles without much software or hardware configuration needed. An option will 
-be given for the choice of main controller (RP2040); namely to scan the full 
-I^2^C bus for responsive slaves. The RPI Pico SDK has an API for I^2^C which 
-also supports functions create a bus scanning function. An example of this 
-bus scan function, according to the API examples, can be found in the pseudo 
-code below.
-
-[source, c]
-----
-#include <stdio.h>
-#include "pico/stdlib.h"
-#include "hardware/i2c.h"
-
-void bus_scan() {
-    int ret;
-    uint8_t rxdata;
-    
-    for (int addr = 0; addr < (1 << 7); ++addr) {
-        ret = i2c_read_blocking(i2c_default, addr, &rxdata, 1, false);
-        printf(ret < 0 ? "." : "@");
-        printf(addr % 16 == 15 ? "\n" : "  ");
-    }
-    printf("Done.\n");
-}
-----
-
-The bus scan function tries to read data from all possible I^2^C addresses, 
-and prints a table which shows what the addresses are from found I^2^C 
-slaves. This is possible due to the i2c_read_blocking function, which returns 
-the length of the read data if the slave address is in use (in this case 1) or 
-a number below 0 if the slave address is not in use. The puzzelbox, however, 
-has the 'Neotrellis' puzzle which also uses I^2^C to function. The bus scan 
-function would also see the 'Neotrellis' rgb matrix as a puzzle module (slave) 
-using this implementation. This can easily be fixed using a handshake between 
-puzzle modules and the main controller, as the 'Neotrellis' rgb matrix cannot 
-answer this handshake and is therefor not recognized as a puzzle module.
-
-// TODO: references (API) & code block naming?
-
 == Research of hardware designs of previous groups (21-22 and 22-23)
 
 This part of the research looks at the hardware designs of the previous groups
-- 
cgit v1.2.3


From 99dc241919bf6ea3cd3c06b77c7d8ad04c7d1fdf Mon Sep 17 00:00:00 2001
From: ThomasintAnker <thomasintanker1@gmail.com>
Date: Sat, 22 Jun 2024 20:11:26 +0200
Subject: Added i2c mcu research

---
 docs/research.adoc | 53 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 48 insertions(+), 5 deletions(-)

(limited to 'docs/research.adoc')

diff --git a/docs/research.adoc b/docs/research.adoc
index 88e43a7..80e32f2 100644
--- a/docs/research.adoc
+++ b/docs/research.adoc
@@ -404,7 +404,54 @@ non-experimental version of {cpp}.
 
 === Research question
 
-How can we use I^2^C for the puzzle module detection?
+How can we use I^2^C for the puzzle module detection and communication?
+
+=== Puzzle Module and Main Controller Communication
+
+Research from project group 21/22 shows that the I^2^C protocol is the best 
+option for communication between the puzzle modules and the main controller. 
+This research section extends the previous section about which MCU is suitable 
+for the puzzle bus, as we have found vital I^2^C limitations with the 
+controller we had chosen. See the handover document for the found limitations.
+
+// TODO: REFERENCES
+
+==== PIC16F15276
+
+The PIC16F15276 MCU shows possibilities to be addressable as a slave while 
+being in master mode. However, this can not be confirmed without physical 
+testing due to the datasheet not mentioning whether it can or can not support 
+this function. It is possible to use this MCU without the aforementioned 
+functionality by manually changing the RCEN register to manually set the 
+MCU to 'receiving' I^2^C instructions, however this also requires a degree of 
+testing.
+
+// TODO: Add the following reference:
+// PIC16F15276 - 25.2.4.3
+// https://ww1.microchip.com/downloads/aemDocuments/documents/MCU08/ProductDocuments/DataSheets/PIC16F15256-74-75-76-Microcontroller-Data-Sheet-40002305.pdf
+
+==== ESP32
+
+The ESP32, like the PIC16F15276, shows possibilities to be addressable as a 
+slave while being in master mode, this also requires testing however. In the 
+case of the ESP32 it is possible to use the two I^2^C peripherals to achieve 
+roughly the same goal. This can be done by having one of the two peripherals 
+be initiated in master mode while the other peripheral is initiated in slave 
+mode. Allowing the MCU to send and recieve data to the I^2^C bus. This does 
+introduce increased code complexity but is a valid option if it goes through 
+testing.
+
+// TODO: Add the following reference:
+// https://docs.espressif.com/projects/esp-idf/en/v4.3/esp32/api-reference/peripherals/i2c.html
+// https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf#i2c
+// https://www.bitsandparts.nl/documentation/482/ESP32_Specifications_EN_v1.pdf
+
+==== RP2040
+
+As written in the handover document, the RP2040 does not support being 
+addressed as a slave while being in master mode. It does however, just like 
+the ESP32 have two I^2^C peripherals. Meaning the same theory can be applied 
+on this MCU.
 
 === Puzzle Module Detection
 
@@ -448,10 +495,6 @@ answer this handshake and is therefor not recognized as a puzzle module.
 
 // TODO: references (API) & code block naming?
 
-=== Welke microcontroller famillies zijn slave addresseerbaar while in master die ook multimaster vriendelijk zijn.
-
-=== multi master == standaard?
-
 == Original Puzzle Box Functionality Research (Thomas)
 
 === Research question
-- 
cgit v1.2.3


From 4eec490cdfdcf6ea4283c2d069ef147fe2365d2b Mon Sep 17 00:00:00 2001
From: ThomasintAnker <thomasintanker1@gmail.com>
Date: Sun, 23 Jun 2024 10:15:55 +0200
Subject: Improved i2c researcg

---
 docs/research.adoc | 64 ++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 40 insertions(+), 24 deletions(-)

(limited to 'docs/research.adoc')

diff --git a/docs/research.adoc b/docs/research.adoc
index 80e32f2..9da6303 100644
--- a/docs/research.adoc
+++ b/docs/research.adoc
@@ -415,43 +415,59 @@ for the puzzle bus, as we have found vital I^2^C limitations with the
 controller we had chosen. See the handover document for the found limitations.
 
 // TODO: REFERENCES
+// TODO: Find synonym for 'vital'
 
-==== PIC16F15276
+==== MCUs Supporting Master Addressable as Slave
 
-The PIC16F15276 MCU shows possibilities to be addressable as a slave while 
-being in master mode. However, this can not be confirmed without physical 
-testing due to the datasheet not mentioning whether it can or can not support 
-this function. It is possible to use this MCU without the aforementioned 
-functionality by manually changing the RCEN register to manually set the 
-MCU to 'receiving' I^2^C instructions, however this also requires a degree of 
-testing.
+===== Atmega328p
+
+The Atmega328p has multi-master support, where the MCU is addressable as a 
+slave while being in master mode. This has been confirmed using the Arduino 
+wire library on both the Arduino Mega and the Arduino Uno.
+
+===== PIC16F15276 & ESP32
+
+Both the PIC16F15276 and the ESP32 MCUs show possibilities to be addressable as a slave while being in master mode. However, at the moment of writing this 
+has yet to be tested.
 
 // TODO: Add the following reference:
 // PIC16F15276 - 25.2.4.3
 // https://ww1.microchip.com/downloads/aemDocuments/documents/MCU08/ProductDocuments/DataSheets/PIC16F15256-74-75-76-Microcontroller-Data-Sheet-40002305.pdf
 
-==== ESP32
-
-The ESP32, like the PIC16F15276, shows possibilities to be addressable as a 
-slave while being in master mode, this also requires testing however. In the 
-case of the ESP32 it is possible to use the two I^2^C peripherals to achieve 
-roughly the same goal. This can be done by having one of the two peripherals 
-be initiated in master mode while the other peripheral is initiated in slave 
-mode. Allowing the MCU to send and recieve data to the I^2^C bus. This does 
-introduce increased code complexity but is a valid option if it goes through 
-testing.
-
 // TODO: Add the following reference:
 // https://docs.espressif.com/projects/esp-idf/en/v4.3/esp32/api-reference/peripherals/i2c.html
 // https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf#i2c
 // https://www.bitsandparts.nl/documentation/482/ESP32_Specifications_EN_v1.pdf
 
-==== RP2040
+==== Alternatives
+
+===== PIC16F15276 Registers
+
+In the case of the PIC16F15276 not support master addressable as slave the 
+following approach would most likely work. As the PIC16F15276 uses specific 
+registers for its master receive functions, namely the RCEN register, it can 
+be manually set to receive data from the I^2^C bus. However, this also has 
+yet to be tested.
+
+// TODO: Add the following reference:
+// PIC16F15276 - 25.2.4.3
+// https://ww1.microchip.com/downloads/aemDocuments/documents/MCU08/ProductDocuments/DataSheets/PIC16F15256-74-75-76-Microcontroller-Data-Sheet-40002305.pdf
+
+===== Multiple I^2^C Peripherals
+
+==== ESP32 & RP2040
+
+The ESP32 and the RP2040 both have multiple peripherals for I^2^C 
+communication, while also supporting simultaneous configuration. This allows 
+both two I^2^C peripherals to be active, one being configured as a master and 
+the other being configured as a slave. This enables the controller to send and 
+receive data to the I^2^C bus without much difficulty. This does introduce 
+increased code complexity but is a valid option if it is succesful in testing.
 
-As written in the handover document, the RP2040 does not support being 
-addressed as a slave while being in master mode. It does however, just like 
-the ESP32 have two I^2^C peripherals. Meaning the same theory can be applied 
-on this MCU.
+// TODO: Add the following reference:
+// https://docs.espressif.com/projects/esp-idf/en/v4.3/esp32/api-reference/peripherals/i2c.html
+// https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf#i2c
+// https://www.bitsandparts.nl/documentation/482/ESP32_Specifications_EN_v1.pdf
 
 === Puzzle Module Detection
 
-- 
cgit v1.2.3

