Skip to content

Commit

Permalink
Generic I2C and GenericSWI2C component with custom bus handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Erich Styger committed Oct 17, 2015
1 parent a97a67d commit 98b7927
Show file tree
Hide file tree
Showing 12 changed files with 520 additions and 102 deletions.
87 changes: 74 additions & 13 deletions Beans/GenericI2C/GenericI2C.bean
Expand Up @@ -4,7 +4,7 @@
<Name>GenericI2C</Name>
<Description>Generic high level I2C Driver on top of the I2C hardware driver</Description>
<Author>Erich Styger</Author>
<Version>01.023</Version>
<Version>01.026</Version>
<Icon>Generic2C</Icon>
<TypesFiles>PE,GenericI2C\GenericI2C</TypesFiles>
<FileVersion>6</FileVersion>
Expand All @@ -19,7 +19,7 @@
<BW_NeedUst>2</BW_NeedUst>
<BW_NeedCns>0</BW_NeedCns>
<BeanStatus>PROPOSAL</BeanStatus>
<Copyright>License : Open Source (LGPL)\nCopyright : (c) Copyright Erich Styger, 2013-2014, all rights reserved.\nhttp : www.mcuoneclipse.com\n\nThis an open source software implementing software using Processor Expert.\nThis is a free software and is opened for education, research and commercial developments under license policy of following terms:\n* This is a free software and there is NO WARRANTY.\n* No restriction on use. You can use, modify and redistribute it for personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.\n* Redistributions of source code must retain the above copyright notice.</Copyright>
<Copyright>License : Open Source (LGPL)\nCopyright : (c) Copyright Erich Styger, 2013-2015, all rights reserved.\nhttp : www.mcuoneclipse.com\n\nThis an open source software implementing software using Processor Expert.\nThis is a free software and is opened for education, research and commercial developments under license policy of following terms:\n* This is a free software and there is NO WARRANTY.\n* No restriction on use. You can use, modify and redistribute it for personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.\n* Redistributions of source code must retain the above copyright notice.</Copyright>
<Category>SW-User Components</Category>
<DemoDriver>no</DemoDriver>
<Shortcut>GI2C</Shortcut>
Expand Down Expand Up @@ -127,7 +127,7 @@
<BoldName>true</BoldName>
<EditLine>false</EditLine>
<Description>Disabled</Description>
<Expanded>Yes</Expanded>
<Expanded>No</Expanded>
<DefaultValue>false</DefaultValue>
<DefineSymbol>YES_NO</DefineSymbol>
<IfDisabled>setNOTHING</IfDisabled>
Expand Down Expand Up @@ -156,7 +156,7 @@
<BoldName>true</BoldName>
<EditLine>false</EditLine>
<Description>Disabled</Description>
<Expanded>Yes</Expanded>
<Expanded>No</Expanded>
<DefaultValue>false</DefaultValue>
<DefineSymbol>YES_NO</DefineSymbol>
<IfDisabled>setNOTHING</IfDisabled>
Expand Down Expand Up @@ -386,6 +386,53 @@
</Declarations>
</TMthdItem>
</Method>
<Method>
<TMthdItem>
<Name>WriteBlock</Name>
<Symbol>WriteBlock</Symbol>
<TypeSpec>typeMethod</TypeSpec>
<Hint>Write a block to the device.</Hint>
<ItemLevel>BASIC</ItemLevel>
<EditLine>false</EditLine>
<TypeSpecNameChangeAble>false</TypeSpecNameChangeAble>
<DefaultIndex>0</DefaultIndex>
<TextValueIndex>false</TextValueIndex>
<RuntimeProperty>false</RuntimeProperty>
<CanDelete>false</CanDelete>
<IconPopup>false</IconPopup>
<DefaultValue>true</DefaultValue>
<Popup>false</Popup>
<PublicMethod>true</PublicMethod>
<IsAssembler>false</IsAssembler>
<InDefinition>true</InDefinition>
<ReturnType>8bit unsigned</ReturnType>
<RetHint>Error code</RetHint>
<ParamCount>3</ParamCount>
<Parameter>
<ParName>data</ParName>
<ParType>pointer</ParType>
<ParPassing>Value</ParPassing>
<ParHint>Data write buffer</ParHint>
</Parameter>
<Parameter>
<ParName>dataSize</ParName>
<ParType>16bit unsigned</ParType>
<ParPassing>Value</ParPassing>
<ParHint/>
</Parameter>
<Parameter>
<ParName>flags</ParName>
<ParType>8bit unsigned</ParType>
<ParPassing>Value</ParPassing>
<ParHint>flags for the transaction</ParHint>
<ParUserDeclaration>%'ModuleName'_EnumSendFlags flags</ParUserDeclaration>
</Parameter>
<Scope>PRIVATE</Scope>
<Declarations>
<ANSIC>byte #M#_#C#(void* data, word dataSize, %'ModuleName'_EnumSendFlags flags)</ANSIC>
</Declarations>
</TMthdItem>
</Method>
<Method>
<TMthdItem>
<Name>ReadBlock</Name>
Expand Down Expand Up @@ -435,10 +482,10 @@
</Method>
<Method>
<TMthdItem>
<Name>WriteBlock</Name>
<Symbol>WriteBlock</Symbol>
<Name>ReadBlockGeneric</Name>
<Symbol>ReadBlockGeneric</Symbol>
<TypeSpec>typeMethod</TypeSpec>
<Hint>Write a block to the device.</Hint>
<Hint>Read from the device a block with using additional control and flags.</Hint>
<ItemLevel>BASIC</ItemLevel>
<EditLine>false</EditLine>
<TypeSpecNameChangeAble>false</TypeSpecNameChangeAble>
Expand All @@ -454,29 +501,43 @@
<InDefinition>true</InDefinition>
<ReturnType>8bit unsigned</ReturnType>
<RetHint>Error code</RetHint>
<ParamCount>3</ParamCount>
<ParamCount>5</ParamCount>
<Parameter>
<ParName>data</ParName>
<ParType>pointer</ParType>
<ParPassing>Value</ParPassing>
<ParHint>Data write buffer</ParHint>
<ParHint>Read buffer</ParHint>
</Parameter>
<Parameter>
<ParName>dataSize</ParName>
<ParType>16bit unsigned</ParType>
<ParPassing>Value</ParPassing>
<ParHint/>
<ParHint>Size of read buffer</ParHint>
</Parameter>
<Parameter>
<ParName>flags</ParName>
<ParName>flagsSend</ParName>
<ParType>8bit unsigned</ParType>
<ParPassing>Value</ParPassing>
<ParHint>flags for the transaction</ParHint>
<ParHint>flags for the send transaction</ParHint>
<ParUserDeclaration>%'ModuleName'_EnumSendFlags flags</ParUserDeclaration>
</Parameter>
<Parameter>
<ParName>flagsStart</ParName>
<ParType>8bit unsigned</ParType>
<ParPassing>Value</ParPassing>
<ParHint>Start flags</ParHint>
<ParUserDeclaration>%'ModuleName'_EnumStartFlags flagsStart</ParUserDeclaration>
</Parameter>
<Parameter>
<ParName>flagsAck</ParName>
<ParType>8bit unsigned</ParType>
<ParPassing>Value</ParPassing>
<ParHint>Acknowledge flags</ParHint>
<ParUserDeclaration>%'ModuleName'_EnumAckFlags flagsAck</ParUserDeclaration>
</Parameter>
<Scope>PRIVATE</Scope>
<Declarations>
<ANSIC>byte #M#_#C#(void* data, word dataSize, %'ModuleName'_EnumSendFlags flags)</ANSIC>
<ANSIC>byte #M#_#C#(void* data, word dataSize, %'ModuleName'_EnumSendFlags flags, %'ModuleName'_EnumStartFlags flagsStart, %'ModuleName'_EnumAckFlags flagsAck)</ANSIC>
</Declarations>
</TMthdItem>
</Method>
Expand Down
2 changes: 1 addition & 1 deletion Beans/GenericI2C/GenericI2C.uis
@@ -1,6 +1,6 @@

