diff --git a/.gitignore b/.gitignore index efd23c5..fdfe509 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,3 @@ db-dump.tar.gz db-dump* full-crate-db.json full-crate-db-schema.json -driver-db-schema.json diff --git a/.taplo.toml b/.taplo.toml index a9578cd..c553779 100644 --- a/.taplo.toml +++ b/.taplo.toml @@ -2,3 +2,13 @@ include = [".taplo.toml", "driver-db/*.toml"] [formatting] indent_string = " " + +[[rule]] +include = ["driver-db/*.toml"] + +[rule.schema] +path = "driver-db-schema.json" + +[rule.formatting] +reorder_arrays = true +reorder_keys = true diff --git a/backend/src/bin/read-driver-db.rs b/backend/src/bin/read-driver-db.rs index 5a01986..a00b18e 100644 --- a/backend/src/bin/read-driver-db.rs +++ b/backend/src/bin/read-driver-db.rs @@ -125,11 +125,8 @@ fn read_all(dir: &Path) -> anyhow::Result> { } pub fn parse_crate(path: &Path) -> anyhow::Result<(String, Driver)> { - if !path - .extension() - .is_some_and(|ext| ext == OsStr::new("toml")) - { - bail!("Driver info has wrong exctension: {path:?}"); + if path.extension().is_none_or(|ext| ext != OsStr::new("toml")) { + bail!("Driver info has wrong extension: {path:?}"); } let Some(crate_name) = path.file_stem() else { diff --git a/backend/src/description.rs b/backend/src/description.rs index f3541a0..34bc599 100644 --- a/backend/src/description.rs +++ b/backend/src/description.rs @@ -34,7 +34,7 @@ mod spdx_expression_serde { } struct ExpressionVisitor; - impl<'de> serde::de::Visitor<'de> for ExpressionVisitor { + impl serde::de::Visitor<'_> for ExpressionVisitor { type Value = Expression; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { diff --git a/backend/src/driver_db.rs b/backend/src/driver_db.rs index 5edcae3..59ae80a 100644 --- a/backend/src/driver_db.rs +++ b/backend/src/driver_db.rs @@ -1,7 +1,9 @@ +use boards::DevBoard; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use url::Url; +pub mod boards; pub mod categories; pub mod manufacturers; pub mod packages; @@ -9,12 +11,17 @@ pub mod packages; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] #[serde(deny_unknown_fields)] pub struct Driver { + /// Version of this driver description TOML schema pub manifest_version: semver::Version, + /// Metadata about the driver pub meta: Meta, - #[serde(skip_serializing_if = "DevBoards::is_empty", default)] - pub dev_boards: DevBoards, + /// List of development boards that house this chip + #[serde(skip_serializing_if = "Vec::is_empty", default)] + pub dev_boards: Vec, + /// Interfaces used by this chip #[serde(skip_serializing_if = "Interfaces::is_empty", default)] pub interfaces: Interfaces, + /// Blog articles and similar covering this driver and its usage #[serde(skip_serializing_if = "Vec::is_empty", default)] pub resources: Vec, } @@ -22,59 +29,34 @@ pub struct Driver { #[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema)] #[serde(deny_unknown_fields)] pub struct Meta { + /// Names of the chips this driver supports pub names: Vec, - pub manufacturer: manufacturers::Manufacturer, + /// Manufacturer that produces devices supported by this driver + pub manufacturer: manufacturers::ChipManufacturer, + /// Links to datasheets of chips that are supported by this driver #[serde(skip_serializing_if = "Vec::is_empty", default)] pub datasheets: Vec, + /// Functionalities this driver provides #[serde(skip_serializing_if = "Vec::is_empty", default)] pub categories: Vec, + /// Part numbers of chips this driver supports #[serde(skip_serializing_if = "Vec::is_empty", default)] pub part_numbers: Vec, + /// Names of KiCAD symbold for chips this driver supports #[serde(skip_serializing_if = "Vec::is_empty", default)] pub kicad_symbol: Vec, + /// Packages or footprints in which chips are available #[serde(skip_serializing_if = "Vec::is_empty", default)] pub packages: Vec, } -#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] -#[serde(deny_unknown_fields)] -pub struct DevBoards { - #[serde(skip_serializing_if = "Option::is_none", default)] - pub adafruit: Option, - #[serde(skip_serializing_if = "Option::is_none", default)] - pub sparkfun: Option, - #[serde(skip_serializing_if = "Option::is_none", default)] - pub mikroe: Option, - #[serde(skip_serializing_if = "Vec::is_empty", default)] - pub other: Vec, -} - -impl DevBoards { - pub fn is_empty(&self) -> bool { - matches!( - self, - DevBoards { - adafruit: None, - sparkfun: None, - mikroe: None, - other: _, - } - ) && self.other.is_empty() - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] -#[serde(deny_unknown_fields)] -pub struct GenericDevBoard { - pub name: String, - pub link: url::Url, -} - #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] #[serde(deny_unknown_fields)] pub struct Interfaces { + /// Information about the I2C interface (if present) #[serde(skip_serializing_if = "Option::is_none", default)] pub i2c: Option, + /// Information about the SPI interface (if present) #[serde(skip_serializing_if = "Option::is_none", default)] pub spi: Option, } @@ -94,14 +76,18 @@ impl Interfaces { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] #[serde(deny_unknown_fields)] pub struct I2c { + /// Addresses that can be used by this device pub addrs: Vec, + /// Does this device have an interrupt line? pub interrupt: bool, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] #[serde(deny_unknown_fields)] pub struct Spi { + /// Whether this device can be used on a shared bus or only on an exclusive device pub bus_type: SpiDeviceType, + /// Does this device have an interrupt line? pub interrupt: bool, } diff --git a/backend/src/driver_db/boards.rs b/backend/src/driver_db/boards.rs new file mode 100644 index 0000000..3d17aa0 --- /dev/null +++ b/backend/src/driver_db/boards.rs @@ -0,0 +1,26 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use url::Url; + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] +pub struct DevBoard { + name: String, + manufacturer: BoardManufacturer, + link: Url, + connections: Vec, +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] +pub enum BoardManufacturer { + Adafruit, + Sparkfun, + Mikroe, + #[serde(rename = "BBC")] + Bbc, +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] +pub enum Connection { + StemmaQt, + MikroBus, +} diff --git a/backend/src/driver_db/categories.rs b/backend/src/driver_db/categories.rs index 6b4d319..a8536e8 100644 --- a/backend/src/driver_db/categories.rs +++ b/backend/src/driver_db/categories.rs @@ -1,158 +1,77 @@ -use std::{ - borrow::Cow, - fmt::{Debug, Display}, - str::FromStr, -}; - -use anyhow::bail; -use schemars::{json_schema, JsonSchema}; +use std::fmt::Debug; + +use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)] +#[derive( + Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize, JsonSchema, +)] pub enum Category { - Analog(Option), - Sensor(Option), - IoExpander(Option), -} - -impl FromStr for Category { - type Err = anyhow::Error; - - fn from_str(s: &str) -> Result { - match s - .split_once("::") - .map(|(prefix, rest)| (prefix, Some(rest))) - .unwrap_or((s, None)) - { - ("Analog", rest) => Ok(Category::Analog(rest.map(FromStr::from_str).transpose()?)), - ("Sensor", rest) => Ok(Category::Sensor(rest.map(FromStr::from_str).transpose()?)), - ("IoExpander", rest) => Ok(Category::IoExpander( - rest.map(FromStr::from_str).transpose()?, - )), - _ => bail!("Unknown category: {s}"), - } - } -} - -impl Display for Category { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let (name, inner): (&str, Option<&dyn Display>) = match self { - Category::Analog(ref inner) => ("Analog", opt_dyn(inner)), - Category::Sensor(ref inner) => ("Sensor", opt_dyn(inner)), - Category::IoExpander(ref inner) => ("IoExpander", opt_dyn(inner)), - }; - - if let Some(inner) = inner { - write!(f, "{}::{}", name, inner) - } else { - write!(f, "{}", name) - } - } -} - -impl Serialize for Category { - fn serialize(&self, serializer: S) -> Result - where - S: serde::Serializer, - { - serializer.serialize_str(self.to_string().as_str()) - } -} + // Analog + /// Devices interacting with analog signals + Analog, -impl<'de> Deserialize<'de> for Category { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let s = String::deserialize(deserializer)?; - Category::from_str(s.as_str()).map_err(serde::de::Error::custom) - } -} + /// Analog to digital converters + #[serde(rename = "Analog::ADC")] + Adc, -impl JsonSchema for Category { - fn schema_name() -> std::borrow::Cow<'static, str> { - Cow::Borrowed("Category") - } + /// Digital to analog converters + #[serde(rename = "Analog::DAC")] + Dac, - fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema { - json_schema!({"enum": ["Analog", "Analog::ADC", "Analog::DAC", "Sensor", "Sensor::PowerMeter"]}) - } -} + // Sensor + /// Devices measuring things about their environment + Sensor, -#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)] -pub enum Analog { - ADC, - DAC, -} - -impl FromStr for Analog { - type Err = anyhow::Error; - - fn from_str(s: &str) -> Result { - match s { - "ADC" => Ok(Analog::ADC), - "DAC" => Ok(Analog::DAC), - _ => bail!("Unknown analog category: {s}"), - } - } -} - -impl Display for Analog { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - Debug::fmt(self, f) - } -} - -#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)] -pub enum Sensor { + /// Sensors measuring electric power + #[serde(rename = "Sensor::PowerMeter")] PowerMeter, + + /// Sensors measuring acceleration + /// + /// These can also be used to determine where "down" is, + /// using the gravitational acceleration. + #[serde(rename = "Sensor::Accelerometer")] Accelerometer, + + /// Sensors measuring rotational acceleration + #[serde(rename = "Sensor::Gyroscope")] Gyroscope, + + /// Sensors measuring magnetic fields + /// + /// These are commonly used as compasses, measuring the + /// magnetic field of the earth. + #[serde(rename = "Sensor::Magnetometer")] Magnetometer, -} -impl FromStr for Sensor { - type Err = anyhow::Error; - - fn from_str(s: &str) -> Result { - match s { - "PowerMeter" => Ok(Sensor::PowerMeter), - "Accelerometer" => Ok(Sensor::Accelerometer), - "Gyroscope" => Ok(Sensor::Gyroscope), - "Magnetometer" => Ok(Sensor::Magnetometer), - _ => bail!("Unknown sensor category: {s}"), - } - } -} + // IO Expander + /// Devices that provide more input and/or output signals + IoExpander, -impl Display for Sensor { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - Debug::fmt(self, f) - } -} + /// Devices that provide PWM input and/or output signals + #[serde(rename = "IoExpander::PWM")] + PwmExpander, -#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)] -pub enum IoExpander { - PWM, -} + // Actor + /// Things that move things in the real world + Actor, -impl FromStr for IoExpander { - type Err = anyhow::Error; + /// Chips for driving motors + #[serde(rename = "Actor::MotorController")] + MotorController, - fn from_str(s: &str) -> Result { - match s { - "PWM" => Ok(IoExpander::PWM), - _ => bail!("Unknown io expander category: {s}"), - } - } -} + // Display + /// Optical displays + Display, -impl Display for IoExpander { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - Debug::fmt(self, f) - } -} + /// OLED Screens + #[serde(rename = "Display::OLED")] + Oled, + + // Timer + Timer, -fn opt_dyn(opt: &Option) -> Option<&dyn Display> { - opt.as_ref().map(|i| i as &dyn Display) + #[serde(rename = "Timer::RTC")] + Rtc, } diff --git a/backend/src/driver_db/manufacturers.rs b/backend/src/driver_db/manufacturers.rs index 92fd8e3..a5c3411 100644 --- a/backend/src/driver_db/manufacturers.rs +++ b/backend/src/driver_db/manufacturers.rs @@ -2,11 +2,14 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema)] -pub enum Manufacturer { +pub enum ChipManufacturer { AnalogDevices, + /// Also known as ST Micro ST, TI, NXP, + Toshiba, + SolomonSystech, #[default] Unknown, } diff --git a/backend/src/driver_db/packages.rs b/backend/src/driver_db/packages.rs index d6449bc..ff2e5c0 100644 --- a/backend/src/driver_db/packages.rs +++ b/backend/src/driver_db/packages.rs @@ -74,6 +74,9 @@ pub enum PackageType { HVQFN, SOIC, SOT, + SSOP, + SO, + PDIP, } impl PackageType { @@ -84,6 +87,9 @@ impl PackageType { PackageType::HVQFN, PackageType::SOIC, PackageType::SOT, + PackageType::SSOP, + PackageType::SO, + PackageType::PDIP, ] } } @@ -98,6 +104,9 @@ impl FromStr for PackageType { "HVQFN" => Ok(PackageType::HVQFN), "SOIC" => Ok(PackageType::SOIC), "SOT" => Ok(PackageType::SOT), + "SSOP" => Ok(PackageType::SSOP), + "SO" => Ok(PackageType::SO), + "PDIP" => Ok(PackageType::PDIP), _ => bail!("Unknown package type: {s}"), } } diff --git a/backend/src/lib.rs b/backend/src/lib.rs index d4b3335..20f9a6a 100644 --- a/backend/src/lib.rs +++ b/backend/src/lib.rs @@ -1,4 +1,4 @@ -use crate::driver_db::{DevBoards, Driver, Interfaces, Resource}; +use crate::driver_db::{boards::DevBoard, Driver, Interfaces, Resource}; use anyhow::Context; use chrono::{DateTime, Utc}; use schemars::{json_schema, JsonSchema, Schema, SchemaGenerator}; @@ -34,8 +34,8 @@ pub struct FullCrate { pub updated_at: DateTime, #[serde(flatten)] pub chip_meta: driver_db::Meta, - #[serde(skip_serializing_if = "DevBoards::is_empty", default)] - pub dev_boards: DevBoards, + #[serde(skip_serializing_if = "Vec::is_empty", default)] + pub dev_boards: Vec, #[serde(skip_serializing_if = "Interfaces::is_empty", default)] pub interfaces: Interfaces, #[serde(skip_serializing_if = "Vec::is_empty", default)] diff --git a/driver-db-schema.json b/driver-db-schema.json new file mode 100644 index 0000000..93f8980 --- /dev/null +++ b/driver-db-schema.json @@ -0,0 +1,339 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Driver", + "type": "object", + "properties": { + "dev_boards": { + "description": "List of development boards that house this chip", + "type": "array", + "items": { + "$ref": "#/$defs/DevBoard" + } + }, + "interfaces": { + "description": "Interfaces used by this chip", + "$ref": "#/$defs/Interfaces" + }, + "manifest_version": { + "description": "Version of this driver description TOML schema", + "type": "string", + "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$" + }, + "meta": { + "description": "Metadata about the driver", + "$ref": "#/$defs/Meta" + }, + "resources": { + "description": "Blog articles and similar covering this driver and its usage", + "type": "array", + "items": { + "$ref": "#/$defs/Resource" + } + } + }, + "additionalProperties": false, + "required": [ + "manifest_version", + "meta" + ], + "$defs": { + "BoardManufacturer": { + "type": "string", + "enum": [ + "Adafruit", + "Sparkfun", + "Mikroe", + "BBC" + ] + }, + "Category": { + "oneOf": [ + { + "type": "string", + "enum": [ + "Timer", + "Timer::RTC" + ] + }, + { + "description": "Devices interacting with analog signals", + "type": "string", + "const": "Analog" + }, + { + "description": "Analog to digital converters", + "type": "string", + "const": "Analog::ADC" + }, + { + "description": "Digital to analog converters", + "type": "string", + "const": "Analog::DAC" + }, + { + "description": "Devices measuring things about their environment", + "type": "string", + "const": "Sensor" + }, + { + "description": "Sensors measuring electric power", + "type": "string", + "const": "Sensor::PowerMeter" + }, + { + "description": "Sensors measuring acceleration\n\n These can also be used to determine where \"down\" is,\n using the gravitational acceleration.", + "type": "string", + "const": "Sensor::Accelerometer" + }, + { + "description": "Sensors measuring rotational acceleration", + "type": "string", + "const": "Sensor::Gyroscope" + }, + { + "description": "Sensors measuring magnetic fields\n\n These are commonly used as compasses, measuring the\n magnetic field of the earth.", + "type": "string", + "const": "Sensor::Magnetometer" + }, + { + "description": "Devices that provide more input and/or output signals", + "type": "string", + "const": "IoExpander" + }, + { + "description": "Devices that provide PWM input and/or output signals", + "type": "string", + "const": "IoExpander::PWM" + }, + { + "description": "Things that move things in the real world", + "type": "string", + "const": "Actor" + }, + { + "description": "Chips for driving motors", + "type": "string", + "const": "Actor::MotorController" + }, + { + "description": "Optical displays", + "type": "string", + "const": "Display" + }, + { + "description": "OLED Screens", + "type": "string", + "const": "Display::OLED" + } + ] + }, + "ChipManufacturer": { + "oneOf": [ + { + "type": "string", + "enum": [ + "AnalogDevices", + "TI", + "NXP", + "Toshiba", + "SolomonSystech", + "Unknown" + ] + }, + { + "description": "Also known as ST Micro", + "type": "string", + "const": "ST" + } + ] + }, + "Connection": { + "type": "string", + "enum": [ + "StemmaQt", + "MikroBus" + ] + }, + "DevBoard": { + "type": "object", + "properties": { + "connections": { + "type": "array", + "items": { + "$ref": "#/$defs/Connection" + } + }, + "link": { + "type": "string", + "format": "uri" + }, + "manufacturer": { + "$ref": "#/$defs/BoardManufacturer" + }, + "name": { + "type": "string" + } + }, + "required": [ + "name", + "manufacturer", + "link", + "connections" + ] + }, + "I2c": { + "type": "object", + "properties": { + "addrs": { + "description": "Addresses that can be used by this device", + "type": "array", + "items": { + "type": "integer", + "format": "uint8", + "minimum": 0 + } + }, + "interrupt": { + "description": "Does this device have an interrupt line?", + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "addrs", + "interrupt" + ] + }, + "Interfaces": { + "type": "object", + "properties": { + "i2c": { + "description": "Information about the I2C interface (if present)", + "anyOf": [ + { + "$ref": "#/$defs/I2c" + }, + { + "type": "null" + } + ] + }, + "spi": { + "description": "Information about the SPI interface (if present)", + "anyOf": [ + { + "$ref": "#/$defs/Spi" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "Meta": { + "type": "object", + "properties": { + "categories": { + "description": "Functionalities this driver provides", + "type": "array", + "items": { + "$ref": "#/$defs/Category" + } + }, + "datasheets": { + "description": "Links to datasheets of chips that are supported by this driver", + "type": "array", + "items": { + "type": "string", + "format": "uri" + } + }, + "kicad_symbol": { + "description": "Names of KiCAD symbold for chips this driver supports", + "type": "array", + "items": { + "type": "string" + } + }, + "manufacturer": { + "description": "Manufacturer that produces devices supported by this driver", + "$ref": "#/$defs/ChipManufacturer" + }, + "names": { + "description": "Names of the chips this driver supports", + "type": "array", + "items": { + "type": "string" + } + }, + "packages": { + "description": "Packages or footprints in which chips are available", + "type": "array", + "items": { + "$ref": "#/$defs/Package" + } + }, + "part_numbers": { + "description": "Part numbers of chips this driver supports", + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false, + "required": [ + "names", + "manufacturer" + ] + }, + "Package": { + "type": "string", + "pattern": "^(TSSOP|LGA|HVQFN|SOIC|SOT|SSOP|SO|PDIP)-\\d+$" + }, + "Resource": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "link": { + "type": "string", + "format": "uri" + } + }, + "additionalProperties": false, + "required": [ + "title", + "link" + ] + }, + "Spi": { + "type": "object", + "properties": { + "bus_type": { + "description": "Whether this device can be used on a shared bus or only on an exclusive device", + "$ref": "#/$defs/SpiDeviceType" + }, + "interrupt": { + "description": "Does this device have an interrupt line?", + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "bus_type", + "interrupt" + ] + }, + "SpiDeviceType": { + "type": "string", + "enum": [ + "SpiBus", + "SpiDevice" + ] + } + } +} \ No newline at end of file diff --git a/driver-db/ad57xx.toml b/driver-db/ad57xx.toml index 81e8496..91e7d74 100644 --- a/driver-db/ad57xx.toml +++ b/driver-db/ad57xx.toml @@ -1,32 +1,31 @@ manifest_version = "0.0.1" [meta] -names = ["AD5724", "AD5734", "AD5754", "AD5722", "AD5732", "AD5752"] -manufacturer = "AnalogDevices" +categories = ["Analog::DAC"] datasheets = [ - "https://www.analog.com/media/en/technical-documentation/data-sheets/ad5724_5734_5754.pdf", "https://www.analog.com/media/en/technical-documentation/data-sheets/ad5722_5732_5752.pdf", + "https://www.analog.com/media/en/technical-documentation/data-sheets/ad5724_5734_5754.pdf", ] -categories = ["Analog::DAC"] +manufacturer = "AnalogDevices" +names = ["AD5722", "AD5724", "AD5732", "AD5734", "AD5752", "AD5754"] +packages = ["TSSOP-24"] part_numbers = [ + "AD5722AREZ", + "AD5722AREZ-REEL7", "AD5724AREZ", "AD5724AREZ-REEL7", + "AD5732AREZ", + "AD5732AREZ-REEL7", "AD5734AREZ", "AD5734AREZ-REEL7", + "AD5752AREZ", + "AD5752AREZ-REEL7", "AD5754AREZ", "AD5754AREZ-REEL7", "AD5754BREZ", "AD5754BREZ-REEL7", - "AD5722AREZ", - "AD5722AREZ-REEL7", - "AD5732AREZ", - "AD5732AREZ-REEL7", - "AD5752AREZ", - "AD5752AREZ-REEL7", ] -packages = ["TSSOP-24"] - [interfaces.spi] bus_type = "SpiDevice" interrupt = false diff --git a/driver-db/ds1307.toml b/driver-db/ds1307.toml new file mode 100644 index 0000000..9ca942a --- /dev/null +++ b/driver-db/ds1307.toml @@ -0,0 +1,34 @@ +manifest_version = "0.0.1" + +[meta] +categories = ["Timer::RTC"] +datasheets = [ + "https://www.analog.com/media/en/technical-documentation/data-sheets/ds1307.pdf", +] +kicad_symbol = [ + "Timer_RTC:DS1307+", + "Timer_RTC:DS1307N+", + "Timer_RTC:DS1307Z+", + "Timer_RTC:DS1307ZN+", +] +manufacturer = "AnalogDevices" +names = ["DS1307"] +packages = ["PDIP-8", "SO-8"] +part_numbers = [ + "DS1307+", + "DS1307N+", + "DS1307Z+ T&R", + "DS1307Z+", + "DS1307ZN+ T&R", + "DS1307ZN+", +] + +[[dev_boards]] +connections = [] +link = "https://www.adafruit.com/product/3296" +manufacturer = "Adafruit" +name = "Adafruit DS1307 Real Time Clock Assembled Breakout Board" + +[interfaces.i2c] +addrs = [0b1101000] +interrupt = false diff --git a/driver-db/ina219.toml b/driver-db/ina219.toml index 9ff7d22..ce37de1 100644 --- a/driver-db/ina219.toml +++ b/driver-db/ina219.toml @@ -1,30 +1,30 @@ manifest_version = "0.0.1" [meta] -names = ["ina219"] -manufacturer = "TI" -datasheets = ["https://ti.com/lit/gpn/INA219"] categories = ["Analog::ADC", "Sensor::PowerMeter"] +datasheets = ["https://ti.com/lit/gpn/INA219"] +manufacturer = "TI" +names = ["ina219"] part_numbers = [ "INA219AIDCNR", "INA219AIDCNR", - "INA219AIDCNT", - "INA219AIDCNT", - "INA219AIDR", - "INA219BIDCNR", - "INA219BIDCNR", - "INA219BIDCNT", - "INA219BIDCNT", - "INA219BIDR", "INA219AIDCNR", "INA219AIDCNR", "INA219AIDCNT", "INA219AIDCNT", + "INA219AIDCNT", + "INA219AIDCNT", + "INA219AIDR", "INA219AIDR", "INA219BIDCNR", "INA219BIDCNR", + "INA219BIDCNR", + "INA219BIDCNR", + "INA219BIDCNT", "INA219BIDCNT", "INA219BIDCNT", + "INA219BIDCNT", + "INA219BIDR", "INA219BIDR", ] @@ -36,8 +36,11 @@ kicad_symbol = [ ] packages = ["SOIC-8", "SOT-23"] -[dev_boards] -adafruit = 904 +[[dev_boards]] +connections = ["StemmaQt"] +link = "https://www.adafruit.com/product/904" +manufacturer = "Adafruit" +name = "INA219 High Side DC Current Sensor Breakout - 26V ±3.2A Max - STEMMA QT" [interfaces.i2c] addrs = [ diff --git a/driver-db/lis3dh-async.toml b/driver-db/lis3dh-async.toml index 67bf1b1..0fe8b61 100644 --- a/driver-db/lis3dh-async.toml +++ b/driver-db/lis3dh-async.toml @@ -1,18 +1,26 @@ manifest_version = "0.0.1" [meta] -names = ["LIS3DH"] -manufacturer = "ST" -datasheets = ["https://www.st.com/resource/en/datasheet/lis3dh.pdf"] categories = ["Sensor::Accelerometer"] +datasheets = ["https://www.st.com/resource/en/datasheet/lis3dh.pdf"] +manufacturer = "ST" +names = ["LIS3DH"] part_numbers = ["LIS3DHTR"] kicad_symbol = ["Sensor_Motion::LIS3DH"] packages = ["LGA-16"] -[dev_boards] -adafruit = 2809 -sparkfun = 13963 +[[dev_boards]] +connections = ["StemmaQt"] +link = "https://www.adafruit.com/product/2809" +manufacturer = "Adafruit" +name = "Adafruit LIS3DH Triple-Axis Accelerometer (+-2g/4g/8g/16g)" + +[[dev_boards]] +connections = [] +link = "https://www.sparkfun.com/products/13963" +manufacturer = "Sparkfun" +name = "SparkFun Triple Axis Accelerometer Breakout - LIS3DH" [interfaces.i2c] addrs = [0x18, 0x19] diff --git a/driver-db/lsm303agr.toml b/driver-db/lsm303agr.toml index 5012bd6..ce9903f 100644 --- a/driver-db/lsm303agr.toml +++ b/driver-db/lsm303agr.toml @@ -1,22 +1,36 @@ -# TODO: This is mock data! Check before using! manifest_version = "0.0.1" [meta] -names = ["lsm303agr"] -manufacturer = "ST" -datasheets = ["https://www.st.com/resource/en/datasheet/lsm303agr.pdf"] categories = ["Sensor::Accelerometer", "Sensor::Magnetometer"] -part_numbers = ["LSM303AGRTR", "LSM303AGRLTR"] +datasheets = ["https://www.st.com/resource/en/datasheet/lsm303agr.pdf"] +manufacturer = "ST" +names = ["LSM303AGR"] +part_numbers = ["LSM303AGR", "LSM303AGRTR"] packages = ["LGA-14"] -[dev_boards] -adafruit = 4413 -mikroe = 2684 -other = [ - { name = "BBC micro:bit v2", link = "https://tech.microbit.org/hardware/" }, -] +[[dev_boards]] +connections = ["StemmaQt"] +link = "https://www.adafruit.com/product/4413" +manufacturer = "Adafruit" +name = "Adafruit LSM303AGR Accelerometer Magnetometer - STEMMA QT Qwiic" + +[[dev_boards]] +connections = ["MikroBus"] +link = "https://www.mikroe.com/lsm303agr-click" +manufacturer = "Mikroe" +name = "LSM303AGR Click" + +[[dev_boards]] +connections = [] +link = "https://tech.microbit.org/hardware/" +manufacturer = "BBC" +name = "BBC micro:bit v2" [interfaces.i2c] -addrs = [0x1E, 0x1D] +addrs = [0x19, 0x1E] +interrupt = true + +[interfaces.spi] +bus_type = "SpiDevice" interrupt = true diff --git a/driver-db/pwm-pca9685.toml b/driver-db/pwm-pca9685.toml index a8aad01..8ab3d86 100644 --- a/driver-db/pwm-pca9685.toml +++ b/driver-db/pwm-pca9685.toml @@ -1,18 +1,23 @@ -# TODO: This is mock data! Check before using! manifest_version = "0.0.1" [meta] -names = ["pca9685"] -manufacturer = "NXP" -datasheets = ["https://www.nxp.com/docs/en/data-sheet/PCA9685.pdf"] categories = ["IoExpander::PWM"] -part_numbers = ["PCA9685PW", "PCA9685PW,118", "PCA9685PW,112"] - +datasheets = ["https://www.nxp.com/docs/en/data-sheet/PCA9685.pdf"] kicad_symbol = ["Driver_LED::PCA9685BS", "Driver_LED::PCA9685PW"] -packages = ["TSSOP-28", "HVQFN-28"] +manufacturer = "NXP" +names = ["pca9685"] +packages = ["HVQFN-28", "TSSOP-28"] +part_numbers = ["PCA9685PW", "PCA9685PW,112", "PCA9685PW,118"] -[dev_boards] -adafruit = 815 +[[dev_boards]] +connections = [] +link = "https://www.adafruit.com/product/815" +manufacturer = "Adafruit" +name = "Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface - PCA9685" + +[[resources]] +link = "https://blog.eldruin.com/pca9685-pwm-led-servo-controller-driver-in-rust/" +title = "Blog Post" [interfaces.i2c] addrs = [ @@ -82,7 +87,3 @@ addrs = [ 0x7F, ] interrupt = false - -[[resources]] -title = "Blog Post" -link = "https://blog.eldruin.com/pca9685-pwm-led-servo-controller-driver-in-rust/" diff --git a/driver-db/ssd1306.toml b/driver-db/ssd1306.toml new file mode 100644 index 0000000..6c76265 --- /dev/null +++ b/driver-db/ssd1306.toml @@ -0,0 +1,16 @@ +manifest_version = "0.0.1" + +[meta] +categories = ["Display::OLED"] +datasheets = ["https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf"] +kicad_symbol = [] +manufacturer = "SolomonSystech" +names = ["SSD1306"] +packages = [] +part_numbers = ["SSD1306"] + +[[dev_boards]] +connections = ["StemmaQt"] +link = "https://www.adafruit.com/product/938" +manufacturer = "Adafruit" +name = "Monochrome 1.3\" 128x64 OLED graphic display - STEMMA QT / Qwiic" diff --git a/driver-db/tb6612fng.toml b/driver-db/tb6612fng.toml new file mode 100644 index 0000000..daa9006 --- /dev/null +++ b/driver-db/tb6612fng.toml @@ -0,0 +1,16 @@ +manifest_version = "0.0.1" + +[meta] +categories = ["Actor::MotorController"] +datasheets = ["https://www.sparkfun.com/datasheets/Robotics/TB6612FNG.pdf"] +kicad_symbol = ["Driver_Motor:TB6612FNG"] +manufacturer = "Toshiba" +names = ["TB6612FNG"] +packages = ["SSOP-24"] +part_numbers = ["TB6612FNG"] + +[[dev_boards]] +connections = [] +link = "https://www.sparkfun.com/products/14450" +manufacturer = "Sparkfun" +name = "SparkFun Motor Driver - Dual TB6612FNG" diff --git a/frontend/src/crate-db.ts b/frontend/src/crate-db.ts index 13299f2..c4cd076 100644 --- a/frontend/src/crate-db.ts +++ b/frontend/src/crate-db.ts @@ -1,12 +1,29 @@ +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + export type Category = + | ("Timer" | "Timer::RTC") | "Analog" | "Analog::ADC" | "Analog::DAC" | "Sensor" - | "Sensor::PowerMeter"; + | "Sensor::PowerMeter" + | "Sensor::Accelerometer" + | "Sensor::Gyroscope" + | "Sensor::Magnetometer" + | "IoExpander" + | "IoExpander::PWM" + | "Actor" + | "Actor::MotorController" + | "Display" + | "Display::OLED"; export type ShortDependency = string; -export type SpiDeviceType = "SpiBus" | "SpiDevice"; -export type Manufacturer = "AnalogDevices" | "ST" | "TI" | "NXP" | "Unknown"; +export type Connection = "StemmaQt" | "MikroBus"; +export type BoardManufacturer = "Adafruit" | "Sparkfun" | "Mikroe" | "BBC"; export type Package = string; export interface FullCrateDb { @@ -16,22 +33,52 @@ export interface FullCrateDb { export interface FullCrate { description: string; + /** + * Functionalities this driver provides + */ categories?: Category[]; crate_size?: number | null; created_at: string; + /** + * Links to datasheets of chips that are supported by this driver + */ datasheets?: string[]; dependencies: ShortDependency[]; - dev_boards?: DevBoards; + dev_boards?: DevBoard[]; documentation?: string | null; downloads: number; homepage?: string | null; interfaces?: Interfaces; + /** + * Names of KiCAD symbold for chips this driver supports + */ kicad_symbol?: string[]; license: string; - manufacturer: Manufacturer; + /** + * Manufacturer that produces devices supported by this driver + */ + manufacturer: + | ( + | "AnalogDevices" + | "TI" + | "NXP" + | "Toshiba" + | "SolomonSystech" + | "Unknown" + ) + | "ST"; name: string; + /** + * Names of the chips this driver supports + */ names: string[]; + /** + * Packages or footprints in which chips are available + */ packages?: Package[]; + /** + * Part numbers of chips this driver supports + */ part_numbers?: string[]; repository?: string | null; resources?: Resource[]; @@ -39,32 +86,49 @@ export interface FullCrate { this_version_downloads: number; updated_at: string; version: string; -} -export interface DevBoards { - adafruit?: number | null; - mikroe?: number | null; - other?: GenericDevBoard[]; - sparkfun?: number | null; + [k: string]: unknown; } -export interface GenericDevBoard { +export interface DevBoard { + connections: Connection[]; link: string; + manufacturer: BoardManufacturer; name: string; + + [k: string]: unknown; } export interface Interfaces { + /** + * Information about the I2C interface (if present) + */ i2c?: I2C | null; + /** + * Information about the SPI interface (if present) + */ spi?: Spi | null; } export interface I2C { + /** + * Addresses that can be used by this device + */ addrs: number[]; + /** + * Does this device have an interrupt line? + */ interrupt: boolean; } export interface Spi { - bus_type: SpiDeviceType; + /** + * Whether this device can be used on a shared bus or only on an exclusive device + */ + bus_type: "SpiBus" | "SpiDevice"; + /** + * Does this device have an interrupt line? + */ interrupt: boolean; } diff --git a/frontend/src/lib/Crate.svelte b/frontend/src/lib/Crate.svelte index 2668d85..1dc0219 100644 --- a/frontend/src/lib/Crate.svelte +++ b/frontend/src/lib/Crate.svelte @@ -27,6 +27,9 @@
+
+ {crate.categories || []} +
{crate.name} {crate.version} @@ -72,23 +75,8 @@ {#if showDevBoards} {/if}