Registered User mNo edit summary |
Registered User m (→Code) Tag: 2017 source edit |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
Where: | Where: | ||
* {{HighlightParam|<category>}} is the '''mandatory''' category article to | * {{HighlightParam|<category>}} is the '''mandatory''' category article to that the licenses and copyright associated to the snippet are refering to: | ||
** '''AI''': to refer to the AI licences page | ** '''AI''': to refer to the AI licences page | ||
** '''ISP''': to refer to the ISP licences page | |||
* {{HighlightParam|<component>}} is the '''mandatory''' component name the snippet is refering to. | * {{HighlightParam|<component>}} is the '''mandatory''' component name the snippet is refering to. | ||
* {{HighlightParam|<snippet>}} is the '''mandatory''' source code of the snippet. | * {{HighlightParam|<snippet>}} is the '''mandatory''' source code of the snippet. | ||
Line 34: | Line 35: | ||
| | | | ||
{{Snippet | category=AI | component=Application | snippet= | {{Snippet | category=AI | component=Application | snippet= | ||
<source lang="c" highlight="4-9"> | |||
/* USER CODE BEGIN 4 */ | |||
/*...*/ | |||
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) | |||
{ | |||
if (GPIO_Pin == GPIO_PIN_11) { | |||
dataRdyIntReceived++; | |||
} | |||
} | |||
/* USER CODE END 4 */ | |||
</source> | |||
}} | |||
|- | |||
| Snippet usage | |||
<pre style="white-space: pre-wrap;"> | |||
{{Snippet | category=ISP | component=Application | snippet= | |||
<source lang="c" highlight="4-9"> | |||
/* USER CODE BEGIN 4 */ | |||
/*...*/ | |||
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) | |||
{ | |||
if (GPIO_Pin == GPIO_PIN_11) { | |||
dataRdyIntReceived++; | |||
} | |||
} | |||
/* USER CODE END 4 */ | |||
</source> | |||
}} | |||
</pre> | |||
| | |||
{{Snippet | category=ISP | component=Application | snippet= | |||
<source lang="c" highlight="4-9"> | <source lang="c" highlight="4-9"> | ||
/* USER CODE BEGIN 4 */ | /* USER CODE BEGIN 4 */ | ||
Line 187: | Line 221: | ||
==Code== | ==Code== | ||
</noinclude>{{#vardefine:cat|}}{{#switch: {{{category|}}} | </noinclude>{{#vardefine:cat|}}{{#switch: {{{category|}}} | ||
| AI = {{#vardefine:cat|AI licences}} | | AI = {{#vardefine:cat| [[AI licences | here]]}} | ||
| ISP = {{#vardefine:cat| [https://www.st.com/resource/en/additional_license_terms/additional-license-terms-for-x-cube-isp.html here]}} | |||
| #default = {{#vardefine:cat|{{Highlight|unknown category}}}} | | #default = {{#vardefine:cat|{{Highlight|unknown category}}}} | ||
}}<div style="margin-bottom:-28px;font-size:12px;">''This snippet is provided AS IS, and by taking it, you agree to be bound to the license terms | }}<div style="margin-bottom:-28px;font-size:12px;">''This snippet is provided AS IS, and by taking it, you agree to be bound to the license terms that can be found {{#var:cat}} for the component: '''{{#if: {{{component|}}} | {{{component|}}} | {{Highlight|unknown component}}}}.'''''</div> | ||
<br> | |||
{{{snippet}}} | {{{snippet}}} |
Latest revision as of 11:27, 25 November 2024
1. Usage
The Snippet template is used to display snippet of code and to provide license/copyrights and component information at the same time.
<category> | component=<component> | snippet=<snippet>}}Usage: {{Snippet | category=
Where:
- <category> is the mandatory category article to that the licenses and copyright associated to the snippet are refering to:
- AI: to refer to the AI licences page
- ISP: to refer to the ISP licences page
- <component> is the mandatory component name the snippet is refering to.
- <snippet> is the mandatory source code of the snippet.
2. Basic examples
You type | You get |
---|---|
Snippet usage
{{Snippet | category=AI | component=Application | snippet=
<source lang="c" highlight="4-9">
/* USER CODE BEGIN 4 */
/*...*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == GPIO_PIN_11) {
dataRdyIntReceived++;
}
}
/* USER CODE END 4 */
</source>
}}
|
This snippet is provided AS IS, and by taking it, you agree to be bound to the license terms which can be found here for the component: Application.
/* USER CODE BEGIN 4 */
/*...*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == GPIO_PIN_11) {
dataRdyIntReceived++;
}
}
/* USER CODE END 4 */
|
Snippet usage
{{Snippet | category=ISP | component=Application | snippet=
<source lang="c" highlight="4-9">
/* USER CODE BEGIN 4 */
/*...*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == GPIO_PIN_11) {
dataRdyIntReceived++;
}
}
/* USER CODE END 4 */
</source>
}}
|
This snippet is provided AS IS, and by taking it, you agree to be bound to the license terms which can be found [[unknown category|here]] for the component: Application.
/* USER CODE BEGIN 4 */
/*...*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == GPIO_PIN_11) {
dataRdyIntReceived++;
}
}
/* USER CODE END 4 */
|
Snippet error if category or component are not set
{{Snippet | snippet=
<source lang="c" highlight="4-9">
/* USER CODE BEGIN 4 */
/*...*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == GPIO_PIN_11) {
dataRdyIntReceived++;
}
}
/* USER CODE END 4 */
</source>
}}
|
This snippet is provided AS IS, and by taking it, you agree to be bound to the license terms which can be found [[unknown category|here]] for the component: unknown component.
/* USER CODE BEGIN 4 */
/*...*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == GPIO_PIN_11) {
dataRdyIntReceived++;
}
}
/* USER CODE END 4 */
|
Snippet error if category as a wrong value
{{Snippet | category=Toto | component=Application | snippet=
<source lang="c" highlight="4-9">
/* USER CODE BEGIN 4 */
/*...*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == GPIO_PIN_11) {
dataRdyIntReceived++;
}
}
/* USER CODE END 4 */
</source>
}}
|
This snippet is provided AS IS, and by taking it, you agree to be bound to the license terms which can be found [[unknown category|here]] for the component: Application.
/* USER CODE BEGIN 4 */
/*...*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == GPIO_PIN_11) {
dataRdyIntReceived++;
}
}
/* USER CODE END 4 */
|
3. More examples
You type | You get |
---|---|
Check that spaces before and after the snippet
BEFORE{{Snippet | category=AI | component=Application | snippet=
<source lang="c" highlight="4-9">
/* USER CODE BEGIN 4 */
/*...*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == GPIO_PIN_11) {
dataRdyIntReceived++;
}
}
/* USER CODE END 4 */
</source>
}}AFTER<br>
BEFORE
{{Snippet | category=AI | component=Application | snippet=
<source lang="c" highlight="4-9">
/* USER CODE BEGIN 4 */
/*...*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == GPIO_PIN_11) {
dataRdyIntReceived++;
}
}
/* USER CODE END 4 */
</source>
}}
AFTER
|
BEFORE This snippet is provided AS IS, and by taking it, you agree to be bound to the license terms which can be found here for the component: Application.
/* USER CODE BEGIN 4 */
/*...*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == GPIO_PIN_11) {
dataRdyIntReceived++;
}
}
/* USER CODE END 4 */
BEFORE This snippet is provided AS IS, and by taking it, you agree to be bound to the license terms which can be found here for the component: Application.
/* USER CODE BEGIN 4 */
/*...*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == GPIO_PIN_11) {
dataRdyIntReceived++;
}
}
/* USER CODE END 4 */
AFTER |
4. Code
This snippet is provided AS IS, and by taking it, you agree to be bound to the license terms that can be found unknown category for the component: unknown component.
{{{snippet}}}