Skip to content

Commit

Permalink
Add pre-commit and CI
Browse files Browse the repository at this point in the history
A basic pre-commit setup has been added. CI has been implemented with it
to keep a baseline level of quality. Offending files have been fixed as
well.
  • Loading branch information
crazybolillo committed Mar 8, 2024
1 parent 9e9b50e commit 4a3f9bf
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 21 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/qa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: QA
on:
pull_request:
push:
branches:
- "main"
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/[email protected]
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: trailing-whitespace
- id: end-of-file-fixer
- id: mixed-line-ending
args: ["--fix=lf"]
1 change: 0 additions & 1 deletion archetypes/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
---

1 change: 0 additions & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ params:
URL: "https://github.com/zoftko/blog/blob/main/content"
text: "Suggest changes"
appendFilePath: true

2 changes: 1 addition & 1 deletion content/posts/handmade-rf-mixer-board-mc1496.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ with SMD components (this was my first time soldering them).

# Building the board
Board layout is very important when designing high speed or high frequency circuits. Some basic
guidelines are:
guidelines are:

* Traces need to be kept as short as possible to minimize the effects associated with transmission lines.
* Component leads should be kept short, or else they will act as inductors. Their parasitic
Expand Down
5 changes: 2 additions & 3 deletions content/posts/how-to-use-led1642gw.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ a serial link. This article documents how to achieve such control with the help
microcontroller.

The end result is the following, a constant fade in/out of LEDs achieved by varying the brightness
to which the LED1642GW channels are set.
to which the LED1642GW channels are set.

*Note that the blinking can't be perceived by the human eye but gets picked up by the camera.*

