Changeset 534f9dbe in rtems
- Timestamp:
- 08/03/20 07:42:25 (4 years ago)
- Branches:
- 5
- Children:
- 95036a45
- Parents:
- 4a2ac5e
- git-author:
- Sebastian Huber <sebastian.huber@…> (08/03/20 07:42:25)
- git-committer:
- Sebastian Huber <sebastian.huber@…> (08/05/20 04:59:10)
- Location:
- bsps/arm/atsam
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
bsps/arm/atsam/include/bsp/sc16is752.h
r4a2ac5e r534f9dbe 25 25 #endif /* __cplusplus */ 26 26 27 /** 28 * @brief The SC16IS752 device context. 29 * 30 * All members are private to the device driver. 31 */ 27 32 typedef struct { 28 33 sc16is752_spi_context base; 29 34 Pin irq_pin; 30 rtems_interrupt_server_entry irqs_entry; /* Internal. Don't touch. */ 31 rtems_interrupt_server_action irqs_action; /* Internal. Don't touch. */ 35 rtems_interrupt_server_entry irqs_entry; 36 rtems_interrupt_server_action irqs_action; 37 uint32_t irqs_index; 32 38 } atsam_sc16is752_spi_context; 39 40 /** 41 * @brief The SC16IS752 device configuration. 42 * 43 * @see atsam_sc16is752_spi_create(). 44 */ 45 typedef struct { 46 /** 47 * @brief The device file path for the new device. 48 */ 49 const char *device_path; 50 51 /** 52 * @brief The SC16IS752 mode. 53 */ 54 sc16is752_mode mode; 55 56 /** 57 * @brief The input frequency in Hertz of the SC16IS752 chip. See XTAL1 and 58 * XTAL2 pins. 59 */ 60 uint32_t input_frequency; 61 62 /** 63 * @brief The SPI bus device path. 64 */ 65 const char *spi_path; 66 67 /** 68 * @brief The SPI chip select (starts with 0, the SPI driver uses 69 * SPI_ChipSelect(1 << spi_chip_select)). 70 */ 71 uint8_t spi_chip_select; 72 73 /** 74 * @brief The SPI bus speed in Hertz. 75 */ 76 uint32_t spi_speed_hz; 77 78 /** 79 * @brief The interrupt pin, e.g. { PIO_PD28, PIOD, ID_PIOD, PIO_INPUT, 80 * PIO_IT_LOW_LEVEL }. 81 */ 82 const Pin irq_pin; 83 84 /** 85 * @brief The index to identify the interrupt server used for interrupt 86 * processing. 87 */ 88 uint32_t server_index; 89 } atsam_sc16is752_spi_config; 33 90 34 91 /** 35 92 * @brief Creates an SPI connected SC16IS752 device. 36 93 * 37 * This devices uses the interrupt server, see 38 * rtems_interrupt_server_initialize(). 94 * This devices uses the interrupt server, see rtems_interrupt_server_create(). 39 95 * 40 96 * The device claims the interrupt of the PIO block. 41 97 * 42 * @param[in] ctx The device context. May have an arbitrary content. 43 * @param[in] device_path The device file path for the new device. 44 * @param[in] mode The SC16IS752 mode. 45 * @param[in] input_frequency The input frequency in Hertz of the SC16IS752 46 * chip. See XTAL1 and XTAL2 pins. 47 * @param[in] spi_path The SPI bus device path. 48 * @param[in] spi_chip_select The SPI chip select (starts with 0, the SPI 49 * driver uses SPI_ChipSelect(1 << spi_chip_select)). 50 * @param[in] spi_speed_hz The SPI bus speed in Hertz. 51 * @param[in] irq_pin The interrupt pin, e.g. { PIO_PD28, PIOD, ID_PIOD, 52 * PIO_INPUT, PIO_IT_LOW_LEVEL }. 98 * @param[out] ctx is the device context. It may have an arbitrary content. 99 * @param config is the device configuration. 53 100 * 54 101 * @return See sc16is752_spi_create(). 55 102 */ 56 103 int atsam_sc16is752_spi_create( 57 atsam_sc16is752_spi_context *ctx, 58 const char *device_path, 59 sc16is752_mode mode, 60 uint32_t input_frequency, 61 const char *spi_path, 62 uint8_t spi_chip_select, 63 uint32_t spi_speed_hz, 64 const Pin *irq_pin 104 atsam_sc16is752_spi_context *ctx, 105 const atsam_sc16is752_spi_config *config 65 106 ); 66 107 -
bsps/arm/atsam/spi/sc16is752.c
r4a2ac5e r534f9dbe 42 42 uint8_t rv; 43 43 44 sc = rtems_interrupt_server_entry_initialize( RTEMS_INTERRUPT_SERVER_DEFAULT,44 sc = rtems_interrupt_server_entry_initialize(ctx->irqs_index, 45 45 &ctx->irqs_entry); 46 46 rtems_interrupt_server_action_prepend(&ctx->irqs_entry, … … 65 65 66 66 int atsam_sc16is752_spi_create( 67 atsam_sc16is752_spi_context *ctx, 68 const char *device_path, 69 sc16is752_mode mode, 70 uint32_t input_frequency, 71 const char *spi_path, 72 uint8_t spi_chip_select, 73 uint32_t spi_speed_hz, 74 const Pin *irq_pin 67 atsam_sc16is752_spi_context *ctx, 68 const atsam_sc16is752_spi_config *config 75 69 ) 76 70 { 77 ctx->base.base.mode = mode;78 ctx->base.base.input_frequency = input_frequency;71 ctx->base.base.mode = config->mode; 72 ctx->base.base.input_frequency = config->input_frequency; 79 73 ctx->base.base.install_irq = atsam_sc16is752_install_interrupt; 80 74 ctx->base.base.remove_irq = atsam_sc16is752_remove_interrupt; 81 ctx->base.spi_path = spi_path; 82 ctx->base.cs = spi_chip_select; 83 ctx->base.speed_hz = spi_speed_hz; 84 ctx->irq_pin = *irq_pin; 75 ctx->base.spi_path = config->spi_path; 76 ctx->base.cs = config->spi_chip_select; 77 ctx->base.speed_hz = config->spi_speed_hz; 78 ctx->irq_pin = config->irq_pin; 79 ctx->irqs_index = config->server_index; 85 80 86 return sc16is752_spi_create(&ctx->base, device_path);81 return sc16is752_spi_create(&ctx->base, config->device_path); 87 82 }
Note: See TracChangeset
for help on using the changeset viewer.