Last edited one month ago

Snippet

1. Usage

The Snippet template is used to display snippet of code and to provide license/copyrights and component information at the same time.

Usage:  {{Snippet | category=<category> | component=<component> | snippet=<snippet>}}

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 that 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 that 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 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 that can be found unknown category 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 that can be found unknown category 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 that 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

BEFORE

This snippet is provided AS IS, and by taking it, you agree to be bound to the license terms that 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}}}