Expand Down Expand Up @@ -106,7 +106,7 @@ void TIM2_IRQHandler(void) {
le_off();
clock_off();
// Turn off timer and notify message has been sent
TIM2->CR1 &= ~(TIM_CR1_CEN);
TIM2->CR1 &= ~(TIM_CR1_CEN);
vTaskNotifyGiveFromISR(led1642TaskHandle, NULL);
}
}
Expand Down Expand Up @@ -142,4 +142,3 @@ other souls.
than enough.
Finally, the complete [code implementation can be consulted here](https://github.com/crazybolillo/stm32f401xc/blob/main/src/led1642.c).
3 changes: 1 addition & 2 deletions content/posts/lessons-first-side-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ integration.
I don't like designing UIs, I can appreciate a well designed one, but usually prefer to stick with
CLIs. This makes designing the front end very tedious. Once I get a general idea it is not too hard
to code it. I used [Thymeleaf](https://www.thymeleaf.org/), [daisyUI](https://daisyui.com/)
and [htmx](https://htmx.org/).
and [htmx](https://htmx.org/).

With this I was able to get an acceptable (I think) UI, however there was not even a proper
landing page and I was not really happy with it. This was an itch I was able to sweep under the rug
Expand Down Expand Up @@ -84,4 +84,3 @@ have a finished side project with acceptable quality, you really need to keep it
I may come back in the future to try something similar but with a much simpler workflow. For the
time being I am happy with the things I learnt. It sounds cheesy but it does seem like after all,
failure is the quickest path to success.

12 changes: 6 additions & 6 deletions content/posts/simple-am-transmitter-mc1496.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ date: 2022-08-04T12:31:54-06:00
tags: ["Electronics", "RF"]
---
The MC1496 is a Balanced Modulator/Demodulator, capable of producing amplitude modulated signals.
Its internal structure resembles a Gilbert Cell biased by two current sources (one for each leg of the circuit),
Its internal structure resembles a Gilbert Cell biased by two current sources (one for each leg of the circuit),
both of them being biased by a single diode with a 500 Ohm resistor.

{{< figure src="/img/simple-am-transmitter-mc1496/internals.png" title="MC1496 - Internal Schematic" align="center" >}}
Expand All @@ -23,7 +23,7 @@ At least three components are required in order to generate an AM signal:
* Mixer (modulator)

In order for the transmitter to be heard by a commercial receiver, it needs to transmit in the AM commercial band
(illegal without a license), this band normally goes from
(illegal without a license), this band normally goes from
[530 to 1700 MHz](https://en.wikipedia.org/wiki/Medium_wave#Spectrum_and_channel_allocation).
I have no regards for the law, and this design does not have enough power nor an antenna good enough (would need to
be at least 75 m long) to interfere with commercial broadcasts, so a 1 MHz crystal is used for generating the carrier
Expand All @@ -43,11 +43,11 @@ desirable.

And from [Crystal Oscillator Circuits](https://www.amazon.com/gp/product/0471874019):
> It has very good short-term stability because the crystal’s source and load impedance are mostly capacitive rather
than resistive, which give it a high in-circuit Q.
than resistive, which give it a high in-circuit Q.
The circuit provides a large output signal and simultaneously drives the crystal at a low power level.

The output is taken from the base of the transistor, where there exists a (relatively) big capacitance, so any
extra stray capacitance introduced by the next stage won't affect the oscillator too much.
extra stray capacitance introduced by the next stage won't affect the oscillator too much.

The next stage consists of a common collector buffer, being biased by a constant current source in an attempt to
provide a high input impedance, trying to isolate the oscillator as much as possible from the next stages.
Expand All @@ -73,15 +73,15 @@ overview of the guidelines and the design steps to follow them were:
3. Modulating pins(1, 4) must be 2.7V below the carrier pins.
4. The bias pin(5) must be 2.7V below the modulating pins.

This leaves very little headroom, and it's why inductors were used at the output stage.
This leaves very little headroom, and it's why inductors were used at the output stage.
They act as resistances at the operating frequency, providing the gain necessary, but act as a short circuit when
it comes to DC biasing.

Bias current (I5) was chosen to be 1mA, considering the diode forward voltage to be 0.75 Vdc at ambient
temperature, the voltage at the bias pin turns out to be 1.25 V.

Knowing the max and min voltage limits, a resistor network was added to provide bias to the two missing stages
of the circuit.
of the circuit.

Audio is inserted into pin 4, where a variable resistor controls the modulation index.
[This video](https://www.youtube.com/watch?v=38OQub2Vi2Q) explains how varying the bias voltage affects the
Expand Down
13 changes: 6 additions & 7 deletions content/posts/stm32-bare-metal-usb-implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ title: "STM32 Bare Metal USB Implementation"
date: 2023-07-20T23:35:19-06:00
tags: ["Electronics", "ARM", "STM32", "USB"]
---
Implementing your own bare metal USB stack may provide certain benefits like little to no
dependencies, smaller code size, better understanding of internals and suffering.
Implementing your own bare metal USB stack may provide certain benefits like little to no
dependencies, smaller code size, better understanding of internals and suffering.

This article documents the process I went through to manually set up and get the USB
core of an STM32F401CCU6 to do what I wanted. My goal was to successfully return a device descriptor.
Once I got that working I had a greater appreciation for TinyUSB and went with it, however this was
still a ~~painful~~ great learning experience.

It is expected for the reader to already be familiar with USB as a protocol,
to get up to speed there are great resources like
to get up to speed there are great resources like
[USB Made Simple](https://www.usbmadesimple.co.uk/).

# Implementation
Expand All @@ -22,7 +22,7 @@ for most other chips.
## Clock setup
First step is to produce a 48 MHz clock. The board I had uses a 25 MHz crystal which will be used
as a source. The system clock will also be derived from the PLL and set to 72 MHz. This last step
is optional. Be warned that **setting the system clock too low will prevent the USB core from correct
is optional. Be warned that **setting the system clock too low will prevent the USB core from correct
functioning**. The exact frequency can be found on your MCU manual, in this case the AHB frequency
should be higher than 14.2 MHz. Here is the code used for setup:

Expand All @@ -33,7 +33,7 @@ while ((FLASH->ACR & FLASH_ACR_LATENCY) != FLASH_ACR_LATENCY_2WS) continue;

// Output the clock to MCO1 for verification
// Set prescaler for APB1 as to not exceed the max frequency recommended (42 MHZ)
RCC->CFGR |= (0x06 << RCC_CFGR_MCO1PRE_Pos) | (0x03 << RCC_CFGR_MCO1_Pos) |
RCC->CFGR |= (0x06 << RCC_CFGR_MCO1PRE_Pos) | (0x03 << RCC_CFGR_MCO1_Pos) |
(0x04 << RCC_CFGR_PPRE1_Pos);

// Turn on HSE (crystal oscillator) which will be used as the PLL source
Expand Down Expand Up @@ -267,7 +267,7 @@ the source code for the driver.

* During implementation, I had a horrible bug which took me a week to solve. The device was successfully
writing the descriptor, but was not ACK the Status OUT packet which caused transactions to timeout. You
can read the whole adventure on the [ST community forums](https://community.st.com/t5/stm32-mcu-products/ep0-in-transfer-times-out/td-p/573140).
can read the whole adventure on the [ST community forums](https://community.st.com/t5/stm32-mcu-products/ep0-in-transfer-times-out/td-p/573140).
Hint: I failed to follow the datasheet and was using an RXFIFO which was not big enough.

## Full code
Expand Down Expand Up @@ -306,4 +306,3 @@ and USB protocol itself. At the time it will seem that there is no information a
will read over and over any resources you can find on implementing USB manually. Over time it gets
easier and once you are on the other side it does seem obvious. Writing this post now makes it seem
like it wasn't that bad after all. Hindsight is always 20/20.

0 comments on commit 4a3f9bf

Please sign in to comment.