Received: from PCH.mit.edu (18.7.21.50) by mail.efplus.com (192.168.0.8) with Microsoft SMTP Server (TLS) id 8.3.485.1; Thu, 30 Jul 2020 11:21:40 -0700 Received: from PCH.MIT.EDU (localhost.localdomain [127.0.0.1]) by PCH.mit.edu (8.14.7/8.12.8) with ESMTP id 06UIDHlC028161; Thu, 30 Jul 2020 14:13:38 -0400 Received: from outgoing-exchange-7.mit.edu (OUTGOING-EXCHANGE-7.MIT.EDU [18.9.28.58]) by PCH.mit.edu (8.14.7/8.12.8) with ESMTP id 06UI4V0F027055 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Jul 2020 14:04:31 -0400 Received: from oc11exedge1.exchange.mit.edu (OC11EXEDGE1.EXCHANGE.MIT.EDU [18.9.3.17]) by outgoing-exchange-7.mit.edu (8.14.7/8.12.4) with ESMTP id 06UI2Ib2011987 for ; Thu, 30 Jul 2020 14:02:41 -0400 Received: from oc11exhyb3.exchange.mit.edu (18.9.1.99) by oc11exedge1.exchange.mit.edu (18.9.3.17) with Microsoft SMTP Server (TLS) id 15.0.1293.2; Thu, 30 Jul 2020 14:03:41 -0400 Received: from oc11exhyb3.exchange.mit.edu (18.9.1.99) by oc11exhyb3.exchange.mit.edu (18.9.1.99) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 30 Jul 2020 14:04:08 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.43) by oc11exhyb3.exchange.mit.edu (18.9.1.99) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Thu, 30 Jul 2020 14:04:08 -0400 Received: from DM6PR11CA0065.namprd11.prod.outlook.com (2603:10b6:5:14c::42) by MWHPR01MB3248.prod.exchangelabs.com (2603:10b6:300:fb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.22; Thu, 30 Jul 2020 18:04:06 +0000 Received: from DM3NAM03FT031.eop-NAM03.prod.protection.outlook.com (2603:10b6:5:14c:cafe::d6) by DM6PR11CA0065.outlook.office365.com (2603:10b6:5:14c::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.17 via Frontend Transport; Thu, 30 Jul 2020 18:04:06 +0000 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (40.92.4.25) by DM3NAM03FT031.mail.protection.outlook.com (10.152.82.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.10 via Frontend Transport; Thu, 30 Jul 2020 18:04:06 +0000 Received: from CY1NAM02FT021.eop-nam02.prod.protection.outlook.com (10.152.74.52) by CY1NAM02HT080.eop-nam02.prod.protection.outlook.com (10.152.74.245) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.20; Thu, 30 Jul 2020 18:04:06 +0000 Received: from BYAPR02MB4055.namprd02.prod.outlook.com (2a01:111:e400:7e45::43) by CY1NAM02FT021.mail.protection.outlook.com (2a01:111:e400:7e45::443) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.17 via Frontend Transport; Thu, 30 Jul 2020 18:04:05 +0000 Received: from BYAPR02MB4055.namprd02.prod.outlook.com ([fe80::e04e:e8e2:57be:7927]) by BYAPR02MB4055.namprd02.prod.outlook.com ([fe80::e04e:e8e2:57be:7927%7]) with mapi id 15.20.3216.034; Thu, 30 Jul 2020 18:04:05 +0000 From: Bob Blick To: Microcontroller discussion list - Public. Sender: "piclist-bounces@mit.edu" Date: Thu, 30 Jul 2020 11:04:05 -0700 Subject: Re: [PIC] Simple GCC question Thread-Topic: [PIC] Simple GCC question Thread-Index: AQHWZotc+nNhZovUu0iBK4Bhj1/IWakgV02AgAAINQWAAAbfgIAAA3fr Message-ID: References: , List-Help: List-Subscribe: , List-Unsubscribe: , In-Reply-To: Reply-To: Microcontroller discussion list - Public. Accept-Language: en-US Content-Language: en-US X-MS-Exchange-Organization-AuthAs: Anonymous X-MS-Exchange-Organization-AuthSource: TS500.efplus4.local X-MS-Has-Attach: X-Auto-Response-Suppress: All X-MS-Exchange-Organization-SenderIdResult: TempError X-MS-Exchange-Organization-PRD: mit.edu X-MS-TNEF-Correlator: acceptlanguage: en-US received-spf: Pass (protection.outlook.com: domain of outlook.com designates 40.92.4.25 as permitted sender) receiver=protection.outlook.com; client-ip=40.92.4.25; helo=NAM02-CY1-obe.outbound.protection.outlook.com; dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8eN1bKFEPK87JnVdy3dtyUddPw3kWkjnMtBnHm/ZVyU=; b=PanfOp01p4EED38Ba8ttWPuuEI90WAY51M1ktAjryy9WKM7ovRLgIv+5pThintIJImYGFFoF5noieuyGeBi6WD+JGvWsFC6uXWX2+wkZRD8bAq0pl3Mox9EbS2pVVpXOxo5AzgUNsLZJpvFOq20tSrU6oJAZo7qL5U6v8i5HfFiw+ilgWdQnHXcq53v7Zs/gKDcwu9zEQX0J0F/+8nDzW/ykTiNORtyp6EHM4zwSoh9zUl1u7ssRGxCa92ddw2I93iju4aGOHwhmOVFWeFe+bs3AimbCnL4s2rRXy/J72E+KLzWYgy17YWnhtTCvOzkHnH6DmR1GdXIa0F14hiQdIA== authentication-results: spf=pass (sender IP is 40.92.4.25) smtp.mailfrom=outlook.com; mit.edu; dkim=pass (signature was verified) header.d=outlook.com; mit.edu; dmarc=pass action=none header.from=outlook.com; errors-to: piclist-bounces@mit.edu list-id: "Microcontroller discussion list - Public." list-post: x-beenthere: piclist@mit.edu x-mailman-version: 2.1.6 x-topics: [PIC] x-mime-autoconverted: from quoted-printable to 8bit by PCH.mit.edu id 06UI4V0F027055 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Hi Manu, I will give it a try. I guess I wasn't just too stupid not to be able to ma= ke it work without changes. Thank you very much. Bob ________________________________________ From: piclist-bounces@mit.edu on behalf of Manu A= braham=20 Sent: Thursday, July 30, 2020 10:49 AM To: Microcontroller discussion list - Public. Subject: Re: [PIC] Simple GCC question Hi Bob, Another look at the github code, I would do this: #define MODE .. #define EN_PIN LL_GPIO_PIN_0 #define EN_PORT GPIOB ... and more Lcd_HandleTypeDef lcd; <-- make this global, int main(void) { ... do whatever .. lcd.mode =3D MODE; lcd.en_pin =3D EN_PIN; lcd.en_port =3D EN_PORT; lcd.rs_pin =3D rs_pin; lcd.rs_port =3D rs_port; lcd.data_pin =3D pin; lcd.data_port =3D port; Lcd_init(&lcd); ... do whatever .. } Lcd_init() happens to be public via lcd.h. So, you do not need to clobber the library, but just that you do not need to call Lcd_create() fn. Advantage, lower memory usage, lesser complexity. :-) Regards, Manu On Thu, Jul 30, 2020 at 11:08 PM Bob Blick wrote: > > Hi Manu, > > Although the LCD will not normally be driven from interrupts, if there is= a lockup I would like it to leave an error code on the display, which woul= d need to be done from an interrupt. > > I guess to make it global without errors I will need to hardcode the port= s and pins so I get rid of the arrays that are handed to Lcd_create() > > Thanks, Bob > > ________________________________________ > From: piclist-bounces@mit.edu on behalf of Manu= Abraham > Sent: Thursday, July 30, 2020 9:55 AM > To: Microcontroller discussion list - Public. > Subject: Re: [PIC] Simple GCC question > > On Thu, Jul 30, 2020 at 9:57 PM Bob Blick wrote: > > > > I'm using a nice little HD44780 LCD library in an STM32 project, it wor= ks great but I'm stuck with a variable scope problem that I can only seem t= o make worse because GCC is a bit stricter than I want it to be at this poi= nt. Sorry if the code example doesn't wordwrap properly. > > > > If, somewhere in main() I create an instance of the LCD like this: > > Lcd_PortType ports[] =3D {LCD_D4_GPIO_Port, LCD_D5_GPIO_Port, LCD_D6_= GPIO_Port, LCD_D7_GPIO_Port}; > > Lcd_PinType pins[] =3D {LCD_D4_Pin, LCD_D5_Pin, LCD_D6_Pin, LCD_D7_Pi= n}; > > Lcd_HandleTypeDef lcd =3D Lcd_create(ports, pins, LCD_RS_GPIO_Port, L= CD_RS_Pin, LCD_EN_GPIO_Port, LCD_EN_Pin, LCD_4_BIT_MODE); > > > > Why I dislike opaque datatypes... > > Instead of copying objects to Lcd_create(), a pointer could have been use= d, > storage could have been global, made static .. > the variables appear to be for configuration purposes ? > > One way to do is make the lcd object global. > > Another way is to pass a lcd object pointer to whatever function you > are calling, > unless you need to access the lcd object from interrupt context. > If you need access from interrupt context, the easier way is to have > global storage. > > -- > --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .