Skip to content

Commit

Permalink
NEED FOR UPDATE YOUR D6Arduino.rar !! added own I2C
Browse files Browse the repository at this point in the history
  • Loading branch information
atc1441 authored Jun 28, 2020
1 parent d7acf13 commit 0dd3138
Show file tree
Hide file tree
Showing 14 changed files with 10,296 additions and 114 deletions.
5 changes: 3 additions & 2 deletions ATCwatch/ATCwatch.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@



//You can use and edit the code as long as you mention me (Aaron Christophel and https://ATCnetz.de) in the source and somewhere in the menu of the working firmware, even when using small peaces of the code. :)
//If you want to use the code or parts of it commercial please write an email to: info@atcnetz.de

Expand All @@ -10,6 +9,7 @@
#include "watchdog.h"
#include "tasks.h"
#include "fast_spi.h"
#include "i2c.h"
#include "bootloader.h"
#include "inputoutput.h"
#include "backlight.h"
Expand Down Expand Up @@ -38,7 +38,8 @@ void setup() {
initRTC2();
init_tasks();
init_bootloader();
init_fast_spi();//needs to be before init_display or external flash
init_fast_spi();//needs to be before init_display and external flash
init_i2c();//needs to be before init_hrs3300, init_touch and init_accl
init_inputoutput();
init_backlight();
init_display();
Expand Down
36 changes: 7 additions & 29 deletions ATCwatch/accl.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "accl.h"
#include "Arduino.h"
#include <Wire.h>
#include "i2c.h"
#include "pinout.h"
#include "bma423.h"
//https://github.com/BoschSensortec/BMA423-Sensor-API
//Many Thanks to Daniel Thompson(https://github.com/daniel-thompson/wasp-os) to giving the Hint with the BMA423 Library
//Many Thanks to Daniel Thompson(https://github.com/daniel-thompson/wasp-os) to giving the Hint to use a modified BMA423 Library
#include "watchdog.h"
#include "inputoutput.h"
#include "ble.h"
Expand All @@ -19,8 +19,6 @@ struct bma4_accel_config accel_conf;

void init_accl() {
pinMode(BMA421_INT, INPUT);
Wire.begin();
Wire.setClock(250000);

uint16_t rslt = 0;
uint8_t init_seq_status = 0;
Expand Down Expand Up @@ -89,10 +87,8 @@ uint16_t do_accl_init() {
}

void reset_accl() {
Wire.beginTransmission(BMA4_I2C_ADDR_PRIMARY);
Wire.write(0x7E);
Wire.write(0xB6);
Wire.endTransmission();
byte standby_value[1] = {0xB6};
user_i2c_write(dev_addr, 0x7E, standby_value, 1);
}

void reset_step_counter() {
Expand Down Expand Up @@ -183,33 +179,15 @@ void get_accl_int() {

int8_t user_i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t length, void *intf_ptr)
{

set_i2cReading(true);
Wire.beginTransmission(dev_addr);
Wire.write(reg_addr);
if ( Wire.endTransmission())return -1;
Wire.requestFrom(dev_addr, length);
for (int i = 0; i < length; i++) {
*reg_data++ = Wire.read();
}
set_i2cReading(false);
return 0;
return user_i2c_read(dev_addr, reg_addr, reg_data, length);
}

int8_t user_i2c_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t length, void *intf_ptr)
{
byte error;
set_i2cReading(true);
Wire.beginTransmission(dev_addr);
Wire.write(reg_addr);
for (int i = 0; i < length; i++) {
Wire.write(*reg_data++);
}
if ( Wire.endTransmission())return -1;
set_i2cReading(false);
return 0;
return user_i2c_write(dev_addr, reg_addr, reg_data, length);
}


void user_delay(uint32_t period_us, void *intf_ptr)
{
delayMicroseconds(period_us);
Expand Down
Loading

0 comments on commit 0dd3138

Please sign in to comment.