[USED_FACES]
BeanVersion=01.023
BeanVersion=01.026

InterfacesCount=5

Expand Down
30 changes: 23 additions & 7 deletions Beans/GenericI2C/GenericI2CMethods.html
Expand Up @@ -247,6 +247,20 @@
<!---VER_SPEC_END DON'T CHANGE THIS LINE-->
</ul><br />
</li>
<li><a name="WriteBlock">
<b>WriteBlock</b></a>
- Write a block to the device.
<ul>
<!---VER_SPEC #ANSIC# DON'T CHANGE THIS LINE-->
<br /><i>ANSIC prototype:</i> byte WriteBlock(void* data, word dataSize, <i>ComponentName_</i>EnumSendFlags flags)<br />
<!---VER_SPEC_END DON'T CHANGE THIS LINE-->
<li><i>data:void*</i> - Data write buffer</li>
<li><i>dataSize:word</i> - no hint</li>
<li><i>flags:byte</i> - flags for the transaction</li>
<li><i>Return value:byte</i> - Error code
</li>
</ul><br />
</li>
<li><a name="ReadBlock">
<b>ReadBlock</b></a>
- Read from the device a block.
Expand All @@ -261,16 +275,18 @@
</li>
</ul><br />
</li>
<li><a name="WriteBlock">
<b>WriteBlock</b></a>
- Write a block to the device.
<li><a name="ReadBlockGeneric">
<b>ReadBlockGeneric</b></a>
- Read from the device a block with using additional control and flags.
<ul>
<!---VER_SPEC #ANSIC# DON'T CHANGE THIS LINE-->
<br /><i>ANSIC prototype:</i> byte WriteBlock(void* data, word dataSize, <i>ComponentName_</i>EnumSendFlags flags)<br />
<br /><i>ANSIC prototype:</i> byte ReadBlockGeneric(void* data, word dataSize, <i>ComponentName_</i>EnumSendFlags flags, <i>ComponentName_</i>EnumStartFlags flagsStart, <i>ComponentName_</i>EnumAckFlags flagsAck)<br />
<!---VER_SPEC_END DON'T CHANGE THIS LINE-->
<li><i>data:void*</i> - Data write buffer</li>
<li><i>dataSize:word</i> - no hint</li>
<li><i>flags:byte</i> - flags for the transaction</li>
<li><i>data:void*</i> - Read buffer</li>
<li><i>dataSize:word</i> - Size of read buffer</li>
<li><i>flagsSend:byte</i> - flags for the send transaction</li>
<li><i>flagsStart:byte</i> - Start flags</li>
<li><i>flagsAck:byte</i> - Acknowledge flags</li>
<li><i>Return value:byte</i> - Error code
</li>
</ul><br />
Expand Down
133 changes: 97 additions & 36 deletions Beans/GenericSWI2C/GenericSWI2C.bean
Expand Up @@ -4,7 +4,7 @@
<Name>GenericSWI2C</Name>
<Description>Generic Software I2C</Description>
<Author>Erich Styger, Marc Lindahl</Author>
<Version>01.007</Version>
<Version>01.015</Version>
<Icon>GenericSWI2C</Icon>
<TypesFiles>PE,GenericSWI2C\GenericSWI2C</TypesFiles>
<FileVersion>6</FileVersion>
Expand All @@ -19,7 +19,7 @@
<BW_NeedUst>0</BW_NeedUst>
<BW_NeedCns>0</BW_NeedCns>
<BeanStatus>PROPOSAL</BeanStatus>
<Copyright>(c) Copyright Freescale Semiconductor, 2014\nhttp : www.freescale.com</Copyright>
<Copyright>(c) Copyright Freescale Semiconductor, 2014-2015\nhttp : www.freescale.com\nChanged and extended: Erich Styger, 2014-2015</Copyright>
<Category>CPU External Devices-Communication</Category>
<DemoDriver>no</DemoDriver>
<BeanLevel>Low</BeanLevel>
Expand Down Expand Up @@ -286,40 +286,6 @@
</Declarations>
</TMthdItem>
</Method>
<Method>
<TMthdItem>
<Name>SetAck</Name>
<Symbol>SetAck</Symbol>
<TypeSpec>typeMethod</TypeSpec>
<Hint>The method sends ACK to the bus.</Hint>
<ItemLevel>BASIC</ItemLevel>
<EditLine>false</EditLine>
<TypeSpecNameChangeAble>false</TypeSpecNameChangeAble>
<DefaultIndex>0</DefaultIndex>
<TextValueIndex>false</TextValueIndex>
<RuntimeProperty>false</RuntimeProperty>
<CanDelete>false</CanDelete>
<IconPopup>false</IconPopup>
<DefaultValue>true</DefaultValue>
<Popup>false</Popup>
<PublicMethod>false</PublicMethod>
<IsAssembler>false</IsAssembler>
<InDefinition>false</InDefinition>
<ReturnType>void</ReturnType>
<RetHint>none</RetHint>
<ParamCount>1</ParamCount>
<Parameter>
<ParName>Ack</ParName>
<ParType>Boolean</ParType>
<ParPassing>Value</ParPassing>
<ParHint>If acknowledge is high or low</ParHint>
</Parameter>
<Scope>PRIVATE</Scope>
<Declarations>
<ANSIC>void #M#_#C#(bool Ack)</ANSIC>
</Declarations>
</TMthdItem>
</Method>
<Method>
<TMthdItem>
<Name>InternalStop</Name>
Expand Down Expand Up @@ -585,6 +551,101 @@
</Declarations>
</TMthdItem>
</Method>
<Method>
<TMthdItem>
<Name>RecvBlockCustom</Name>
<Symbol>RecvBlockCustom</Symbol>
<TypeSpec>typeMethod</TypeSpec>
<Hint>Same as RecvBlock(), but with additional flags to control the bus transfer.</Hint>
<ItemLevel>BASIC</ItemLevel>
<EditLine>false</EditLine>
<TypeSpecNameChangeAble>false</TypeSpecNameChangeAble>
<DefaultIndex>0</DefaultIndex>
<TextValueIndex>false</TextValueIndex>
<RuntimeProperty>false</RuntimeProperty>
<CanDelete>false</CanDelete>
<IconPopup>false</IconPopup>
<DefaultValue>true</DefaultValue>
<Popup>false</Popup>
<PublicMethod>true</PublicMethod>
<IsAssembler>false</IsAssembler>
<InDefinition>true</InDefinition>
<ReturnType>8bit unsigned</ReturnType>
<RetHint>Error code, possible codes:\nERR_OK - OK\nERR_SPEED - This device does not work in the active speed mode\nERR_BUSY - The slave device is busy, it does not respond by the acknowledgment (MASTER mode only)\nERR_DISABLED - Device is disabled\nERR_BUSOFF - Clock timeout elapsed (SLAVE mode only)</RetHint>
<ParamCount>5</ParamCount>
<Parameter>
<ParName>Ptr</ParName>
<ParType>pointer</ParType>
<ParPassing>Value</ParPassing>
<ParHint>A pointer to the block space for received data</ParHint>
<ParUserDeclaration>void *Ptr</ParUserDeclaration>
</Parameter>
<Parameter>
<ParName>Siz</ParName>
<ParType>16bit unsigned</ParType>
<ParPassing>Value</ParPassing>
<ParHint>The size of the block</ParHint>
</Parameter>
<Parameter>
<ParName>Rcv</ParName>
<ParType>16bit unsigned</ParType>
<ParPassing>Address</ParPassing>
<ParHint>A pointer to the number of actually received data</ParHint>
</Parameter>
<Parameter>
<ParName>flagsStart</ParName>
<ParType>8bit unsigned</ParType>
<ParPassing>Value</ParPassing>
<ParHint>Flags for start condition</ParHint>
<ParUserDeclaration>%'ModuleName'%.EnumStartFlags flagsStart</ParUserDeclaration>
</Parameter>
<Parameter>
<ParName>flagsAck</ParName>
<ParType>8bit unsigned</ParType>
<ParPassing>Value</ParPassing>
<ParHint>Flags for Ack after last byte</ParHint>
<ParUserDeclaration>%'ModuleName'%.EnumAckFlags flagsAck</ParUserDeclaration>
</Parameter>
<Scope>PRIVATE</Scope>
<Declarations>
<ANSIC>byte #M#_#C#(void *Ptr, word Siz, word *Rcv, %'ModuleName'%.EnumStartFlags flagsStart, %'ModuleName'%.EnumAckFlags flagsAck)</ANSIC>
</Declarations>
</TMthdItem>
</Method>
<Method>
<TMthdItem>
<Name>SendAck</Name>
<Symbol>SendAck</Symbol>
<TypeSpec>typeMethod</TypeSpec>
<Hint>The method sends ACK to the bus.</Hint>
<ItemLevel>BASIC</ItemLevel>
<EditLine>false</EditLine>
<TypeSpecNameChangeAble>false</TypeSpecNameChangeAble>
<DefaultIndex>0</DefaultIndex>
<TextValueIndex>false</TextValueIndex>
<RuntimeProperty>false</RuntimeProperty>
<CanDelete>false</CanDelete>
<IconPopup>false</IconPopup>
<DefaultValue>true</DefaultValue>
<Popup>false</Popup>
<PublicMethod>true</PublicMethod>
<IsAssembler>false</IsAssembler>
<InDefinition>false</InDefinition>
<ReturnType>void</ReturnType>
<RetHint>none</RetHint>
<ParamCount>1</ParamCount>
<Parameter>
<ParName>Ack</ParName>
<ParType>Boolean</ParType>
<ParPassing>Value</ParPassing>
<ParHint>If acknowledge is high or low</ParHint>
</Parameter>
<Scope>PRIVATE</Scope>
<Declarations>
<ANSIC>void #M#_#C#(bool Ack)</ANSIC>
</Declarations>
</TMthdItem>
</Method>
<Method>
<TMthdItem>
<Name>SendStop</Name>
Expand Down
2 changes: 1 addition & 1 deletion Beans/GenericSWI2C/GenericSWI2C.uis
@@ -1,6 +1,6 @@

[USED_FACES]
BeanVersion=01.007
BeanVersion=01.015

InterfacesCount=3

Expand Down

0 comments on commit 98b7927

Please sign in to comment.