I am not allowed to share the real numbers, and the negotiations were back in 2018, so worthless now.
I shared the results from back then , take it or leave I don't care if you believe me or not, I know what I know.
Currently with the chips shortage all bets are off and you may be thankfull to get any allocation.
I believe you (personally). You negotiated very good price with ST. Is it possible that if you negotiated with a different vendor (or vendors) you would get even better price?

For arm cortex M3 and M4 cores (f2 and f4) we were not able to get better prices from other vendors. You have to understand that with these large procurements of half a million chips every $0.01 is $5000
For the f0 we did get a good deal with Atmel however after Microchip aquired Atmel the prices were almost doubled

$0.01 on a $5 chip is completely irrelevant - against all the other things one has to pay for.
$0.01 on a $5 chip is completely irrelevant - against all the other things one has to pay for.This is absolutely not the case. The biggest companies out there negotiate fractions of a cent, not just a cent. And smaller companies wish they can do the same. And yes, it is better to negotiate a smaller price and buy a jet on the saved money than just give away the price of a jet just just because you were to lazy to negotiate a better price.
If you are a car maker and you need 200 MCUs in a car, then every cent start to matter.
And MCU is not the only thing in the system. Once you are done with "one cent does not matter here" tactic, your board is a few dollars more expensive all of a sudden.
$0.01 on a $5 chip is completely irrelevant - against all the other things one has to pay for.
I don't know how good or bad the current STMCube stuff is. I looked at STPLIB a long time ago (~2014), and then I think the first HAL library. Both were significantly unimpressive: bloated, poor code, incorrect code, not substantially readable, etc.
That's all separate from IDEs. Using a library shouldn't lock users into a particular IDE. For any IDE, there will be a significant number of users who HATE it. Libraries that are easy to integrate into "any" configurable IDE are much better than ones that assume a particular development environment.
looking at someone else's source code almost ALWAYS triggers criticism.
integerdivider = ((25 * apbclock) / (4 * (USART_InitStruct->USART_BaudRate)));
tmpreg = (integerdivider / 100) << 4;
/* Determine the fractional part */
fractionaldivider = integerdivider - (100 * (tmpreg >> 4));
/* Implement the fractional part in the register */
tmpreg |= ((((fractionaldivider * 16) + 50) / 100)) & ((uint8_t)0x0F);
/* Write to USART BRR */
USARTx->BRR = (uint16_t)tmpreg;
// .h file
#define USART_DIV(_PCLK_, _BAUD_) (((_PCLK_)*25U)/(4U*(_BAUD_)))
#define USART_DIVMANT(_PCLK_, _BAUD_) (USART_DIV((_PCLK_), (_BAUD_))/100U)
#define USART_DIVFRAQ(_PCLK_, _BAUD_) ((((USART_DIV((_PCLK_), (_BAUD_)) - (USART_DIVMANT((_PCLK_), (_BAUD_)) * 100U)) * 16U) + 50U) / 100U)
/* UART BRR = mantissa + overflow + fraction
= (UART DIVMANT << 4) + ((UART DIVFRAQ & 0xF0) << 1) + (UART DIVFRAQ & 0x0FU) */
#define USART_BRR(_PCLK_, _BAUD_) (((USART_DIVMANT((_PCLK_), (_BAUD_)) << 4U) + \
((USART_DIVFRAQ((_PCLK_), (_BAUD_)) & 0xF0U) << 1U)) + \
(USART_DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0FU))
// .c file:
husart->Instance->BRR = USART_BRR(pclk, husart->Init.BaudRate);
Usart->BRR = pclk/baud;



" fractions of a cent on each part in e.g. a modern EV can make or break the product and the company, and countless hours are spent optimizing and squeezing every last cent out of the CBOM."
That is part of why so many bigger companies are sh*t places to work for, and are really sh*t to have as a customer
But generally speaking, looking at someone else's source code almost ALWAYS triggers criticism.
because all the real challenges are elsewhere than getting UART to print characters.
MISRA is completely uninteresting. It's another tick in the box for Powerpoint managers, and completely depends on the case if it helps or hinders. Usually the latter.
It's not some holy grail of safe development practices, it's really just a small list of forbidden constructs that sometimes have caused problems. Look it up. It's a slightly more advanced and better formed version of "don't use goto". It's clearly a panic reply to actual problems.
It does not in any way help avoiding problems in all the remaining constructs. It isn't even designed to help in developing safe code (where specification of edge cases, testing, code coverage, verification and proving things come in). These are all difficult, and MISRA's purpose isn't to even comment on them.
But generally speaking, looking at someone else's source code almost ALWAYS triggers criticism.
Yes, and it's always considerable amount of work integrating other's code and libraries. Because it sucks, it has to provide something back. I.e., spend 10 hours to reuse work by others, save 100 hours by not having to do the work from scratch. That would be an acceptable ratio.
That is exactly why we use large libraries to do non-trivial things. This is why we use OpenCV to help with computer vision, or use existing BSD or linux networking stack.
I follow the TinyUSB project, which aims to provide a common user-facing solution for the device classes it supports, while handling the chip-specific stuff in the background for you. As you can imagine, it's got a lot of preprocessor macros that sort out which USB peripheral and which processor are used. I haven't had a chance to really test any of it, but at least there's work going on in this area.
MISRA fails to remove common C pitfalls. It addresses an uninterestingly small part of actual programming errors. The problem is deep in C. It is just a powerful but somewhat dangerous language. You can't fundamentally make it better by removing half of the power, and half of the pitfalls. Mistakes will be made regardless, and the key is to find and correct the mistakes. Even better, their root causes.
But yeah, MISRA's great for the hobbyists role-playing safety critical aerospace industry. In this regard, I completely understand why STM32 HAL is written in MISRA compliant C. It hits the target.
