How to compare a result of a function ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2015-10-11 3:39 AM
Guys,
How can compare the result of the furnction output ? I have on main.c :Code:
result = VS1053_Init(); if (result == 0) { HAL_GPIO_WritePin(GPIOE, GPIO_PIN_6 , 1 ); HAL_Delay(100); HAL_GPIO_WritePin(GPIOE, GPIO_PIN_6 , 0 ); }
and : vs.c :Code:
unsigned char VS1053B_Init() { . . . return 0; }
Thanks- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2015-10-11 9:47 AM
Presumably related to [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/Unsigned%20char%20is%20always%20true&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/AllItems.aspx¤tviews=19]this thread. Try to keep materially connected stuff in one thread, please.
Yes, the code here looks reasonable enough. Your problem is more likely when trying to compare things when aren't directly comparable, or of the same ranges. XX == YYYY ? If the number you want is 16-bit wide, then holding it in an 8-bit variable isn't going to work. The most significant 8-bits of information will get wiped away. Maybe you want to go back and review the chapter on numeric representation, and how numbers would be held in 8, 16, or 32-bit variables/registersUp vote any posts that you find helpful, it shows what's working..
