Skip to content

Commit

Permalink
Correct calculation of byte and bit position in generated e2p header …
Browse files Browse the repository at this point in the history
…files.
  • Loading branch information
breaker27 committed Mar 23, 2014
1 parent 2eb6cd8 commit 9ad8903
Showing 1 changed file with 7 additions and 6 deletions.
Expand Up @@ -422,13 +422,14 @@ private String byteAccessStr(int offset, int bits, boolean isArray)
{
if (isArray)
{
if ((offset % 8) == 0)
if ((bits % 8) == 0)
{
return (offset / 8) + " + index";
int bytesPerValue = bits / 8;
return (offset / 8) + " + (uint16_t)index * " + bytesPerValue;
}
else
{
return "(" + offset + " + (uint16_t)index * 8) / 8";
return "(" + offset + " + (uint16_t)index * " + bits + ") / 8";
}
}
else
Expand All @@ -448,13 +449,13 @@ private String bitAccessStr(int offset, int bits, boolean isArray)
{
if (isArray)
{
if ((offset % 8) == 0)
if ((bits % 8) == 0)
{
return (offset / 8) + " + index";
return "" + (offset % 8);
}
else
{
return "(" + offset + " + (uint16_t)index * 8) % 8";
return "(" + offset + " + (uint16_t)index * " + bits + ") % 8";
}
}
else
Expand Down

0 comments on commit 9ad8903

Please sign in to comment.