Skip to content

Abstraction of I2C interface for discussion - STM32 #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Corrected some typos, added TTestInterface for debug
  • Loading branch information
Bruce MacKinnon authored and Bruce MacKinnon committed Oct 10, 2020
commit 8a2ad1219a0ec2bd2d0a7ca2949248389333ee0f
2 changes: 1 addition & 1 deletion src/STM32_HAL_Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
//
// NOT IMPLEMENTED YET!!
//
class STM32_HAL_Interface : public I2C_Interface {
class STM32_HAL_Interface : public I2CInterface {
public:
// TODO: WILL PASS THE HAL I2C STRUCTURE HERE
STM32_HAL_Interface() {
Expand Down
53 changes: 53 additions & 0 deletions src/TestInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (C) 2020 Bruce MacKinnon KC1FSZ
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _Test_Interface_h
#define _Test_Interface_h

#include <stdint.h>
#include <stdio.h>
#include "I2CInterface.h"

// A dummy interface for testing.
//
class TestInterface : public I2CInterface {
public:
TestInterface() {
printf("TestInterface initialized\n");
}
uint8_t check_address(uint8_t i2c_bus_addr) {
printf("check_address\n");
return 0;
}
uint8_t read(uint8_t i2c_bus_addr, uint8_t addr) {
printf("read(%x,%x)\n", i2c_bus_addr, addr);
return 0;
}
uint8_t write(uint8_t i2c_bus_addr, uint8_t addr, uint8_t data) {
printf("write(%x, %x, %x)\n", i2c_bus_addr, addr, data);
return 0;
}
uint8_t write_bulk(uint8_t i2c_bus_addr, uint8_t addr, uint8_t bytes, uint8_t *data) {
printf("write_bulk(%x, %x, ", i2c_bus_addr, addr);
for (int i = 0; i < bytes; i++) {
printf("%x ", data[i]);
}
printf(")\n");
return 0;
}
};

#endif
19 changes: 12 additions & 7 deletions src/si5351.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,22 @@

#include <stdint.h>

#define SI5351_DEMO

// Bring in the relevant interface to the I2C bus. This has been
// abstracted to allow the library to be used in differnet
// hardware environments.
#ifndef STM32
#include "STM32_HAL_Interface.h"
static STM32_HAL_Interface I2C_Interface_Instance;
#if defined(SI5351_STM32)
#include "STM32_HAL_Interface.h"
static STM32_HAL_Interface I2C_Interface_Instance;
#elif defined(SI5351_DEMO)
#include "TestInterface.h"
static TestInterface I2C_Interface_Instance;
#else
#include "Arduino.h"
#include "Wire.h"
#include "ArduinoInterface.h"
static ArduinoInterface I2C_Interface_Instance;
#include "Arduino.h"
#include "Wire.h"
#include "ArduinoInterface.h"
static ArduinoInterface I2C_Interface_Instance;
#endif

#include "si5351.h"
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy