STM32 L1 Standard Peripheral Lib Revisited

stm32_icon_bigHello everyone! Today I thought that I might actually share my version of STM32L Standard Peripheral Library that I am using for all my projects. You would probably ask if it is any different from what ST Microelectronics already gave you. Well there are few differences which are presented below. You may also ask why bother switching to my library instead of using ST’s. The main reason for that is, that all of my projects are/will be based on this piece of code, so if you are interested in those you may want to get familiar with my lib. I plan to upload some simple examples (“Hello, World!” like, you know, for basic interfaces, GPIO, SPI, I2C, DMA…), so stay tuned and watch for updates.

Change-list

  • I’ve got rid of all that CMSIS related sources – since I’m using CodeSourcery toolchain I have no need to have those. To maintain support for all ARM related things I have created separate files like nvic.c, systick.c and so on, which are no different (in terms of usage, from programmer’s point of view, of course) from any other peripheral.
  • I’ve improved code formatting, because I hate it when lines of code have more than 80 characters. That gray, vertical line (a.k.a. “margin”) in your editor exists there for a reason which is called “usability”. Whenever you try to open two source code files in, let’s say, Eclipse IDE then long lines of code can really ruin your day, because not only that you have to scroll up and down but, in addition you need to go from left to right. Bummer!
  • Most of functions have the same name as in ST’s version, but some of those were altered to be more descriptive about what they really do. Nevertheless you should’n have any hard time with that.
  • I made some use of bit-banding feautre in some of those functions, just to improve overall performance.
  • I removed all #define #if and all that macro magic used in *.c files by ST. I find it pretty hard to debug such things.
  • I removed all “asserts“, wasn’t using those anyway…

That’s about it. I’m about to post all my source code in downloads section of this page, so you all can have a better access to it.

Mighty Little FM Transmitter (part 1)

fmtrx_icon_bigWell there is one thing that’s most annoying about laptops: their speakers. People often choose to listen to their music with headphones, but still, sitting with headphones on for a number of hours is not too comfortable nor healthy. Many of us use speaker systems but that often leads to quite a mess with all those cables and power cords.

Since I’m in possession of Phillips Music Center with integrated FM receiver I wanted to make some use out of it. In order to avoid a long piece of audio cable going on my floor from my laptop to music center itself, I thought of a device that would allow me to send my audio signal in a wireless manner. Here is the whole story how this simple idea materialized.

Step One: Concept.

To make this device functional it had to satisfy following requirements:

  • Ability to transmit high quality audio signal in FM Broadcast Band (stereo, high bandwidth, etc.)
  • Implement USB Audio Sound Card (driver-less solution) to get all the audio from my laptop, so that additional stereo jack connection wouldn’t be necessary.
  • Power the whole system from USB port (again – no additional cables)
  • Optional: Implement FM receiver, so that I could send audio from one PC to another
  • Support as many different architectures/OSes/etc. as possible
  • Implement an easy way to modify parameters (such as transmit frequency) over USB (single interface to rule it all)

Step Two: Choosing the right components for the job.

… a.k.a choosing the obvious. Implementing whole FM circuitry all by myself would be pointless and painful (to say the least). The overall outcome in terms of performance would be doubtful, so I decided to choose a single IC solution that integrates all that I needed: Si4721, from Silicon Labs. Just a single glance at it’s datasheet and you know you’ve scored a home-run.

What about MCU? Well, considering my stock, again – I chose the obvious candidate for the job: STM32L151, from ST Microelectronics. I have couple of those as leftovers from my previous projects. It embeds all that is needed to make a perfect ‘heart’ of entire system and I really like working with ST MCUs :)

I also decided to design and implement a simple RF Power Amplifier just to pump up the output antenna swing a little bit, mainly because I’m about to use short monopole antenna, known as ‘the wire’ Using full size monopole antenna for FM Band would be a project-killer IMHO (75 cm of wire sticking out of my USB dongle? no thanks, maybe another time..)

Additional parts included: some LDO that will be capable of powering all ICs and PA as well, LEDs just to notify the user of current mode of operation, USB state, etc.., passive components, blah blah…

Stay tuned for more !