STRUCT MCP320X(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct mcp320x πŸ’…

okay so real talk β€” this is a page from the Kernel API Manual, and today's main character is struct mcp320x, aka the Microchip SPI ADC instance. yes bestie, we're doing kernel structs now, and honestly? it's giving iconic. πŸŽ€


✨ NAME ✨

struct mcp320x β€” the Microchip SPI ADC instance herself. that's it, that's the vibe. πŸ’–


🌸 SYNOPSIS 🌸

like, here's literally the whole struct, copied exactly, no cap:

struct mcp320x {
    struct spi_device *spi;
    struct spi_message msg;
    struct spi_transfer transfer[2];
    struct spi_message start_conv_msg;
    struct spi_transfer start_conv_transfer;
    struct regulator *reg;
    struct mutex lock;
    const struct mcp320x_chip_info *chip_info;
    u8 tx_buf;
    u8 rx_buf[4];
 };

look at her. ten fields. absolutely ate. πŸ”₯


πŸ¦‹ Members πŸ¦‹

time for the roll call, bestie β€” every single field, no skips, no "skip the boring ones" energy:

  • spi β€” the SPI slave, which is also the parent of the IIO device. proud parent energy fr fr. πŸ‘‘
  • msg β€” the SPI message that selects a channel and receives a value from the ADC. she does two jobs and does them both flawlessly. πŸ’…
  • transfer β€” the SPI transfers that msg uses. the supporting cast, but honestly? essential. ✨
  • start_conv_msg β€” the SPI message that starts a conversion by briefly asserting CS. brief but powerful, like a story post. ⭐
  • start_conv_transfer β€” the SPI transfer that start_conv_msg uses. they're a duo, iykyk. 🫢
  • reg β€” the regulator generating Vref. keeping the voltage cute and stable. 🌈
  • lock β€” this one protects read sequences. a whole mutex just for that. security queen behavior, we love to see it. πŸ”’ (well, lock, but you get me)
  • chip_info β€” the ADC properties. her little info card. πŸŽ€
  • tx_buf β€” the buffer for transfer[0], and lowkey important detail: it's not used on single-channel converters. so if you're on single-channel, she's just chilling there unused. πŸ™ˆ
  • rx_buf β€” the buffer for transfer[1]. currently four whole bytes of u8 coming home to roost. πŸ“

πŸ’œ SEE ALSO πŸ’œ

  • the kernel file ./drivers/iio/adc/mcp320x.c β€” go read the source bestie, it's right there πŸ’–

okay that's the whole page, and that's on periodt. this cutie lives in ./drivers/iio/adc, and the manual itself is dated October 2026 β€” screenshot it, frame it, put it on the fridge. πŸ§šπŸ’œ

πŸ“¦ where this page comes from