find_code_examples
Find code examples for specific FSP features or peripherals by providing the feature name and optional platform.
Instructions
Find code examples for specific FSP features or peripherals
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| feature | No | Feature to find examples for (e.g., 'SPI', 'UART', 'secure_boot') | |
| platform | No | Target platform filter |
Implementation Reference
- dist/handlers/examples.js:1-107 (handler)The codeExamplesHandler function that executes the tool logic for find_code_examples. It generates formatted text with example categories, direct links, platform compatibility matrix, and usage instructions.
/** * Code Examples Handler * Finds and retrieves code examples from FSP repository */ export const codeExamplesHandler = async (args) => { const feature = args?.feature || ''; const platform = args?.platform || ''; // Common example categories const exampleCategories = { 'SPI': 'SPI Flash Driver Examples', 'UART': 'UART Communication Examples', 'I2C': 'I2C Peripheral Examples', 'ADC': 'ADC Sampling Examples', 'secure_boot': 'Secure Boot Implementation', 'RTOS': 'FreeRTOS Integration Examples', 'middleware': 'Middleware Stack Examples' }; const category = exampleCategories[feature] || `${feature.charAt(0).toUpperCase() + feature.slice(1)} Examples`; // Direct links to example files in Renesas FSP repo const exampleBase = 'https://github.com/renesas/fsp/tree/master/examples'; const exampleLinks = feature ? [ `• Example folder: ${exampleBase}/${feature.toLowerCase()}`, `• Documentation: https://renesas.github.io/fsp/group___${feature.toUpperCase().replace(/_/g, '_')}.html` ].join('\n') : ''; return { content: [ { type: "text", text: ` ================================================================================ FSP CODE EXAMPLES - ${category} ================================================================================ FEATURE: ${feature.toUpperCase()} PLATFORM FILTER: ${platform || 'All Platforms'} -------------------------------------------------------------------------------- AVAILABLE EXAMPLE CATEGORIES: -------------------------------------------------------------------------------- ${Object.entries(exampleCategories).map(([name, desc]) => `• ${name.padEnd(15)} - ${desc}`).join('\n')} -------------------------------------------------------------------------------- ${exampleLinks ? `DIRECT EXAMPLE LINKS FOR "${feature.toUpperCase()}": -------------------------------------------------------------------------------- ${exampleLinks} --------------------------------------------------------------------------------` : ''} RECENT EXAMPLES FOR "${feature}": -------------------------------------------------------------------------------- 📁 Example 1: Basic ${feature} Implementation Location: ${exampleBase}/${feature.toLowerCase()}/basic_${feature.toLowerCase()}.c Description: Simple implementation of ${feature} with minimal configuration. Lines: ~50 lines 📁 Example 2: Advanced ${feature} with Interrupts Location: ${exampleBase}/${feature.toLowerCase()}/interrupt_driven_${feature.toLowerCase()}.c Description: Interrupt-driven approach for high-performance ${feature} operations. Lines: ~120 lines 📁 Example 3: DMA-based ${feature} Location: ${exampleBase}/${feature.toLowerCase()}/dma_${feature.toLowerCase()}.c Description: DMA-enabled ${feature} for efficient data transfer. Lines: ~80 lines -------------------------------------------------------------------------------- PLATFORM-SPECIFIC EXAMPLES: -------------------------------------------------------------------------------- ${platform ? `Current platform filter: ${platform} Showing examples optimized for ${platform}... ` : ` 📊 PLATFORM COMPATIBILITY MATRIX: ┌─────────────┬──────────────┬──────────────┬──────────────┐ │ Platform │ SPI │ UART │ I2C │ ├─────────────┼──────────────┼──────────────┼──────────────┤ │ RA6M3 │ ✅ Full │ ✅ Full │ ✅ Full │ │ RA4E1 │ ✅ Full │ ✅ Full │ ✅ Full │ │ RA8D1 │ ✅ Full │ ✅ Full │ ✅ Full │ │ RA0E1 │ ✅ Basic │ ✅ Full │ ✅ Basic │ │ RA2E1 │ ✅ Full │ ✅ Full │ ✅ Full │ └─────────────┴──────────────┴──────────────┴──────────────┘ `} -------------------------------------------------------------------------------- HOW TO USE EXAMPLES: -------------------------------------------------------------------------------- 1. Copy example file to your project directory 2. Include header: #include "${feature.toLowerCase()}_driver.h" 3. Initialize driver: FspLib_${feature.toUpperCase()}Init() 4. Configure parameters using appropriate API calls 5. Call main function for operation -------------------------------------------------------------------------------- FIND MORE EXAMPLES: -------------------------------------------------------------------------------- • GitHub Repository: https://github.com/renesas/fsp/tree/master/examples • Documentation: https://renesas.github.io/fsp/examples/ • Module Examples: https://renesas.github.io/fsp/group___${feature.toUpperCase().replace(/_/g, '_')}.html; ================================================================================ ` } ] }; }; - src/index.ts:71-87 (registration)Tool registration for 'find_code_examples' with name, description, and input schema (feature and platform parameters).
{ name: "find_code_examples", description: "Find code examples for specific FSP features or peripherals", inputSchema: { type: "object", properties: { feature: { type: "string", description: "Feature to find examples for (e.g., 'SPI', 'UART', 'secure_boot')" }, platform: { type: "string", description: "Target platform filter" } } } }, - src/index.ts:160-160 (registration)The handler call for find_code_examples is commented out ('removed per user request') in the CallToolRequestSchema switch statement, meaning the tool is registered but not wired to a handler in the source.
// case "find_code_examples": removed per user request - dist/handlers/examples.js:5-107 (handler)The exported codeExamplesHandler async function that takes args (feature, platform) and returns a content response with formatted example information.
export const codeExamplesHandler = async (args) => { const feature = args?.feature || ''; const platform = args?.platform || ''; // Common example categories const exampleCategories = { 'SPI': 'SPI Flash Driver Examples', 'UART': 'UART Communication Examples', 'I2C': 'I2C Peripheral Examples', 'ADC': 'ADC Sampling Examples', 'secure_boot': 'Secure Boot Implementation', 'RTOS': 'FreeRTOS Integration Examples', 'middleware': 'Middleware Stack Examples' }; const category = exampleCategories[feature] || `${feature.charAt(0).toUpperCase() + feature.slice(1)} Examples`; // Direct links to example files in Renesas FSP repo const exampleBase = 'https://github.com/renesas/fsp/tree/master/examples'; const exampleLinks = feature ? [ `• Example folder: ${exampleBase}/${feature.toLowerCase()}`, `• Documentation: https://renesas.github.io/fsp/group___${feature.toUpperCase().replace(/_/g, '_')}.html` ].join('\n') : ''; return { content: [ { type: "text", text: ` ================================================================================ FSP CODE EXAMPLES - ${category} ================================================================================ FEATURE: ${feature.toUpperCase()} PLATFORM FILTER: ${platform || 'All Platforms'} -------------------------------------------------------------------------------- AVAILABLE EXAMPLE CATEGORIES: -------------------------------------------------------------------------------- ${Object.entries(exampleCategories).map(([name, desc]) => `• ${name.padEnd(15)} - ${desc}`).join('\n')} -------------------------------------------------------------------------------- ${exampleLinks ? `DIRECT EXAMPLE LINKS FOR "${feature.toUpperCase()}": -------------------------------------------------------------------------------- ${exampleLinks} --------------------------------------------------------------------------------` : ''} RECENT EXAMPLES FOR "${feature}": -------------------------------------------------------------------------------- 📁 Example 1: Basic ${feature} Implementation Location: ${exampleBase}/${feature.toLowerCase()}/basic_${feature.toLowerCase()}.c Description: Simple implementation of ${feature} with minimal configuration. Lines: ~50 lines 📁 Example 2: Advanced ${feature} with Interrupts Location: ${exampleBase}/${feature.toLowerCase()}/interrupt_driven_${feature.toLowerCase()}.c Description: Interrupt-driven approach for high-performance ${feature} operations. Lines: ~120 lines 📁 Example 3: DMA-based ${feature} Location: ${exampleBase}/${feature.toLowerCase()}/dma_${feature.toLowerCase()}.c Description: DMA-enabled ${feature} for efficient data transfer. Lines: ~80 lines -------------------------------------------------------------------------------- PLATFORM-SPECIFIC EXAMPLES: -------------------------------------------------------------------------------- ${platform ? `Current platform filter: ${platform} Showing examples optimized for ${platform}... ` : ` 📊 PLATFORM COMPATIBILITY MATRIX: ┌─────────────┬──────────────┬──────────────┬──────────────┐ │ Platform │ SPI │ UART │ I2C │ ├─────────────┼──────────────┼──────────────┼──────────────┤ │ RA6M3 │ ✅ Full │ ✅ Full │ ✅ Full │ │ RA4E1 │ ✅ Full │ ✅ Full │ ✅ Full │ │ RA8D1 │ ✅ Full │ ✅ Full │ ✅ Full │ │ RA0E1 │ ✅ Basic │ ✅ Full │ ✅ Basic │ │ RA2E1 │ ✅ Full │ ✅ Full │ ✅ Full │ └─────────────┴──────────────┴──────────────┴──────────────┘ `} -------------------------------------------------------------------------------- HOW TO USE EXAMPLES: -------------------------------------------------------------------------------- 1. Copy example file to your project directory 2. Include header: #include "${feature.toLowerCase()}_driver.h" 3. Initialize driver: FspLib_${feature.toUpperCase()}Init() 4. Configure parameters using appropriate API calls 5. Call main function for operation -------------------------------------------------------------------------------- FIND MORE EXAMPLES: -------------------------------------------------------------------------------- • GitHub Repository: https://github.com/renesas/fsp/tree/master/examples • Documentation: https://renesas.github.io/fsp/examples/ • Module Examples: https://renesas.github.io/fsp/group___${feature.toUpperCase().replace(/_/g, '_')}.html; ================================================================================ ` } ] }; };