Missing files for SWo

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@236 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-10-05 08:33:15 +00:00
parent c860b5b3b4
commit 3990c23a79
9 changed files with 481 additions and 19 deletions

View File

@@ -63,14 +63,21 @@ ErrorStatus MAX5715_construct(struct MAX5715* self, const struct IODevice* devic
{
ErrorStatus returnValue = SUCCESS;
int loopCounter;
if (self != NULL)
if (!self->initialized)
{
self->device = device;
for (loopCounter = 0; loopCounter < MAX5715_NUMBER_OF_DACS; loopCounter++)
if (device != NULL)
{
self->dac[loopCounter].id = loopCounter;
self->dac[loopCounter].value = 0x0000;
for (loopCounter = 0; loopCounter < MAX5715_NUMBER_OF_DACS; loopCounter++)
{
self->dac[loopCounter].initialized = false;
}
self->device = device;
self->initialized = true;
}
else
{
returnValue = ERROR;
}
}
else
@@ -137,3 +144,51 @@ ErrorStatus MAX5715_sendCommand(const struct MAX5715* self, uint8_t command, uin
return IODevice_write(self->device, buffer, 3);
}
ErrorStatus MAX5715Channel_construct(struct MAX5715_DAC* self, struct MAX5715* parent, size_t id)
{
ErrorStatus returnValue = SUCCESS;
if (id < MAX5715_NUMBER_OF_DACS)
{
// Check that the parent has no channel already initialized on that ID
if (!parent->dac[id].initialized)
{
if (!self->initialized)
{
parent->dac[id] = *self;
self->id = id;
self->parent = parent;
self->value = 0;
self->initialized = true;
}
else
{
returnValue = ERROR;
}
}
else
{
returnValue = ERROR;
}
}
else
{
returnValue = ERROR;
}
return returnValue;
}
ErrorStatus MAX5715Channel_setValue(struct MAX5715_DAC* self, uint16_t value)
{
ErrorStatus returnValue = SUCCESS;
// Send data
// Send GO
return returnValue;
}