for_gamma

Dependents:   DataPool

GammaTransporter.cpp

Committer:
Komazawa_sun
Date:
2017-08-22
Revision:
3:8487ffc7b69c
Parent:
0:519ec302e9b8

File content as of revision 3:8487ffc7b69c:

#include "GammaTransporter.h"

GammaTransporter::GammaTransporter()
:   pool(),
    i2c(SDA,SCL)
{
    
}

bool GammaTransporter::set()
{
    bool no_error = true;
    
    i2c.transport_begin(JUSHINKUN_ADDR, pool.ctrl.all_data, 10);
    no_error = no_error & i2c.read();
    i2c.transport_end();
    
    i2c.transport_begin(APPER_BODY_ADDR, pool.a.all_data, 4);
    no_error = no_error & i2c.write();
    i2c.transport_end();
    
    i2c.transport_begin(APPER_BODY_ADDR, pool.ar.all_data, 1);
    no_error = no_error & i2c.read();
    i2c.transport_end();
    
    pool.up_load();
    
    return no_error;
}

void GammaTransporter::write(int index_num, int data)
{
    pool.data_index[index_num] = data;
}   

int GammaTransporter::read(int index_num)
{
    return pool.data_index[index_num];
}

void GammaTransporter::reset()
{
    pool.reset();
}