Skip to content
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

Fix #220: Add class cFram_FM24CL16B and class cFram2k use it #221

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ cCommandStream KEYWORD1
cCompletion KEYWORD1
cFlash_AT25SF081 KEYWORD1
cFram KEYWORD1
cFram_FM24CL16B KEYWORD1
cFram2k KEYWORD1
cFram8k KEYWORD1
cFramStorage KEYWORD1
Expand Down
6 changes: 3 additions & 3 deletions src/Catena_Fram2k.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ Revision history:
# include "Catena_Fram.h"
#endif

#ifndef _ADAFRUIT_FRAM_I2C_H_
# include <Adafruit_FRAM_I2C.h>
#ifndef _CATENA_FRAM_FM24CL16B_H_
# include "Catena_Fram_fm24cl16b.h"
#endif

/****************************************************************************\
Expand Down Expand Up @@ -84,7 +84,7 @@ class cFram2k : public cFram

protected:
private:
Adafruit_FRAM_I2C m_hw;
cFram_FM24CL16B m_hw;
};

}; // namespace McciCatena
Expand Down
66 changes: 66 additions & 0 deletions src/Catena_Fram_fm24cl16b.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*

Module: Catena_Fram_fm24cl16b.h

Function:
class cFram_FM24CL16B: 2K I2C FRAM

Copyright notice:
See accompanying LICENSE file.

Author:
ChaeHee Won, MCCI Corporation September 2019

*/

#ifndef _CATENA_FRAM_FM24CL16B_H_ /* prevent multiple includes */
#define _CATENA_FRAM_FM24CL16B_H_

#pragma once

#include <Arduino.h>
#include <Wire.h>

namespace McciCatena {

class cFram_FM24CL16B
{
public:
cFram_FM24CL16B(void);

static constexpr uint8_t CATENA_FM24CL16B_ADDRESS = 0x50;
static constexpr int CATENA_FM24CL16B_SLAVE_ID = (0xF8 >> 1);

// set up and probe device
boolean begin(uint8_t DeviceAddress = CATENA_FM24CL16B_ADDRESS,
TwoWire *pWire = &Wire);

// write a single byte
void write8(uint16_t framAddr, uint8_t value);

// write a buffer
void write(uint16_t framAddr, uint8_t const *pBuffer, size_t nBuffer);

// read a single byte
uint8_t read8(uint16_t framAddr);

// read a buffer
size_t read(uint16_t framAddr, uint8_t *pBuffer, size_t nBuffer);

// read ID
void readId(uint16_t *pManufactureId, uint16_t *pProductId);

private:
uint8_t m_DeviceAddress;
boolean m_Initialized;
boolean m_PowerDown;
TwoWire * m_pWire;

void prepIO(void) const;
uint8_t getDeviceAddress(uint16_t framAddr) const;
};

} // namespace McciCatena

/**** end of Catena_Fram_fm24cl16b.h ****/
#endif /* _CATENA_FRAM_FM24CL16B_H_ */
35 changes: 6 additions & 29 deletions src/Catena_Mb85rc64ta.h
Original file line number Diff line number Diff line change
@@ -1,36 +1,15 @@
/* Catena_Mb85rc64ta.h Wed Dec 06 2017 15:30:56 chwon */

/*

Module: Catena_Mb85rc64ta.h

Function:
class Catena_Mb85rc64ta

Version:
V0.6.0 Wed Dec 06 2017 15:30:56 chwon Edit level 2
class Catena_Mb85rc64ta: 8K I2C FRAM

Copyright notice:
This file copyright (C) 2017 by

MCCI Corporation
3520 Krums Corners Road
Ithaca, NY 14850

An unpublished work. All rights reserved.

This file is proprietary information, and may not be disclosed or
copied without the prior permission of MCCI Corporation.
See accompanying LICENSE file.

Author:
ChaeHee Won, MCCI Corporation October 2017

Revision history:
0.6.0 Fri Oct 13 2017 15:19:30 chwon
Module created.

0.6.0 Wed Dec 06 2017 15:30:56 chwon
Add readId and power control.
ChaeHee Won, MCCI Corporation October 2017

*/

Expand All @@ -42,18 +21,16 @@ Revision history:
#include <Arduino.h>
#include <Wire.h>

/* TODO: change these to enums and constepxrs in the McciCatena namespace */

#define CATENA_MB85RC64TA_ADDRESS (0x50)
#define CATENA_MB85RC64TA_SLAVE_ID (0xF8 >> 1)

namespace McciCatena {

class Catena_Mb85rc64ta
{
public:
Catena_Mb85rc64ta(void);

static constexpr uint8_t CATENA_MB85RC64TA_ADDRESS = 0x50;
static constexpr int CATENA_MB85RC64TA_SLAVE_ID = (0xF8 >> 1);

// set up and probe device
boolean begin(uint8_t DeviceAddress = CATENA_MB85RC64TA_ADDRESS,
TwoWire *pWire = &Wire);
Expand Down
6 changes: 3 additions & 3 deletions src/lib/Catena_Fram8k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Name: McciCatena::cFram8k::begin()
McciCatena::cFram8k::begin()

Description:
Initialize an cFram2K object prior to operation.
Initialize an cFram8k object prior to operation.

Returns:
true for success, false for failure.
Expand All @@ -84,7 +84,7 @@ McciCatena::cFram8k::begin()

/*

Name: McciCatena::cFram2K::read()
Name: McciCatena::cFram8k::read()

Function:
Read a string of bytes from the FRAM
Expand Down Expand Up @@ -117,7 +117,7 @@ McciCatena::cFram8k::read(

/*

Name: McciCatena::cFram2K::write()
Name: McciCatena::cFram8k::write()

Function:
Write a sequence of bytes to the FRAM.
Expand Down
Loading